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.collective.celos.ci.testing.fixtures.compare.FixTableComparer.java

private Map<String, FixObjectCompareResult> compareRespectOrder(FixTable expected, FixTable actual) {
    Map<String, FixObjectCompareResult> fails = Maps.newLinkedHashMap();
    ListIterator<FixTable.FixRow> expIter = expected.getRows().listIterator();
    ListIterator<FixTable.FixRow> actIter = actual.getRows().listIterator();
    while (expIter.hasNext()) {
        FixTable.FixRow expRow = expIter.next();
        FixTable.FixRow actRow = actIter.next();

        FixObjectCompareResult result = compareFixRows(expected.getColumnNames(), expRow, actRow);
        if (result.getStatus() == FixObjectCompareResult.Status.FAIL) {
            fails.put("Row #" + expIter.previousIndex(), result);
        }//from  w w w  . j a  v  a2  s  .co m
    }
    return fails;
}

From source file:com.edgenius.wiki.render.macro.BaseMacro.java

/**
 * Reset all inside node to blank text node.
 * !!! Here changes ListIterator cursor position!!!
 * @param node//from w  w w. j av  a2 s  . co m
 * @param iter
 */
protected void resetInsideNode(HTMLNode node, ListIterator<HTMLNode> iter) {
    HTMLNode subnode;
    for (; iter.hasNext();) {
        subnode = iter.next();
        if (subnode == node.getPair())
            break;

        if (!subnode.isTextNode()) {
            subnode.reset("", true);
            if (subnode.getPair() != null)
                subnode.getPair().reset("", true);
        } else {
            subnode.reset("", true);
        }
    }
}

From source file:com.braffdev.server.core.container.resourceloader.ResourceLoader.java

/**
 * Removes the given stream from the list of currently open streams.
 *
 * @param in the stream.//  w w  w  .ja v a2  s .  co  m
 */
public void removeStream(ResourceInputStream in) {
    synchronized (this.streams) {
        ListIterator<ResourceInputStream> iter = this.streams.listIterator();
        while (iter.hasNext()) {
            if (in == iter.next()) {
                iter.remove();
                break;
            }
        }
    }
}

From source file:com.carolinarollergirls.scoreboard.jetty.MediaServlet.java

protected void processFileItemList(List<FileItem> fileItems, String media, String type)
        throws FileNotFoundException, IOException {
    File typeDir = getTypeDir(media, type, true);

    ListIterator<FileItem> fileItemIterator = fileItems.listIterator();
    while (fileItemIterator.hasNext()) {
        FileItem item = fileItemIterator.next();
        if (item.isFormField()) {
            fileItemIterator.remove();/* ww w . jav a 2 s  .co m*/
        } else {
            File f = createFile(typeDir, item);
        }
    }
}

From source file:com.braffdev.server.core.container.resourceloader.ResourceLoader.java

/**
 * Frees all resource that may are being used (Closes all open InputStreams and prevents the server from opening new ones);
 *//* w  w  w  . j  a  va 2 s  . c  o  m*/
@Override
public void shutdown() {
    this.enabled = false;

    // close all streams
    synchronized (this.streams) {
        ListIterator<ResourceInputStream> iter = this.streams.listIterator();
        while (iter.hasNext()) {
            InputStream in = iter.next();
            IOUtils.closeQuietly(in);

            iter.remove();
        }
    }
}

From source file:com.att.aro.ui.view.diagnostictab.plot.AlarmPlot.java

private List<ScheduledAlarmInfo> getHasFiredAlarms(Map<String, List<ScheduledAlarmInfo>> pendingAlarms) {
    List<ScheduledAlarmInfo> result = new ArrayList<ScheduledAlarmInfo>();
    for (Map.Entry<String, List<ScheduledAlarmInfo>> entry : pendingAlarms.entrySet()) {
        List<ScheduledAlarmInfo> alarms = entry.getValue();
        @SuppressWarnings("rawtypes")
        ListIterator itrAlarms = alarms.listIterator();
        while (itrAlarms.hasNext()) {
            ScheduledAlarmInfo alarm = (ScheduledAlarmInfo) itrAlarms.next();
            if (alarm.getHasFired() > 0) {
                result.add(alarm);/*from ww  w. ja va 2s  .c o  m*/
            }
        }
    }
    return result;
}

From source file:org.opensha.sha.calc.IM_EventSet.v03.test.IM_EventSetHazardCurveTest.java

public IM_EventSetHazardCurveTest() {

    outputDir = IM_EventSetTest.getTempDir();
    erf = new Frankel96_AdjustableEqkRupForecast();
    erf.getAdjustableParameterList().getParameter(Frankel96_AdjustableEqkRupForecast.BACK_SEIS_NAME)
            .setValue(Frankel96_AdjustableEqkRupForecast.BACK_SEIS_EXCLUDE);
    erf.updateForecast();//  w  w w  . j av a  2 s  .  c o  m
    imr = new CB_2008_AttenRel(null);
    imr.setParamDefaults();
    IM_EventSetOutputWriter.setIMTFromString(imt, imr);
    site = new Site(new Location(34d, -118d));

    ListIterator<ParameterAPI<?>> it = imr.getSiteParamsIterator();
    while (it.hasNext()) {
        ParameterAPI<?> param = it.next();
        site.addParameter(param);
    }
    sites = new ArrayList<Site>();
    sites.add(site);
    sitesData = new ArrayList<ArrayList<SiteDataValue<?>>>();
    sitesData.add(new ArrayList<SiteDataValue<?>>());

    gp = new GraphPanel(this);
}

