Example usage for java.util HashSet iterator

List of usage examples for java.util HashSet iterator

Introduction

In this page you can find the example usage for java.util HashSet iterator.

Prototype

public Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this set.

Usage

From source file:loci.plugins.util.LibraryChecker.java

/**
 * Reports missing libraries in the given hash set to the user.
 * @return true iff no libraries are missing (the hash set is empty).
 */// w w w.  jav a  2  s  .c  o m
public static boolean checkMissing(HashSet<String> missing) {
    int num = missing.size();
    if (num == 0)
        return true;
    StringBuffer sb = new StringBuffer();
    sb.append("The following librar");
    sb.append(num == 1 ? "y was" : "ies were");
    sb.append(" not found:");
    Iterator<String> iter = missing.iterator();
    for (int i = 0; i < num; i++)
        sb.append("\n    " + iter.next());
    String them = num == 1 ? "it" : "them";
    sb.append("\nPlease download ");
    sb.append(them);
    sb.append(" from the LOCI website at");
    sb.append("\n    " + URL_LOCI_SOFTWARE);
    sb.append("\nand place ");
    sb.append(them);
    sb.append(" in the ImageJ plugins folder.");
    IJ.error("LOCI Plugins", sb.toString());
    return false;
}

From source file:ca.sfu.federation.utils.IContextUtils.java

public static Map<String, INamed> getDependancies(Map<String, INamed> ElementMap) {
    // init//www .j  a v a 2s  . c o m
    LinkedHashMap<String, INamed> results = new LinkedHashMap<String, INamed>();
    HashSet dependancies = new HashSet();
    // scenario dependancies come from contextual object references
    Iterator iter = ElementMap.values().iterator();
    while (iter.hasNext()) {
        INamed named = (INamed) iter.next();
        dependancies.add(named.getContext());
    }
    // convert set to map
    iter = dependancies.iterator();
    while (iter.hasNext()) {
        INamed named = (INamed) iter.next();
        results.put(named.getName(), named);
    }
    // return result
    return results;
}

From source file:crossbear.convergence.ConvergenceConnector.java

/**
 * Get the ConvergenceCertObservation from a Set of ConvergenceCertObservations whose certificate has a specific SHA1-hash
 * //ww  w  .j a v  a 2  s  .  com
 * @param certSHA1 The SHA1-hash of the certificate of the ConvergenceCertObservation that should be returned
 * @param hostCcos A Set of ConvergenceCertObservations
 * @return The ConvergenceCertObservation whose certificate has a SHA1-hash that matches "certSHA1". If there is no ConvergenceCertObservation in the set for which this is true then null is returned.
 */
private static ConvergenceCertObservation getCCOFromList(String certSHA1,
        HashSet<ConvergenceCertObservation> hostCcos) {

    // Go through the whole set ...
    Iterator<ConvergenceCertObservation> itr = (Iterator<ConvergenceCertObservation>) hostCcos.iterator();
    while (itr.hasNext()) {

        // .. and check for each ConvergenceCertObservation ...
        ConvergenceCertObservation cco = itr.next();

        // .. if the SHA1-hash of its certificate matches "certSHA1".
        if (cco.getCertHash().equals(certSHA1)) {

            // If yes: return it.
            return cco;
        }
    }

    // If there was no suitable ConvergenceCertObservation in the set: return null
    return null;
}

From source file:Main.java

public static void addTaintInformationToIntent(Intent i, HashSet<String> taintCategories) {
    boolean intentHasNoExtras = i.getExtras() == null ? true : false;

    //A bit of limitation here, because we do only care about the extras
    if (!intentHasNoExtras) {
        Bundle extras = i.getExtras();//w w  w.  ja va 2s.co m

        String taintKeyName = generateKeyNameForTaintInfo(extras.keySet());

        String taintInformation = null;

        if (taintCategories.size() > 1)
            taintInformation = taintCategories.toString().substring(1, taintCategories.toString().length() - 1);
        else
            taintInformation = taintCategories.iterator().next();

        i.putExtra(taintKeyName, taintInformation);
    }
}

From source file:importer.handler.post.stages.Discriminator.java

/**
 * Merge two sets of space-delimited short version names
 * @param oldV the old version names//w w  w .  java  2 s. c om
 * @param newV the new version names to add
 * @return the merged versions
 */
static String mergeVersions(String oldV, String newV) {
    if (oldV.length() == 0)
        return newV;
    else if (newV.length() == 0)
        return oldV;
    else {
        String[] oldVersions = oldV.split(" ");
        String[] newVersions = newV.split(" ");
        HashSet<String> all = new HashSet<String>();
        for (int i = 0; i < oldVersions.length; i++)
            all.add(oldVersions[i]);
        for (int i = 0; i < newVersions.length; i++)
            all.add(newVersions[i]);
        Iterator<String> iter = all.iterator();
        StringBuilder sb = new StringBuilder();
        while (iter.hasNext()) {
            String version = iter.next();
            sb.append(version);
            if (iter.hasNext())
                sb.append(" ");
        }
        return sb.toString();
    }
}

