Example usage for java.util Set iterator

List of usage examples for java.util Set iterator

Introduction

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

Prototype

Iterator<E> iterator();

Source Link

Document

Returns an iterator over the elements in this set.

Usage

From source file:WpRDFFunctionLibrary.java

public static void addBdbLinkSets(Model openPhactsLinkSets, IDMapper mapper, Xref idXref,
        Resource internalWPDataNodeResource) throws IDMapperException {
    Set<Xref> bdbLinkSetsIdXref = mapper.mapID(idXref);
    Iterator<Xref> iter = bdbLinkSetsIdXref.iterator();
    while (iter.hasNext()) {
        Xref linkedId = (Xref) iter.next();
        String linkedIdString = linkedId.getId();
        //System.out.println(linkedId.getURN());
        if (linkedId.getURN().contains("urn")) {
            //System.out.println(linkedId.getURN().split(":").length);
            String linkedIdSource = linkedId.getURN().split(":")[2];
            //System.out.println("http://identifiers.org/"+linkedIdSource+"/"+linkedIdString);
            Resource linkedIdResource = openPhactsLinkSets
                    .createResource("http://identifiers.org/" + linkedIdSource + "/" + linkedIdString);
            internalWPDataNodeResource.addProperty(Skos.related, linkedIdResource);
        }//from  w w w  . ja  v a 2  s  . co  m
    }
}

From source file:webim.WebimConfig.java

