List of usage examples for java.util Iterator remove
default void remove()
From source file:com.aurel.track.admin.customize.lists.systemOption.IssueTypeBL.java
public static List<TListTypeBean> loadByPersonAndProjectAndRight(Integer personID, Integer projectID, int[] rightFlags, boolean documents) { List<TListTypeBean> resultList = new LinkedList<TListTypeBean>(); if (projectID == null) { return resultList; }//from w w w .java 2 s . co m //allowed by project type TProjectBean projectBean = LookupContainer.getProjectBean(projectID); List<TListTypeBean> issueTypesAllowedByProjectType = loadAllowedByProjectType(projectBean.getProjectType(), documents); //get the roles Set<Integer> rolesSet = AccessBeans.getRolesWithRightForPersonInProject(personID, projectID, rightFlags); if (rolesSet == null || rolesSet.isEmpty()) { return resultList; } Object[] roleIDs = rolesSet.toArray(); //roles with issueType restrictions List<TRoleBean> roleWithExplicitIssueType = RoleBL.loadWithExplicitIssueType(roleIDs); //at least one role has no restrictions for listType if (roleWithExplicitIssueType != null && roleWithExplicitIssueType.size() < rolesSet.size()) { //load all list types allowed in project type return issueTypesAllowedByProjectType; } //all roles have explicit issue type restrictions //get all those explicit issueTypes for roles List<TListTypeBean> allowedByRoles = issueTypeDAO.loadForRoles(roleIDs); Map<Integer, TListTypeBean> allowedByProjectTypeMap = GeneralUtils .createMapFromList(issueTypesAllowedByProjectType); if (allowedByRoles != null) { Iterator<TListTypeBean> iterator = allowedByRoles.iterator(); while (iterator.hasNext()) { TListTypeBean listTypeBean = iterator.next(); if (!allowedByProjectTypeMap.containsKey(listTypeBean.getObjectID())) { iterator.remove(); } } } return allowedByRoles; }
From source file:com.fengduo.bee.commons.core.lang.CollectionUtils.java
public static <T extends Object> void remove(Collection<T> values, Grep<T> grep, int limit) { Iterator<T> iterator = values.iterator(); int i = 0;/*from ww w . j a v a2s . c o m*/ while (iterator.hasNext()) { if (grep.grep(iterator.next())) { iterator.remove(); i++; } if (i >= limit) { break; } } }
From source file:nl.minbzk.dwr.zoeken.enricher.processor.UIMAInjector.java
/** * Release all context resources back to their respective CasPools. * /*from w ww . ja va 2 s. c o m*/ * @param context */ @SuppressWarnings("unchecked") public static void release(final ProcessorContext context) { Map<String, CASUnit> casses = (Map<String, CASUnit>) context.getParameter(CONTEXT_PARAMETER_CAS); if (logger.isDebugEnabled()) logger.debug(format("Found %d CAS structures that can be released back to their pool", casses.size())); Iterator<Entry<String, CASUnit>> iterator = casses.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, CASUnit> entry = iterator.next(); if (logger.isDebugEnabled()) logger.debug(format("About to release CAS %s", entry.getValue().getCas().toString())); entry.getValue().getUimaUnit().releaseCas(entry.getValue().getCas()); iterator.remove(); } if (logger.isDebugEnabled()) logger.debug("Finished releasing all CAS structures back to their pool"); }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.controller.BratAjaxCasUtil.java
public static List<AnnotationFS> selectAt(CAS aJcas, final Type type, int aBegin, int aEnd) { List<AnnotationFS> covered = CasUtil.selectCovered(aJcas, type, aBegin, aEnd); // Remove all that do not have the exact same offset Iterator<AnnotationFS> i = covered.iterator(); while (i.hasNext()) { AnnotationFS cur = i.next();/* w w w . j a v a2s.c om*/ if (!(cur.getBegin() == aBegin && cur.getEnd() == aEnd)) { i.remove(); } } return covered; }
From source file:com.mindquarry.desktop.workspace.ConflictHelper.java
/** * Finds all conflicts where a locally deleted file conflicts with a remote * file modification.// ww w . j a va 2 s.c o m */ public static List<Conflict> findFileDeleteModifiedConflicts(List<Status> remoteAndLocalChanges) { List<Conflict> conflicts = new ArrayList<Conflict>(); Iterator<Status> iter = remoteAndLocalChanges.iterator(); while (iter.hasNext()) { Status status = iter.next(); // local DELETE if (status.getNodeKind() == NodeKind.file && status.getTextStatus() == StatusKind.deleted) { // if remote MOD if (status.getRepositoryTextStatus() == StatusKind.modified) { iter.remove(); conflicts.add(new DeleteWithModificationConflict(true, status, null)); } } } return conflicts; }
From source file:com.mindquarry.desktop.workspace.ConflictHelper.java
/** * Finds all conflicts where a locally modified file conflicts with a remote * file deletion.//from w w w. java2 s. c o m */ public static List<Conflict> findFileModifiedDeleteConflicts(List<Status> remoteAndLocalChanges) { List<Conflict> conflicts = new ArrayList<Conflict>(); Iterator<Status> iter = remoteAndLocalChanges.iterator(); while (iter.hasNext()) { Status status = iter.next(); // remote DELETE if (status.getNodeKind() == NodeKind.file && status.getRepositoryTextStatus() == StatusKind.deleted) { // if local MOD if (status.getTextStatus() == StatusKind.modified) { iter.remove(); conflicts.add(new DeleteWithModificationConflict(false, status, null)); } } } return conflicts; }
From source file:com.xqdev.jam.MLJAM.java
private static Interpreter getInterpreter(String contextId) throws EvalError { // Get the appropriate interpreter Interpreter i = null;/*from w w w . j av a 2 s.c o m*/ boolean createdInterp = false; synchronized (interpreters) { // serialize two gets of the same name i = interpreters.get(contextId); if (i == null) { i = new Interpreter(); interpreters.put(contextId, i); createdInterp = true; } } if (createdInterp) { Log.log("Created context: " + contextId + " (" + i + ")"); // Now configure stdin and stdout to capture 10k of content // Store references to the circular buffers within the interpreter itself. // This provides a nice place to store them plus theoretically allows // advanced use from within the bsh environment. // On Windows print() outputs \r\n but in XQuery that's normalized to \n // so the 10k of Java buffer may produce less than 10k of content in XQuery! OutputStream circularOutput = new CircularByteArrayOutputStream(10240); PrintStream printOutput = new PrintStream(circularOutput); i.setOut(printOutput); i.set("mljamout", circularOutput); OutputStream circularError = new CircularByteArrayOutputStream(10240); PrintStream printError = new PrintStream(circularError); i.setErr(printError); i.set("mljamerr", circularError); // Capture the built-in System.out and System.err also. // (Commented out since System appears global, can't do per interpreter.) //i.set("mljamprintout", printOutput); //i.set("mljamprinterr", printError); //i.eval("System.setOut(mljamprintout);"); //i.eval("System.setErr(mljamprinterr);"); // Need to expose hexdecode() and base64decode() built-in functions i.eval("hexdecode(String s) { return com.xqdev.jam.MLJAM.hexDecode(s); }"); i.eval("base64decode(String s) { return com.xqdev.jam.MLJAM.base64Decode(s); }"); // Let's tell the context what its id is i.set("mljamid", contextId); } // Update the last accessed time, used for cleaning i.set("mljamlast", System.currentTimeMillis()); // If it's been long enough, go snooping for stale contexts if (System.currentTimeMillis() > lastClean + CLEAN_INTERVAL) { Log.log("Initiated periodic scan for stale context objects"); lastClean = System.currentTimeMillis(); Iterator<Interpreter> itr = interpreters.values().iterator(); while (itr.hasNext()) { Interpreter interp = itr.next(); Long last = (Long) interp.get("mljamlast"); if (System.currentTimeMillis() > last + STALE_TIMEOUT) { itr.remove(); Log.log("Staled context: " + interp.get("mljamid") + " (" + interp + ")"); } else if ((System.currentTimeMillis() > last + TEMP_STALE_TIMEOUT) && ("" + interp.get("mljamid")).startsWith("temp:")) { itr.remove(); Log.log("Staled temp context: " + interp.get("mljamid") + " (" + interp + ")"); } } } return i; }
From source file:com.android.launcher4.InstallShortcutReceiver.java
public static void removeFromInstallQueue(SharedPreferences sharedPrefs, ArrayList<String> packageNames) { if (packageNames.isEmpty()) { return;// w ww. j a va2 s .co m } synchronized (sLock) { Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null); if (DBG) { Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames); } if (strings != null) { Set<String> newStrings = new HashSet<String>(strings); Iterator<String> newStringsIter = newStrings.iterator(); while (newStringsIter.hasNext()) { String json = newStringsIter.next(); try { JSONObject object = (JSONObject) new JSONTokener(json).nextValue(); Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); String pn = launchIntent.getPackage(); if (pn == null) { pn = launchIntent.getComponent().getPackageName(); } if (packageNames.contains(pn)) { newStringsIter.remove(); } } catch (org.json.JSONException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } catch (java.net.URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to remove: " + e); } } sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>(newStrings)).commit(); } } }
From source file:io.swagger.codegen.languages.Swift3Codegen.java
private static CodegenModel reconcileProperties(CodegenModel codegenModel, CodegenModel parentCodegenModel) { // To support inheritance in this generator, we will analyze // the parent and child models, look for properties that match, and remove // them from the child models and leave them in the parent. // Because the child models extend the parents, the properties will be available via the parent. // Get the properties for the parent and child models final List<CodegenProperty> parentModelCodegenProperties = parentCodegenModel.vars; List<CodegenProperty> codegenProperties = codegenModel.vars; codegenModel.allVars = new ArrayList<CodegenProperty>(codegenProperties); codegenModel.parentVars = parentCodegenModel.allVars; // Iterate over all of the parent model properties boolean removedChildProperty = false; for (CodegenProperty parentModelCodegenProperty : parentModelCodegenProperties) { // Now that we have found a prop in the parent class, // and search the child class for the same prop. Iterator<CodegenProperty> iterator = codegenProperties.iterator(); while (iterator.hasNext()) { CodegenProperty codegenProperty = iterator.next(); if (codegenProperty.baseName == parentModelCodegenProperty.baseName) { // We found a property in the child class that is // a duplicate of the one in the parent, so remove it. iterator.remove(); removedChildProperty = true; }// w ww . j av a 2 s.co m } } if (removedChildProperty) { // If we removed an entry from this model's vars, we need to ensure hasMore is updated int count = 0, numVars = codegenProperties.size(); for (CodegenProperty codegenProperty : codegenProperties) { count += 1; codegenProperty.hasMore = (count < numVars) ? true : false; } codegenModel.vars = codegenProperties; } return codegenModel; }
From source file:org.cloudifysource.quality.iTests.test.cli.cloudify.util.NewRestTestUtils.java
private static void waitForManagersToShutDown(final ControllerDetails[] managers, final int port, final long timeoutMinutes) throws InterruptedException, TimeoutException, CLIException { final Set<ControllerDetails> managersStillUp = new HashSet<ControllerDetails>(); managersStillUp.addAll(Arrays.asList(managers)); final ConditionLatch conditionLatch = new ConditionLatch() .pollingInterval(POLLING_INTERVAL_MILLISECONDS, TimeUnit.MILLISECONDS) .timeout(timeoutMinutes, TimeUnit.MINUTES) .timeoutErrorMessage(CloudifyErrorMessages.SHUTDOWN_MANAGERS_TIMEOUT.getName()); conditionLatch.waitFor(new ConditionLatch.Predicate() { @Override/*from w w w.j a v a 2 s.c om*/ public boolean isDone() throws CLIException, InterruptedException { final Iterator<ControllerDetails> iterator = managersStillUp.iterator(); while (iterator.hasNext()) { final ControllerDetails manager = iterator.next(); final String host = manager.isBootstrapToPublicIp() ? manager.getPublicIp() : manager.getPrivateIp(); if (ServiceUtils.isPortFree(host, port)) { iterator.remove(); LogUtils.log("Manager [" + host + "] is down."); if (managersStillUp.isEmpty()) { LogUtils.log("All ports are free."); return true; } LogUtils.log(managersStillUp.size() + " managers more to check"); } else { LogUtils.log("Manager [" + host + "] is still up."); } } return false; } }); }