List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:com.intuit.tank.http.BaseRequestHandler.java
/** * Set all the header keys//w w w. j av a 2s . c o m * * @param connection */ @SuppressWarnings("rawtypes") public static void setHeaders(HttpMethod method, HashMap<String, String> headerInformation) { try { Set set = headerInformation.entrySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry mapEntry = (Map.Entry) iter.next(); method.setRequestHeader((String) mapEntry.getKey(), (String) mapEntry.getValue()); } } catch (Exception ex) { logger.warn(LogUtil.getLogMessage("Unable to set header: " + ex.getMessage(), LogEventType.System)); } }
From source file:it.cnr.icar.eric.common.security.KeyToolStripped.java
public static void dumpProviderInfo(String msg) { Provider[] providers = Security.getProviders(); System.err.println(msg);/*from w w w. j a v a2 s .com*/ for (int i = 0; i < providers.length; i++) { Provider provider = providers[i]; System.err.println("Provider name: " + provider.getName()); //System.err.println("Provider class: " + provider.getClass().getName()); //System.err.println("Provider information: " + provider.getInfo()); //System.err.println("Provider version: " + provider.getVersion()); Set<Entry<Object, Object>> entries = provider.entrySet(); @SuppressWarnings("unused") Iterator<Entry<Object, Object>> iterator = entries.iterator(); /* while (iterator.hasNext()) { System.err.println(" Property entry: " + iterator.next()); } */ } }
From source file:edu.uci.ics.jung.utils.PredicateUtils.java
/** * <p>Returns a <code>Set</code> consisting of all vertices <code>v</code> * in graph <code>g</code> that satisfy predicate <code>p</code>, * that is, those for which <code>p.evaluate(v)</code> returns true.</p> * //from w w w . j a v a 2 s .c o m * <p>If <code>g</code> has a <code>SubsetManager</code> that defines * a cached subset based on <code>p</code>, that subset is returned. */ public static Set getVertices(ArchetypeGraph g, Predicate p) { SubsetManager sm = (SubsetManager) g.getUserDatum(ArchetypeGraph.SUBSET_MANAGER); if (sm != null) { Set s = sm.getVertices(p); if (s != null) return s; } Set s = new HashSet(); Set vertices = g.getVertices(); for (Iterator v_it = vertices.iterator(); v_it.hasNext();) { ArchetypeVertex v = (ArchetypeVertex) v_it.next(); if (p.evaluate(v)) s.add(v); } return Collections.unmodifiableSet(s); }
From source file:com.bruce.intellijplugin.generatesetter.utils.PsiToolUtils.java
public static void addImportToFile(PsiDocumentManager psiDocumentManager, PsiJavaFile containingFile, Document document, Set<String> newImportList) { if (newImportList.size() > 0) { Iterator<String> iterator = newImportList.iterator(); while (iterator.hasNext()) { String u = iterator.next(); if (u.startsWith("java.lang")) { iterator.remove();/*from w ww . j a va 2 s.c om*/ } } } if (newImportList.size() > 0) { PsiJavaFile javaFile = containingFile; PsiImportStatement[] importStatements = javaFile.getImportList().getImportStatements(); Set<String> containedSet = new HashSet<>(); for (PsiImportStatement s : importStatements) { containedSet.add(s.getQualifiedName()); } StringBuilder newImportText = new StringBuilder(); for (String newImport : newImportList) { if (!containedSet.contains(newImport)) { newImportText.append("\nimport " + newImport + ";"); } } PsiPackageStatement packageStatement = javaFile.getPackageStatement(); int start = 0; if (packageStatement != null) { start = packageStatement.getTextLength() + packageStatement.getTextOffset(); } String insertText = newImportText.toString(); if (StringUtils.isNotBlank(insertText)) { document.insertString(start, insertText); PsiDocumentUtils.commitAndSaveDocument(psiDocumentManager, document); } } }
From source file:com.morty.podcast.writer.PodCastUtils.java
public static void printProperties(Map props) { if (m_logger.isDebugEnabled()) { m_logger.debug("All props returned as::"); Set keys = props.keySet(); Iterator it = keys.iterator(); while (it.hasNext()) { String key = (String) it.next(); m_logger.debug("Key [" + key + "] has value [" + props.get(key).toString() + "]"); }/* w w w .j a va 2 s . c o m*/ m_logger.debug("All props Finished"); } }
From source file:Main.java
/** * Returns a {@link Collection} containing the union * of the given {@link Collection}s.//from w w w . j ava 2s . c om * <p/> * The cardinality of each element in the returned {@link Collection} * will be equal to the maximum of the cardinality of that element * in the two given {@link Collection}s. * * @param a the first collection, must not be null * @param b the second collection, must not be null * @return the union of the two collections15 * @see Collection#addAll */ public static <E> Collection<E> union(final Collection<? extends E> a, final Collection<? extends E> b) { ArrayList<E> list = new ArrayList<E>(); Map mapa = getCardinalityMap(a); Map mapb = getCardinalityMap(b); Set<E> elts = new HashSet<E>(a); elts.addAll(b); Iterator<E> it = elts.iterator(); while (it.hasNext()) { E obj = it.next(); for (int i = 0, m = Math.max(getFreq(obj, mapa), getFreq(obj, mapb)); i < m; i++) { list.add(obj); } } return list; }
From source file:Main.java
/** * Returns a {@link Collection} containing the intersection * of the given {@link Collection}s.//from ww w .jav a 2 s. c o m * <p/> * The cardinality of each element in the returned {@link Collection} * will be equal to the minimum of the cardinality of that element * in the two given {@link Collection}s. * * @param a the first collection, must not be null * @param b the second collection, must not be null * @return the intersection of the two collections15 * @see Collection#retainAll * @see #containsAny */ public static <E> Collection<E> intersection(final Collection<? extends E> a, final Collection<? extends E> b) { ArrayList<E> list = new ArrayList<E>(); Map mapa = getCardinalityMap(a); Map mapb = getCardinalityMap(b); Set<E> elts = new HashSet<E>(a); elts.addAll(b); Iterator<E> it = elts.iterator(); while (it.hasNext()) { E obj = it.next(); for (int i = 0, m = Math.min(getFreq(obj, mapa), getFreq(obj, mapb)); i < m; i++) { list.add(obj); } } return list; }
From source file:net.cit.tetrad.utility.QueryUtils.java
public static void getUpdate(Update update, Map<String, Object> values) { Set<String> keys = values.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String key = it.next().toString(); Object value = values.get(key); update.set(key, value);//from w w w. jav a 2 s . c o m } }
From source file:com.evolveum.midpoint.prism.xml.XsdTypeMapper.java
public static QName determineQNameWithNs(QName xsdType) { if (StringUtils.isNotBlank(xsdType.getNamespaceURI())) { return xsdType; }/*from w ww .j av a 2s. c o m*/ Set<QName> keys = xsdToJavaTypeMap.keySet(); for (Iterator<QName> iterator = keys.iterator(); iterator.hasNext();) { QName key = iterator.next(); if (QNameUtil.match(key, xsdType)) { return key; } } return null; }
From source file:Main.java
/** * Returns a {@link Collection} containing the exclusive disjunction * (symmetric difference) of the given {@link Collection}s. * <p/>/* w w w .j ava 2 s . c o m*/ * The cardinality of each element <i>e</i> in the returned {@link Collection} * will be equal to * <tt>max(cardinality(<i>e</i>,<i>a</i>),cardinality(<i>e</i>,<i>b</i>)) - min(cardinality(<i>e</i>,<i>a</i>),cardinality(<i>e</i>,<i>b</i>))</tt>. * <p/> * This is equivalent to * <tt>{@link #subtract subtract}({@link #union union(a,b)},{@link #intersection intersection(a,b)})</tt> * or * <tt>{@link #union union}({@link #subtract subtract(a,b)},{@link #subtract subtract(b,a)})</tt>. * * @param a the first collection, must not be null * @param b the second collection, must not be null * @return the symmetric difference of the two collections15 */ public static <E> Collection<E> disjunction(final Collection<E> a, final Collection<E> b) { ArrayList<E> list = new ArrayList<E>(); Map mapa = getCardinalityMap(a); Map mapb = getCardinalityMap(b); Set<E> elts = new HashSet<E>(a); elts.addAll(b); Iterator<E> it = elts.iterator(); while (it.hasNext()) { E obj = it.next(); for (int i = 0, m = ((Math.max(getFreq(obj, mapa), getFreq(obj, mapb))) - (Math.min(getFreq(obj, mapa), getFreq(obj, mapb)))); i < m; i++) { list.add(obj); } } return list; }