public WebimConfig() {
    Properties prop = new Properties();
    try {// www.  ja  va2s .  c o  m
        prop.load(getClass().getResourceAsStream("/webim/Webim.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    Set<Object> keys = prop.keySet();
    for (Iterator<Object> it = keys.iterator(); it.hasNext();) {
        String key = (String) it.next();
        String value = prop.getProperty(key);
        key = key.substring("webim.".length());
        if ("true".equals(value) || "false".equals(value)) {
            data.put(key, Boolean.valueOf(value));
        } else {
            data.put(key, value);
        }
    }
}

From source file:com.hpcloud.mon.MonApiApplication.java

private void removeExceptionMappers(Set<Object> items) {
    for (Iterator<Object> i = items.iterator(); i.hasNext();) {
        Object o = i.next();/*from  w  ww.j a v  a 2s  . c om*/
        if (o instanceof ExceptionMapper)
            i.remove();
    }
}

From source file:com.puppycrawl.tools.checkstyle.internal.XdocsPagesTest.java

private static void validateStyleModules(Set<Node> checks, Set<Node> configs, Set<String> styleChecks,
        String fileName, String ruleName) {
    final Iterator<Node> itrChecks = checks.iterator();
    final Iterator<Node> itrConfigs = configs.iterator();

    while (itrChecks.hasNext()) {
        final Node module = itrChecks.next();
        final String moduleName = module.getTextContent().trim();

        if (!module.getAttributes().getNamedItem("href").getTextContent().startsWith("config_")) {
            continue;
        }/* w w w  .  j a v a 2s . c  o m*/

        Assert.assertTrue(
                fileName + " rule '" + ruleName + "' module '" + moduleName + "' shouldn't end with 'Check'",
                !moduleName.endsWith("Check"));

        styleChecks.remove(moduleName);

        for (String configName : new String[] { "config", "test" }) {
            Node config = null;

            try {
                config = itrConfigs.next();
            } catch (NoSuchElementException ignore) {
                Assert.fail(fileName + " rule '" + ruleName + "' module '" + moduleName
                        + "' is missing the config link: " + configName);
            }

            Assert.assertEquals(fileName + " rule '" + ruleName + "' module '" + moduleName
                    + "' has mismatched config/test links", configName, config.getTextContent().trim());

            final String configUrl = config.getAttributes().getNamedItem("href").getTextContent();

            if ("config".equals(configName)) {
                final String expectedUrl = "https://github.com/search?q="
                        + "path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+"
                        + "repo%3Acheckstyle%2Fcheckstyle+" + moduleName;

                Assert.assertEquals(fileName + " rule '" + ruleName + "' module '" + moduleName
                        + "' should have matching " + configName + " url", expectedUrl, configUrl);
            } else if ("test".equals(configName)) {
                Assert.assertTrue(
                        fileName + " rule '" + ruleName + "' module '" + moduleName + "' should have matching "
                                + configName + " url",
                        configUrl.startsWith("https://github.com/checkstyle/checkstyle/"
                                + "blob/master/src/it/java/com/google/checkstyle/test/"));
                Assert.assertTrue(fileName + " rule '" + ruleName + "' module '" + moduleName
                        + "' should have matching " + configName + " url",
                        configUrl.endsWith("/" + moduleName + "Test.java"));

                Assert.assertTrue(
                        fileName + " rule '" + ruleName + "' module '" + moduleName
                                + "' should have a test that exists",
                        new File(configUrl.substring(53).replace('/', File.separatorChar)).exists());
            }
        }
    }

    Assert.assertFalse(fileName + " rule '" + ruleName + "' has too many configs", itrConfigs.hasNext());
}

From source file:com.interface21.transaction.interceptor.TransactionAttributeSourceEditor.java

public void setAsText(String s) throws IllegalArgumentException {
    MapTransactionAttributeSource source = new MapTransactionAttributeSource();
    if (s == null || "".equals(s)) {
        // Leave value in property editor null
    } else {//from ww  w .ja va 2  s  .co  m
        // Use properties editor to tokenize the hold string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);
        Properties p = (Properties) propertiesEditor.getValue();

        // Now we have properties, process each one individually
        Set keys = p.keySet();
        for (Iterator iter = keys.iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String value = p.getProperty(name);
            parseMethodDescriptor(name, value, source);
        }
    }
    setValue(source);
}

From source file:edu.ucdenver.bios.powersvc.resource.PowerResourceHelper.java

/**
 * Create a fixed/random between participant contrast (C matrix)
 *  from the study design./*from   www .  ja  v a2 s. com*/
 * @param studyDesign study design object
 * @return fixed/random C matrix
 */
public static FixedRandomMatrix betweenParticipantContrastFromStudyDesign(StudyDesign studyDesign) {
    if (studyDesign.getViewTypeEnum() == StudyDesignViewTypeEnum.MATRIX_MODE) {
        // matrix based design
        NamedMatrix cFixed = studyDesign.getNamedMatrix(PowerConstants.MATRIX_BETWEEN_CONTRAST);
        NamedMatrix cRandom = studyDesign.getNamedMatrix(PowerConstants.MATRIX_BETWEEN_CONTRAST_RANDOM);

        return new FixedRandomMatrix((cFixed != null ? cFixed.getData().getData() : null),
                (cRandom != null ? cRandom.getData().getData() : null), true);

    } else {
        // Guided design
        Set<Hypothesis> hypothesisSet = studyDesign.getHypothesis();
        if (hypothesisSet != null) {
            // only consider the primary hypothesis at present (i.e. the first one)
            Hypothesis hypothesis = hypothesisSet.iterator().next();
            if (hypothesis != null) {
                RealMatrix cFixed = null;
                RealMatrix cRandom = null;
                // get the factor of interest
                List<HypothesisBetweenParticipantMapping> betweenMap = hypothesis
                        .getBetweenParticipantFactorMapList();
                if (betweenMap != null && betweenMap.size() > 0) {
                    // build the fixed part of the contrast based on the hypothesis of interest
                    switch (hypothesis.getType()) {
                    case MAIN_EFFECT:
                        // between subject factor of interest
                        cFixed = ContrastHelper.mainEffectBetween(
                                betweenMap.get(0).getBetweenParticipantFactor(),
                                studyDesign.getBetweenParticipantFactorList());
                        break;
                    case INTERACTION:
                        cFixed = ContrastHelper.interactionBetween(betweenMap,
                                studyDesign.getBetweenParticipantFactorList());
                        break;
                    case TREND:
                        HypothesisBetweenParticipantMapping trendFactor = betweenMap.get(0);
                        cFixed = ContrastHelper.trendBetween(trendFactor,
                                studyDesign.getBetweenParticipantFactorList());
                    }
                } else {
                    cFixed = ContrastHelper.grandMeanBetween(studyDesign.getBetweenParticipantFactorList());
                }

                // build the random contrast if the design has a baseline covariate
                if (studyDesign.isGaussianCovariate()) {
                    if (cFixed != null) {
                        cRandom = MatrixUtils.getRealMatrixWithFilledValue(cFixed.getRowDimension(), 1, 0);
                    }
                }
                return new FixedRandomMatrix((cFixed != null ? cFixed.getData() : null),
                        (cRandom != null ? cRandom.getData() : null), true);
            }

            // no hypothesis specified
            return null;
        }
    }

    // unknown view type
    return null;
}

From source file:edu.uci.ics.jung.graph.predicates.ConnectedGraphPredicate.java

/**
 * Returns <code>true</code> if there exists a path from each 
 * vertex to all other vertices (ignoring edge direction).
 * //from   w  w  w .  ja v a 2s. c  o  m
 * <p>Returns <code>true</code> for an empty graph.</p>
 * 
 * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
 */
public boolean evaluateGraph(ArchetypeGraph graph) {
    Graph g = (Graph) graph;
    if (g.numVertices() == 0)
        return true;

    Vertex start = (Vertex) g.getVertices().iterator().next(); // pick any vertex
    Set visited = new HashSet();
    LinkedList stack = new LinkedList();
    stack.add(start);
    // traverse through graph in depth-first order
    while (!stack.isEmpty()) {
        Vertex v = (Vertex) stack.removeFirst();
        visited.add(v);
        Set neighbors = v.getNeighbors();
        for (Iterator n_it = neighbors.iterator(); n_it.hasNext();) {
            Vertex w = (Vertex) n_it.next();
            if (!visited.contains(w))
                stack.addFirst(w);
        }
    }
    return (visited.size() == g.numVertices());
}

From source file:net.sf.ehcache.store.FifoMemoryStore.java

/**
 * Returns the first eligible element that can be taken out of the cache
 * based on the FIFO policy// w  w  w  .  jav  a 2  s  . c o m
 */
Element getFirstElement() {
    if (map.size() == 0) {
        return null;
    }

    Element element = null;
    Serializable key;

    Set keySet = map.keySet();
    Iterator itr = keySet.iterator();
    // The first element is the candidate to remove
    if (itr.hasNext()) {
        key = (Serializable) itr.next();
        element = (Element) map.get(key);
    }

    return element;
}

From source file:edu.ucdenver.bios.powersvc.resource.PowerResourceHelper.java

/**
 * Create the within participant contrast (U matrix)
 *  from the study design.//from www . j  a  v  a  2s . c  om
 * @param studyDesign study design object
 * @return U matrix
 */
public static RealMatrix withinParticipantContrastFromStudyDesign(StudyDesign studyDesign) {
    if (studyDesign.getViewTypeEnum() == StudyDesignViewTypeEnum.MATRIX_MODE) {
        return toRealMatrix(studyDesign.getNamedMatrix(PowerConstants.MATRIX_WITHIN_CONTRAST));
    } else {
        // Guided design
        Set<Hypothesis> hypothesisSet = studyDesign.getHypothesis();
        if (hypothesisSet != null) {
            // only consider the primary hypothesis at present (i.e. the first one)
            Hypothesis hypothesis = hypothesisSet.iterator().next();
            if (hypothesis != null) {
                RealMatrix withinContrast = null;
                // get the factor of interest
                List<HypothesisRepeatedMeasuresMapping> withinMap = hypothesis.getRepeatedMeasuresMapTree();
                if (withinMap != null && withinMap.size() > 0) {
                    // build the fixed part of the contrast based on the hypothesis of interest
                    switch (hypothesis.getType()) {
                    case MAIN_EFFECT:
                        // between subject factor of interest
                        withinContrast = ContrastHelper.mainEffectWithin(
                                withinMap.get(0).getRepeatedMeasuresNode(),
                                studyDesign.getRepeatedMeasuresTree(), studyDesign.getResponseList());
                        break;
                    case INTERACTION:
                        withinContrast = ContrastHelper.interactionWithin(withinMap,
                                studyDesign.getRepeatedMeasuresTree(), studyDesign.getResponseList());
                        break;
                    case TREND:
                        HypothesisRepeatedMeasuresMapping trendFactor = withinMap.get(0);
                        withinContrast = ContrastHelper.trendWithin(trendFactor,
                                studyDesign.getRepeatedMeasuresTree(), studyDesign.getResponseList());
                    }
                } else {
                    withinContrast = ContrastHelper.grandMeanWithin(studyDesign.getRepeatedMeasuresTree(),
                            studyDesign.getResponseList());
                }

                // expand rows if clustering is present
                if (withinContrast != null) {
                    List<ClusterNode> clusterNodeList = studyDesign.getClusteringTree();
                    if (clusterNodeList != null && clusterNodeList.size() > 0) {
                        int totalRows = 1;
                        for (ClusterNode node : clusterNodeList) {
                            totalRows *= node.getGroupSize();
                        }

                        // direct product the U matrix with a matrix of ones to 
                        // generate the proper dimensions for a cluster sample
                        RealMatrix oneMatrix = MatrixUtils.getRealMatrixWithFilledValue(totalRows, 1, 1);
                        withinContrast = MatrixUtils.getKroneckerProduct(oneMatrix, withinContrast);

                    }
                }

                return withinContrast;
            }

            // no hypothesis specified
            return null;
        }
    }

    // unknown view type
    return null;
}

From source file:ContextBinder.java

public String getValues() {

    StringBuffer buf = new StringBuffer("");
    Set set = map.keySet();

    synchronized (map) {

        Iterator i = set.iterator();
        while (i.hasNext())
            buf.append((String) i.next() + "<br>");
    }/*from  w  w w  . j ava2  s  .c  om*/

    return buf.toString();

}