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:gov.nih.nci.ncicb.cadsr.cdebrowser.struts.actions.CompareCDEAction.java

/**
 * Displays CDE Cart.//from   w w w  . j  a  v  a2 s  .co m
 *
 * @param mapping The ActionMapping used to select this instance.
 * @param form The optional ActionForm bean for this request.
 * @param request The HTTP Request we are processing.
 * @param response The HTTP Response we are processing.
 *
 * @return
 *
 * @throws IOException
 * @throws ServletException
 */
public ActionForward compareCDEs(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
    //CDECart cart = new CDECartTransferObject();
    CDECart cart = null;

    DynaActionForm compareForm = (DynaActionForm) form;

    String[] cdeIdseqArr = (String[]) compareForm.get(ProcessConstants.SELECT_DE);
    CDECompareList cdeList = (CDECompareList) this.getSessionObject(request, CDE_COMPARE_LIST);

    if (cdeList == null) {
        cdeList = new CDECompareList();

        setSessionObject(request, CDE_COMPARE_LIST, cdeList, true);
    }

    if (cdeIdseqArr != null) {
        cdeList.add(cdeIdseqArr);
    }

    if (cdeList.getCdeList().size() == 0) {
        saveMessage("cadsr.cdebrowser.cdecompare.list.empty", request);

        return mapping.findForward("search");
    }

    if (cdeList.getCdeList().size() < 2) {
        saveMessage("cadsr.cdebrowser.cdecompare.list.oneelement", request);

        return mapping.findForward("search");
    }

    ListIterator it = cdeList.listIterator();
    List cdeDetailList = new ArrayList();

    try {
        while (it.hasNext()) {
            DataElement de = (DataElement) it.next();

            cdeDetailList.add(getDataElementDetails(de, request.getSession().getId()));
        }

        cdeList.setDetailCDEList(cdeDetailList);
    } catch (Exception e) {
        Exception ex = e;

        saveMessage("cadsr.cdebrowser.cdecompare.compare.failed", request);
        return mapping.findForward(FAILURE);
    }

    return mapping.findForward(SUCCESS);
}

From source file:com.hortonworks.atlas.cli.AtlasCLI.java

/**
 * This method lists all types in the Atlas
 *//*from w w  w. java  2s  .  c  o m*/