From source file:SerialVersionUID.java

/**
 * Create a Map<String, ClassVersionInfo> for the jboss dist jars.
 * /* w w  w.  j a  va  2s  . c  o m*/
 * @param j2eeHome -
 *          the j2ee ri dist root directory
 * @return Map<String, ClassVersionInfo>
 * @throws IOException
 */
public static Map generateRISerialVersionUIDReport(File j2eeHome) throws IOException {
    // Obtain the jars from the /lib
    HashSet jarFiles = new HashSet();
    File lib = new File(j2eeHome, "lib");
    buildJarSet(lib, jarFiles);
    URL[] cp = new URL[jarFiles.size()];
    jarFiles.toArray(cp);
    ClassLoader parent = Thread.currentThread().getContextClassLoader();
    URLClassLoader completeClasspath = new URLClassLoader(cp, parent);

    TreeMap classVersionMap = new TreeMap();
    Iterator jarIter = jarFiles.iterator();
    while (jarIter.hasNext()) {
        URL jar = (URL) jarIter.next();
        try {
            generateJarSerialVersionUIDs(jar, classVersionMap, completeClasspath, "javax");
        } catch (IOException e) {
            log.info("Failed to process jar: " + jar);
        }
    }

    return classVersionMap;
}

From source file:com.addthis.hydra.job.spawn.JobAlertUtil.java

/**
 * Count the total number of hits along a certain path in a tree object
 * @param jobId The job to query//from  w w w . j  a  v a  2  s  .  c  o m
 * @param checkPath The path to check, e.g.
 * @return The number of hits along the specified path
 */
public static long getQueryCount(String jobId, String checkPath) {

    HashSet<String> result = JSONFetcher.staticLoadSet(getQueryURL(jobId, checkPath, defaultOps, defaultOps),
            alertQueryTimeout, alertQueryRetries, null);
    if (result == null || result.isEmpty()) {
        log.warn("Found no data for job={} checkPath={}; returning zero", jobId, checkPath);
        return 0;
    } else if (result.size() > 1) {
        log.warn("Found multiple results for job={} checkPath={}; using first row", jobId, checkPath);
    }
    String raw = result.iterator().next();
    return Long.parseLong(QUERY_TRIM_PATTERN.matcher(raw).replaceAll("")); // Trim [] characters and parse as long

}

From source file:Main.java

public static void addTaintInformationToIntent(Intent i, HashSet<String> taintCategories) {
    boolean intentHasNoExtras = i.getExtras() == null ? true : false;

    Log.i("PEP", "in addTaintInformationToIntent(Intent i, HashSet<String> taintCategories)");

    //A bit of limitation here, because we do only care about the extras
    if (!intentHasNoExtras) {
        Bundle extras = i.getExtras();/*from   w  w  w. j  av a  2 s  . c  o  m*/

        String taintKeyName = generateKeyNameForTaintInfo(extras.keySet());

        String taintInformation = null;

        if (taintCategories.size() > 1)
            taintInformation = taintCategories.toString().substring(1, taintCategories.toString().length() - 1);
        else
            taintInformation = taintCategories.iterator().next();

        i.putExtra(taintKeyName, taintInformation);
    }
}

From source file:util.RegexStrUtil.java

/**
  * This method generates a string of words based on the HashSet
  * @param expression The tag array for strip exclusion
  * @return String returns the words//from   w  w  w  .  j a  v  a2s . c o  m
  */
public static String getKeywordsAsString(HashSet myKeywords) {
    if (myKeywords == null) {
        return null;
    }
    StringBuffer sb = new StringBuffer();
    if (sb != null) {
        Iterator iterator = myKeywords.iterator();
        while (iterator.hasNext()) {
            Mykeywords keyword = (Mykeywords) iterator.next();
            if (keyword != null) {
                sb.append(keyword.getValue(DbConstants.KEYWORD));
                sb.append(" ");
            }
        }
        return sb.toString();
    }
    return null;
}

From source file:util.RegexStrUtil.java

/**
  * This method generates a string of words based on the HashSet
  * @param expression The tag array for strip exclusion
  * @return String returns the words/*from  w w  w. ja  v  a  2 s .  c  o m*/
  */
public static String getUsertagsAsString(HashSet myKeywords) {
    if (myKeywords == null) {
        return null;
    }
    StringBuffer sb = new StringBuffer();
    if (sb != null) {
        Iterator iterator = myKeywords.iterator();
        while (iterator.hasNext()) {
            Blog blog = (Blog) iterator.next();
            if (blog != null) {
                sb.append(blog.getValue(DbConstants.USER_TAGS));
                sb.append(" ");
            }
        }
        return sb.toString();
    }
    return null;
}