List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:net.sourceforge.fenixedu.domain.space.SpaceUtils.java
public static Occupation getFirstOccurrenceOfResourceAllocationByClass(final Space space, final WrittenEvaluation evaluation) { for (final Occupation resourceAllocation : space.getOccupationSet()) { if (resourceAllocation instanceof WrittenEvaluationSpaceOccupation) { final WrittenEvaluationSpaceOccupation evaluationSpaceOccupation = (WrittenEvaluationSpaceOccupation) resourceAllocation; final Set<WrittenEvaluation> evaluations = evaluationSpaceOccupation.getWrittenEvaluationsSet(); if (!evaluations.isEmpty() && evaluations.iterator().next() == evaluation) { return resourceAllocation; }// w w w . j a v a 2s . c om } } return null; }
From source file:com.microsoft.tfs.core.util.CodePageMapping.java
/** * <p>/*from w w w.ja va 2 s. c om*/ * Translates the specified {@link Charset} into a code page. * </p> * * <p> * If the {@link Charset} does not map to a code page, the * <code>mustExist</code> parameter specifies the policy. If * <code>mustExist</code> is <code>true</code>, an * {@link UnknownEncodingException} is thrown. Otherwise, <code>0</code> is * returned. The value 0 is not a valid code page value for TFS. * </p> * * @param charset * a {@link Charset} to translate (must not be <code>null</code>) * @param mustExist * if <code>true</code>, the {@link Charset} must map to a code page * @return a code page for the {@link Charset}, which may be <code>0</code> * if <code>mustExist</code> is <code>false</code> * @throws UnknownEncodingException */ public static int getCodePage(final Charset charset, final boolean mustExist) { Check.notNull(charset, "charset"); //$NON-NLS-1$ Integer codePage = tryLookupSystemPropertyCodePage(charset.name()); if (codePage != null) { return codePage.intValue(); } final Set<String> aliases = charset.aliases(); for (final Iterator<String> it = aliases.iterator(); it.hasNext();) { final String alias = it.next(); codePage = tryLookupSystemPropertyCodePage(alias); if (codePage != null) { return codePage.intValue(); } } codePage = CodePageData.getCodePage(charset.name()); if (codePage != null) { return codePage.intValue(); } if (mustExist) { throw new UnknownEncodingException(charset); } return 0; }
From source file:com.intuit.tank.script.util.ScriptFilterUtil.java
private static void doRemoveAction(List<ScriptStep> steps, SortedMap<Integer, ScriptStep> stepsToAdd, Set<ScriptStep> stepsToDelete, ScriptFilterAction scriptFilterAction, ScriptStep step) { if (scriptFilterAction.getScope().equalsIgnoreCase(RemoveActionScope.request.getValue())) { stepsToDelete.add(step);/*from w w w . java2s . com*/ } else if (scriptFilterAction.getScope().equalsIgnoreCase(RemoveActionScope.requestCookie.getValue())) { Set<RequestData> requestCookies = step.getRequestCookies(); for (Iterator<RequestData> iterator = requestCookies.iterator(); iterator.hasNext();) { RequestData requestData = iterator.next(); if (requestData.getKey().equalsIgnoreCase(scriptFilterAction.getKey())) { iterator.remove(); } } } else if (scriptFilterAction.getScope().equalsIgnoreCase(RemoveActionScope.requestHeader.getValue())) { Set<RequestData> requestHeaders = step.getRequestheaders(); for (Iterator<RequestData> iterator = requestHeaders.iterator(); iterator.hasNext();) { RequestData requestData = iterator.next(); if (requestData.getKey().equalsIgnoreCase(scriptFilterAction.getKey())) { iterator.remove(); } } } else if (scriptFilterAction.getScope().equalsIgnoreCase(RemoveActionScope.queryString.getValue())) { Set<RequestData> queryStrings = step.getQueryStrings(); for (Iterator<RequestData> iterator = queryStrings.iterator(); iterator.hasNext();) { RequestData requestData = iterator.next(); if (requestData.getKey().equalsIgnoreCase(scriptFilterAction.getKey())) { iterator.remove(); } } } else if (scriptFilterAction.getScope().equalsIgnoreCase(RemoveActionScope.postData.getValue())) { Set<RequestData> postData = step.getPostDatas(); for (Iterator<RequestData> iterator = postData.iterator(); iterator.hasNext();) { RequestData requestData = iterator.next(); if (requestData.getKey().equalsIgnoreCase(scriptFilterAction.getKey())) { iterator.remove(); } } } else { logger.warn("Remove Action not available for scope " + scriptFilterAction.getScope()); } }
From source file:org.jdbcluster.JDBClusterUtil.java
/** * returns the corresponding cluster id for a dao class * /*from ww w. j av a 2 s. c o m*/ * @param clazz * the dao class * @return the cluster id. Can be {@code null} */ static synchronized public String getClusterId(Class<? extends Dao> clazz) { if (dao2clusterId == null) { fillDao2ClusterId(); } Set<String> clusterIds = dao2clusterId.get(clazz); if (clusterIds == null || clusterIds.isEmpty()) { return null; } else if (clusterIds.size() == 1) { return clusterIds.iterator().next(); } else { throw new ConfigurationException( "several clusters defined using this dao [" + clazz.getName() + "]. Not supported yet"); } }
From source file:com.symbian.driver.plugins.ftptelnet.TelnetProcess.java
/** * removeAllInstances: disconnect all instances and deletes them. * //from w w w .ja v a2s . com * @return boolean success/fail (if any fails to disconnect) */ public static boolean removeAllInstances() { boolean lResult = true; Set<String> lkeySet = iTelnetInstances.keySet(); for (Iterator iter = lkeySet.iterator(); iter.hasNext();) { TelnetProcess lInstance = (TelnetProcess) iTelnetInstances.get(iter.next()); lInstance.disconnectTelnet(); iTelnetInstances.remove(iter); } return lResult; }
From source file:edu.ksu.cis.indus.staticanalyses.concurrency.escape.MethodContext.java
/** * Fixes up the field maps of the alias sets in the given map. When alias sets are cloned, the field maps are cloned. * Hence, they are shallow copied. This method clones the relation between the alias sets among their clones. * /*from w ww . ja v a 2 s. c o m*/ * @param src2clone maps an representative alias set to it's clone. This is also an out parameter that will contain new * mappings. * @throws CloneNotSupportedException when <code>clone()</code> fails. */ private static void fixUpFieldMapsOfClone(final Map<AliasSet, AliasSet> src2clone) throws CloneNotSupportedException { final IWorkBag<AliasSet> _wb = new HistoryAwareLIFOWorkBag<AliasSet>(new HashSet<AliasSet>()); _wb.addAllWork(src2clone.keySet()); while (_wb.hasWork()) { final AliasSet _src = _wb.getWork(); final AliasSet _clone = src2clone.get(_src); final Map<String, AliasSet> _srcASFieldMap = _src.getFieldMap(); final Set<String> _srcASFields = _srcASFieldMap.keySet(); final Iterator<String> _i = _srcASFields.iterator(); final int _iEnd = _srcASFields.size(); for (int _iIndex = 0; _iIndex < _iEnd; _iIndex++) { final String _field = _i.next(); /* * We use the representative alias set as it is possible that a field may have 2 alias sets in different * contexts but the same representative alias set in both contexts. We don't do the same for clones as they * are the representatives until they are unified, which happens in the following block. */ final AliasSet _srcFieldAS = _src.getASForField(_field).find(); final AliasSet _cloneFieldAS; _cloneFieldAS = getCloneOf(src2clone, _srcFieldAS); // if the clone is different from the src only then we need to further process src. if (_cloneFieldAS != _srcFieldAS) { _wb.addWork(_srcFieldAS); } _clone.putASForField(_field, _cloneFieldAS); } } // Unify the clones to reflect the relation between their originators. for (final Iterator<AliasSet> _i = src2clone.keySet().iterator(); _i.hasNext();) { final AliasSet _k1 = _i.next(); for (final Iterator<AliasSet> _j = src2clone.keySet().iterator(); _j.hasNext();) { final AliasSet _k2 = _j.next(); if (_k1 != _k2 && _k1.find() == _k2.find()) { final AliasSet _v1 = src2clone.get(_k1); final AliasSet _v2 = src2clone.get(_k2); _v1.unifyAliasSetHelper(_v2, false); } } } return; }
From source file:com.microsoft.tfs.core.util.CodePageMapping.java
/** * <p>//w w w .j a va2s .co m * Translates the specified encoding into a code page. * </p> * * <p> * If the encoding does not map to a code page, the <code>mustExist</code> * parameter specifies the policy. If <code>mustExist</code> is * <code>true</code>, an {@link UnknownEncodingException} is thrown. * Otherwise, <code>0</code> is returned. The value 0 is not a valid code * page value for TFS. * </p> * * @param encoding * an encoding to translate (must not be <code>null</code>) * @param mustExist * if <code>true</code>, the encoding must map to a code page * @return a code page for the encoding, which may be <code>0</code> if * <code>mustExist</code> is <code>false</code> * @throws UnknownEncodingException */ public static int getCodePage(final String encoding, final boolean mustExist) { Check.notNull(encoding, "encoding"); //$NON-NLS-1$ Integer codePage = tryLookupSystemPropertyCodePage(encoding); if (codePage != null) { return codePage.intValue(); } final Charset charset = tryCharsetForName(encoding); if (charset != null) { final String name = charset.name(); if (!encoding.equalsIgnoreCase(name)) { codePage = tryLookupSystemPropertyCodePage(name); if (codePage != null) { return codePage.intValue(); } } final Set<String> aliases = charset.aliases(); for (final Iterator<String> it = aliases.iterator(); it.hasNext();) { final String alias = it.next(); if (encoding.equalsIgnoreCase(alias)) { continue; } codePage = tryLookupSystemPropertyCodePage(alias); if (codePage != null) { return codePage.intValue(); } } } codePage = CodePageData.getCodePage(encoding); if (codePage != null) { return codePage.intValue(); } if (charset != null) { final String name = charset.name(); if (!encoding.equalsIgnoreCase(name)) { codePage = CodePageData.getCodePage(charset.name()); if (codePage != null) { return codePage.intValue(); } } } if (mustExist) { if (charset != null) { throw new UnknownEncodingException(charset); } throw new UnknownEncodingException(encoding); } return 0; }
From source file:eionet.cr.web.util.JstlFunctions.java
/** * * @param subjectDTO/* w w w .j a va 2 s . co m*/ * @param predicates * @param object * @return */ public static boolean subjectHasPredicateObject(SubjectDTO subjectDTO, Set predicates, String object) { boolean result = false; if (predicates == null) { return result; } for (Iterator i = predicates.iterator(); i.hasNext();) { if (subjectDTO.hasPredicateObject(i.next().toString(), object)) { result = true; break; } } return result; }
From source file:org.tec.webapp.jdbc.entity.support.PreparedStatementBuilder.java
/** * Build prepared statement for Select//from w ww . ja v a2 s . c om * * @param tablename the table to select from * @param columns the set of column names * @param whereParams the map of where params * @param whereClause the string where clause * @return PreparedStatementBuilder to select */ public static PreparedStatementBuilder getSelectBuilder(String tablename, Set<String> columns, ParameterMap whereParams, String whereClause) { // Nothing to update if (0 == columns.size()) { throw new RuntimeException("No columns provided to select. " + tablename); } // Build the actual prepared statement StringBuilder buf = new StringBuilder(); buf.append("SELECT "); for (Iterator<String> itCol = columns.iterator(); itCol.hasNext();) { buf.append(itCol.next()); if (itCol.hasNext()) { buf.append(','); } } buf.append(" FROM "); buf.append(tablename); if (whereClause != null && whereClause.length() > 0) { buf.append(" WHERE ").append(whereClause); } return new PreparedStatementBuilder(buf.toString(), null, whereParams, 0); }
From source file:com.all4tec.sa.maven.proguard.ProGuardMojo.java
private static Artifact getDependancy(Inclusion inc, MavenProject mavenProject) throws MojoExecutionException { Set dependancy = mavenProject.getArtifacts(); for (Iterator i = dependancy.iterator(); i.hasNext();) { Artifact artifact = (Artifact) i.next(); if (inc.match(artifact)) { return artifact; }//from w w w. j a v a 2 s . co m } throw new MojoExecutionException("artifactId Not found " + inc.artifactId); }