Example usage for java.util ListIterator next

List of usage examples for java.util ListIterator next

Introduction

In this page you can find the example usage for java.util ListIterator next.

Prototype

E next();

Source Link

Document

Returns the next element in the list and advances the cursor position.

Usage

From source file:com.offbynull.voip.kademlia.model.NodeLeastRecentSet.java

public Node get(Id id) {
    InternalValidate.matchesLength(baseId.getBitLength(), id);

    ListIterator<Activity> it = entries.listIterator();
    while (it.hasNext()) {
        Activity entry = it.next();

        Id entryId = entry.getNode().getId();

        if (entryId.equals(id)) {
            return entry.getNode();
        }/*from   ww w . j a  va  2  s  .  c om*/
    }

    return null;
}

From source file:com.liferay.arquillian.maven.internal.tasks.ToolsClasspathTask.java

/**
 * (non-Javadoc)/*from   ww w.ja  va2 s . co  m*/
 * @see
 * org.jboss.shrinkwrap.resolver.impl.maven.task.MavenWorkingSessionTask
 * #execute(org.jboss.shrinkwrap.resolver.api.maven.MavenWorkingSession)
 */
@Override
public URLClassLoader execute(MavenWorkingSession session) {
    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<>();

    if ((appServerLibGlobalDir != null) && appServerLibGlobalDir.exists()) {

        // app server global libraries

        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars

        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars

        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }
    }

    if (_log.isTraceEnabled()) {
        _log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());
    }

    List<URL> classpathUrls = new ArrayList<>();

    try {
        if (!liferayToolArchives.isEmpty()) {
            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }
        }
    } catch (MalformedURLException e) {
        _log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ShowDegreesAction.java

private List buildDegreesList(List executionDegreesList) {
    if (executionDegreesList == null) {
        return null;
    }/*w  w  w  . j a va2s  . c  o m*/

    List degreesList = new ArrayList();

    ListIterator listIterator = executionDegreesList.listIterator();
    while (listIterator.hasNext()) {
        InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) listIterator.next();

        if (!degreesList.contains(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree())) {

            degreesList.add(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree());
        }
    }

    // order list by alphabetic order of the code
    Collections.sort(degreesList, new BeanComparator("nome"));

    return degreesList;
}

From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java

private String getNamedData(String name) {
    ListIterator<NameValuePair> itr = webData.listIterator();
    while (itr.hasNext()) {
        NameValuePair t = itr.next();
        if (t.getName() == name) {
            return t.getValue();
        }/* w w  w . ja va2 s  .  co  m*/
    }
    return new String();
}

From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java

private void setNamedData(String name, String value) {
    ListIterator<NameValuePair> itr = webData.listIterator();
    while (itr.hasNext()) {
        NameValuePair t = itr.next();
        if (t.getName() == name) {
            itr.set(new BasicNameValuePair(name, value));
            return;
        }//from ww w.j  a  v a 2s. c om
    }
    webData.add(new BasicNameValuePair(name, value));
}

From source file:com.offbynull.voip.kademlia.model.NodeLeastRecentSet.java

public ActivityChangeSet remove(Node node) {
    Validate.notNull(node);/*from   ww  w .j  a v a 2 s . co m*/

    Id nodeId = node.getId();

    InternalValidate.matchesLength(baseId.getBitLength(), nodeId);

    ListIterator<Activity> it = entries.listIterator();
    while (it.hasNext()) {
        Activity entry = it.next();

        Id entryId = entry.getNode().getId();

        if (entryId.equals(nodeId)) {
            InternalValidate.matchesLink(entry.getNode(), node);

            // remove
            it.remove();
            return ActivityChangeSet.removed(entry);
        }
    }

    return ActivityChangeSet.NO_CHANGE;
}

From source file:mimir.ControlChart.java

public void newValue(double value) {
    //add value to data
    this.data.addValue(value);
    //System.out.println("Added Value: "+value+" to dataset");
    //iterate through patterns to catch signals
    ListIterator<PatternRule> patternChecker = this.patterns.listIterator(0);
    while (patternChecker.hasNext()) {
        PatternRule p = patternChecker.next();
        //System.out.println("Checking for: " + p.name);
        boolean flag = p.check(value);
        if (flag) {
            this.signals.add(p.name);
            //System.out.println(" -- caught flag -- ");
        }//from   ww w  .ja  va2 s  . c om
    }
    //handle signals in other scope
    return;
}