public void listTypes() {

    List<String> lt;
    try {
        lt = aClient.listTypes();

        ListIterator<String> lstItr = lt.listIterator();

        System.out.println("Listing all Types in atlas: ");

        while (lstItr.hasNext()) {

            System.out.println(lstItr.next());

        }
    } catch (AtlasServiceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:com.alvermont.terraj.stargen.dole.DoleAccrete.java

/**
 * Creates a solar system. On return a list of
 * planets will be available that can be obtained with getPlanets()
 *
 * @param star The star in the solar system.
 *//*from   w w  w  .  j av a2  s .c  o  m*/
public void createSystem(Primary star) {
    short i;

    // fill in luminosity and ecosphere if not already set
    if (star.getLuminosity() == 0) {
        star.setLuminosity(EnviroUtils.getLuminosity(star.getMass()));
    }

    star.setREcosphere(Math.sqrt(star.getLuminosity()));

    star.setREcosphereInner(star.getREcosphere() * 0.93);
    star.setREcosphereOuter(star.getREcosphere() * 1.1);

    // done
    this.nNucleus = 0;

    /* A little initialization . . . */
    this.A = DoleConstants.AO * Math.sqrt(star.getMass());

    minRadius = DoleConstants.MINRADIUS * Math.pow(star.getMass(), 0.33);
    maxRadius = DoleConstants.MAXRADIUS * Math.pow(star.getMass(), 0.33);

    initBands();

    /* . . . and we're off to play God. */
    while (!list0.isEmpty()) {
        final DolePlanetRecord p = createPlanet(star);

        if (p == null) {
            break;
        }

        evolvePlanet(star, p);

        checkCoalesence(star, p);
    }

    freeBands();

    i = 1;

    final ListIterator<Planet> li = star.getPlanets().listIterator();

    while (li.hasNext()) {
        final Planet pl = (Planet) li.next();

        if (pl.getMass() > 2e-8) {
            pl.setNumber(++i);

            planetStats.computePlanetStats(star, pl);
        } else {
            li.remove();
        }
    }
}

From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java

/**
 * Add directories to playlistUI.//from  ww  w  .  j av  a 2 s.co m
 * @param folderList
 */
public void addDirs(List folderList) {
    if (folderList.size() > 0) {
        ListIterator it = folderList.listIterator();
        while (it.hasNext()) {
            addDir((File) it.next());
        }
    }
}

From source file:at.ofai.music.util.WormFileParseException.java

public EventList(EventList e) {
    this();/*from  w w w . j  a va2 s  .com*/
    ListIterator<Event> it = e.listIterator();
    while (it.hasNext())
        add(it.next());
}

From source file:com.t3.model.initiative.InitiativeList.java

/**
 * Updates occurred to the tokens. /*w  ww.  j a v  a 2s .  c  o m*/
 */
public void update() {

    // No zone, no tokens
    if (getZone() == null) {
        clearModel();
        return;
    } // endif

    // Remove deleted tokens
    startUnitOfWork();
    boolean updateNeeded = false;
    ListIterator<TokenInitiative> i = tokens.listIterator();
    while (i.hasNext()) {
        TokenInitiative ti = i.next();
        if (!ti.tokenExists()) {
            int index = tokens.indexOf(ti);
            if (index <= current)
                setCurrent(current - 1);
            i.remove();
            updateNeeded = true;
            getPCS().fireIndexedPropertyChange(TOKENS_PROP, index, ti, null);
        } // endif
    } // endwhile
    if (updateNeeded) {
        finishUnitOfWork();
    } else if (holdUpdate == 1) {
        holdUpdate -= 1; // Do no updates.
        LOGGER.debug("finishUnitOfWork() - no update");
    } // endif
}

From source file:com.emc.ecs.sync.target.EcsS3Target.java

protected void putIntermediateVersions(ListIterator<EcsS3ObjectVersion> versions, final String key) {
    while (versions.hasNext()) {
        EcsS3ObjectVersion version = versions.next();
        try {//w w w. j  a v  a  2 s  .  c  o  m
            if (!version.isLatest()) {
                // source has more versions; add any non-current versions that are missing from the target
                // (current version will be added below)
                if (version.isDeleteMarker()) {
                    log.debug("[{}#{}]: deleting object in target to replicate delete marker in source.",
                            version.getRelativePath(), version.getVersionId());
                    time(new Function<Void>() {
                        @Override
                        public Void call() {
                            s3.deleteObject(bucketName, key);
                            return null;
                        }
                    }, OPERATION_DELETE_OBJECT);
                } else {
                    log.debug("[{}#{}]: replicating historical version in target.", version.getRelativePath(),
                            version.getVersionId());
                    putObject(version, key);
                }
            }
        } catch (RuntimeException e) {
            throw new RuntimeException(
                    String.format("sync of historical version %s failed", version.getVersionId()), e);
        }
    }
}

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

/**
 * This is facility method to help you handle reset HTMLNode to markup text with given  tidy style. 
 * //w w  w .  j  ava  2s.co  m
 * !! You must ensure both endMarkup and node.getPair() is not null if you want to put endMarkup into node.getPair() node!
 * 
 * !!!!
 * If tidyStyle is TIDY_STYLE_BLOCK, this node will be insert some LINE_START or LINE_END tags.  
 * Iter.next() is unaffected. However, Iter.previous() will return new inserted LINK_END tag. 
 * 
 */
protected void resetMacroMarkup(int tidyStyle, HTMLNode node, ListIterator<HTMLNode> iter, String startMarkup,
        String endMarkup) {
    if (tidyStyle == Macro.TIDY_STYLE_BLOCK) {
        //add HTMLNode.LINE_START and END surrounding markup
        node.reset(HTMLNode.LINE_START_TAG, false);
        iter.add(new HTMLNode(startMarkup, true));
        HTMLNode lastNode = new HTMLNode(HTMLNode.LINE_END_TAG, false);
        iter.add(lastNode);

        if (node.getPair() != null) {
            if (!StringUtils.isBlank(endMarkup)) {
                while (iter.hasNext()) {
                    HTMLNode cursor = iter.next();
                    if (node.getPair() == cursor) {
                        node.getPair().reset(HTMLNode.LINE_START_TAG, false);
                        iter.add(new HTMLNode(endMarkup, true));
                        iter.add(new HTMLNode(HTMLNode.LINE_END_TAG, false));

                        //!!! reset ListIterator back to last node - to ensure iter.next() is unaffected, use lastNode
                        moveIteratorCursorTo(lastNode, iter, false);
                        break;
                    }
                }
            } else {
                node.getPair().reset("", true);
            }
        }
    } else {
        node.reset(startMarkup, true);
        if (node.getPair() != null) {
            if (!StringUtils.isBlank(endMarkup)) {
                node.getPair().reset(endMarkup, true);
            } else {
                node.getPair().reset("", true);
            }

        }
    }
}

From source file:vteaexploration.plottools.panels.XYExplorationPanel.java

@Override
public int getGatedObjects(ImagePlus ip) {
    ArrayList<MicroObject> ImageGatedObjects = new ArrayList<MicroObject>();
    try {//  w  ww  .j av a  2 s. c om

        ArrayList<MicroObject> volumes = (ArrayList) plotvalues.get(1);
        ListIterator<MicroObject> itr = volumes.listIterator();
        while (itr.hasNext()) {
            MicroObject m = itr.next();
            int[] c = new int[2];
            c = m.getBoundsCenter();

            if (ip.getRoi().contains(c[0], c[1])) {
                ImageGatedObjects.add(m);
                m.setGated(true);
            }
        }
    } catch (NullPointerException e) {
        return 0;
    }
    return ImageGatedObjects.size();
}

From source file:bigtweet.BTSim.java

/**
*
* @param na number of agents//www  . j  a v  a  2s  .co  m
* @param selectingMethod: , last, or first in the list of agents. (or null,
* random, to random)
* @param exceptState agents except of that state, can be null
* @return
*/
public List<UserAgent> getNUsers(int na, String selectingMethod, String exceptState) {
    List<UserAgent> r = new ArrayList<UserAgent>();
    UserAgent aux;
    int added = 0;

    switch (selectingMethod) {
    case "last":
        ListIterator<UserAgent> li = getAgents().listIterator(getAgents().size());
        while (li.hasPrevious() && added < na) {

            aux = li.previous();
            if (exceptState == null || !aux.getState().equals(exceptState)) {
                r.add(aux);
                added++;
            }
        }
        if (added < na) {
            throw new RuntimeException("There is no " + na + " agents to be added.");
        }
        break;
    case "first":
        li = getAgents().listIterator();
        while (li.hasNext() && added < na) {
            aux = li.next();
            if (exceptState == null || !aux.getState().equals(exceptState)) {
                r.add(aux);
                added++;
            }
        }
        if (added < na) {
            throw new RuntimeException("There is no " + na + " agents to be added.");
        }
        break;

    default:
        r = getNRandomUsers(na, exceptState);
    }

    return r;

}