From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParser.java

public void parse(String[] args) throws CmdLineParseException {
    LinkedList<String> arglist = new LinkedList<String>();
    arglist.addAll(Arrays.asList(args));

    // Quick Help
    if (arglist.contains("--" + OPT_HELP)) {
        usage();/*www  .java  2  s  . co  m*/
        return;
    }

    // Configuration File Option
    int idx = arglist.indexOf("--" + OPT_CONFIG);
    if (idx >= 0) {
        if (idx + 1 > arglist.size()) {
            throw new CmdLineParseException("Expected <File> parameter for option: --" + OPT_CONFIG);
        }
        String value = arglist.get(idx + 1);
        File file = (File) ConvertUtils.convert(value, File.class);

        this.configer.setPersistFile(file);

        arglist.remove(idx + 1);
        arglist.remove(idx);
    }

    // Save Options Option
    boolean saveOptions = false;

    idx = arglist.indexOf("--" + OPT_SAVE);
    if (idx >= 0) {
        saveOptions = true;
        arglist.remove(idx);
    }

    // Restore from persist first.
    try {
        configer.restore();
    } catch (IOException e) {
        throw new CmdLineParseException("Unable to load configuration: " + e.getMessage(), e);
    }

    // Set values from command line now.
    String value;
    ListIterator<String> iter = arglist.listIterator();
    while (iter.hasNext()) {
        String arg = iter.next();
        if (arg.startsWith("--")) {
            // Its an option.
            String optname = arg.substring(2);

            Configurable cfgrbl = configer.getConfigurable(optname);

            if (cfgrbl == null) {
                throw new CmdLineParseException("Invalid Option: " + arg);
            }

            if (!iter.hasNext()) {
                throw new CmdLineParseException(
                        "Expected <" + cfgrbl.getType() + "> parameter for option: " + arg);
            }
            value = iter.next();
            configer.setValue(optname, value);
            continue; // process next arg
        }

        // All others are considered args.
        addToRawArgs(arg);
    }

    // Save options (if specified)
    if (saveOptions) {
        try {
            configer.persist();
        } catch (IOException e) {
            throw new CmdLineParseException("Unable to save configuration: " + e.getMessage(), e);
        }
    }
}

From source file:org.openinfinity.tagcloud.domain.service.TargetServiceImpl.java

private List<Result> nearbySearch(List<Target> allTargets, List<Result> results, List<Tag> nearbyTags) {

    for (Target target : allTargets) {
        List<Tag> foundNearbyTags = new ArrayList<Tag>();
        for (Tag tag : nearbyTags) {
            if (target.getTags().contains(tag))
                foundNearbyTags.add(tag);
        }// ww  w.j  a v a2  s  .  c  o  m
        if (foundNearbyTags.size() == 0)
            continue;

        ListIterator<Result> resultIterator = results.listIterator(0);
        while (resultIterator.hasNext()) {
            Result result = resultIterator.next();
            for (Tag tag : foundNearbyTags) {
                NearbyTarget nearbyTarget = result.getNearbyTargetsMap().get(tag.getText());
                double distance = calcRelativeDistance(result.getTarget(), target);
                if (distance < nearbyTarget.getDistance()) {
                    nearbyTarget.setTarget(target);
                    nearbyTarget.setDistance(distance);
                }
            }
            result.updateNearbyTargetList();
        }
    }

    // update correct absolute distances and remove ones too far away
    ListIterator<Result> resultIterator = results.listIterator(0);
    while (resultIterator.hasNext()) {
        Result result = resultIterator.next();

        for (NearbyTarget nearbyTarget : result.getNearbyTargetsList()) {
            nearbyTarget.setDistance(calcDistance(result.getTarget(), nearbyTarget.getTarget()));
            if (nearbyTarget.getDistance() > NearbyTarget.MAX_DISTANCE) {
                resultIterator.remove();
                break;
            }
        }

    }

    return results;
}

From source file:edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupDaoJena.java

public int removeUnpopulatedGroups(List<VClassGroup> groups) {
    if (groups == null || groups.size() == 0)
        return 0;
    int removedGroupsCount = 0;
    ListIterator<VClassGroup> it = groups.listIterator();
    while (it.hasNext()) {
        VClassGroup group = it.next();
        List<VClass> classes = group.getVitroClassList();
        if (classes == null || classes.size() < 1) {
            removedGroupsCount++;/*ww w  . jav  a2s.c  om*/
            it.remove();
        }
    }
    return removedGroupsCount;
}