From source file:biz.c24.io.spring.integration.selectors.ValidatingMessageSelectorTests.java

@Test
public void testInvalid() {
    Employee employee = new Employee();
    employee.setSalutation("Mr");
    // Should fail due to non-capitalised first letter
    employee.setFirstName("andy");
    employee.setLastName("Acheson");
    // No job title set - should also cause a validation failure
    //employee.setJobTitle("Software Developer");

    C24ValidatingMessageSelector selector = new C24ValidatingMessageSelector();
    selector.setFailFast(true);//  ww  w.  j  a v a  2s .c om
    selector.setThrowExceptionOnRejection(false);
    assertThat(selector.accept(MessageBuilder.withPayload(employee).build()), is(false));

    selector.setFailFast(false);
    assertThat(selector.accept(MessageBuilder.withPayload(employee).build()), is(false));

    selector.setFailFast(true);
    selector.setThrowExceptionOnRejection(true);
    try {
        selector.accept(MessageBuilder.withPayload(employee).build());
        fail("Selector failed to throw an exception on invalid CDO");
    } catch (MessageRejectedException ex) {
        // Expected behaviour
        assertThat(ex.getCause(), is(ValidationException.class));
    }

    selector.setFailFast(false);
    try {
        selector.accept(MessageBuilder.withPayload(employee).build());
        fail("Selector failed to throw an exception on invalid CDO");
    } catch (C24AggregatedMessageValidationException ex) {
        // Expected behaviour
        ListIterator<ValidationEvent> failures = ex.getFailEvents();
        int failureCount = 0;
        while (failures.hasNext()) {
            failureCount++;
            failures.next();
        }
        assertThat(failureCount, is(2));

    }
}

From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.FactorRedundantGroupAndDecorVarsRule.java

private boolean factorRedundantRhsVars(List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> veList,
        Mutable<ILogicalOperator> opRef, Map<LogicalVariable, LogicalVariable> varRhsToLhs,
        IOptimizationContext context) throws AlgebricksException {
    varRhsToLhs.clear();//w w w .  j  av a2s  .c o  m
    ListIterator<Pair<LogicalVariable, Mutable<ILogicalExpression>>> iter = veList.listIterator();
    boolean changed = false;
    while (iter.hasNext()) {
        Pair<LogicalVariable, Mutable<ILogicalExpression>> p = iter.next();
        if (p.second.getValue().getExpressionTag() != LogicalExpressionTag.VARIABLE) {
            continue;
        }
        LogicalVariable v = GroupByOperator.getDecorVariable(p);
        LogicalVariable lhs = varRhsToLhs.get(v);
        if (lhs != null) {
            if (p.first != null) {
                AssignOperator assign = new AssignOperator(p.first,
                        new MutableObject<ILogicalExpression>(new VariableReferenceExpression(lhs)));
                ILogicalOperator op = opRef.getValue();
                assign.getInputs().add(new MutableObject<ILogicalOperator>(op));
                opRef.setValue(assign);
                context.computeAndSetTypeEnvironmentForOperator(assign);
            }
            iter.remove();
            changed = true;
        } else {
            varRhsToLhs.put(v, p.first);
        }
    }
    return changed;
}

From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java

public String generateHtml(List nonListedVVs, List availableValidVaues, String questionIdSeq) {
    StringBuffer selectHtml = new StringBuffer(
            "<select class=\"" + selectClassName + "\" name=\"" + selectName + "\"> \n");

    StringBuffer optionHtml = (StringBuffer) pageContext.getAttribute(questionIdSeq + "validValueOptionBuffer");
    ///*from  w  w  w. j a va2  s  . c  o m*/
    //The options are cached since they dont change for the same question
    //
    if (optionHtml != null) {
        return selectHtml.toString() + optionHtml.toString();
    }
    optionHtml = new StringBuffer();

    ListIterator avalilableVVsListIterate = nonListedVVs.listIterator();
    while (avalilableVVsListIterate.hasNext()) {
        FormValidValue fvv = (FormValidValue) avalilableVVsListIterate.next();
        int index = availableValidVaues.indexOf(fvv);
        optionHtml.append("<option value=\"" + index + "\">" + fvv.getLongName() + "</option> \n");
    }
    optionHtml.append("</select>");

    pageContext.setAttribute(questionIdSeq + "validValueOptionBuffer", optionHtml);

    return selectHtml.toString() + optionHtml.toString();
}