Example usage for java.util ListIterator hasNext

List of usage examples for java.util ListIterator hasNext

Introduction

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

Prototype

boolean hasNext();

Source Link

Document

Returns true if this list iterator has more elements when traversing the list in the forward direction.

Usage

From source file:com.thomaztwofast.uhc.GameManager.java

private boolean isRecipeEx(ItemStack a) {
    ListIterator<Recipe> b = gA.getServer().getRecipesFor(a).listIterator();
    while (b.hasNext()) {
        if (b.next().getResult().equals(a)) {
            return true;
        }//from  w  w  w  .  j  av  a 2s  .  c o m
    }
    return false;
}

From source file:gov.nih.nci.ncicb.cadsr.cdebrowser.struts.actions.CompareCDEAction.java

/**
 * Displays CDE Cart./*from  w  w w .j  a  va2 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
 *//* w  ww.  j a v  a2 s .  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.
 *///  w w  w.  j  a  v  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  www  . j av  a  2  s.c om*/
 * @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:com.emc.ecs.sync.target.EcsS3Target.java

protected void putIntermediateVersions(ListIterator<EcsS3ObjectVersion> versions, final String key) {
    while (versions.hasNext()) {
        EcsS3ObjectVersion version = versions.next();
        try {//from   w  w  w .  ja  v  a2s  .c  om
            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 .ja v  a2 s .  c  o 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:chat.viska.commons.pipelines.Pipeline.java

private void processObject(final Object obj, final boolean isReading) {
    final ListIterator<Map.Entry<String, Pipe>> iterator = isReading ? pipes.listIterator()
            : pipes.listIterator(pipes.size());
    final List<Object> cache = new ArrayList<>();
    cache.add(obj);//from   ww  w .j  a  v  a 2 s. c  o  m
    while (isReading ? iterator.hasNext() : iterator.hasPrevious()) {
        final Pipe pipe = isReading ? iterator.next().getValue() : iterator.previous().getValue();
        final List<Object> toForward = new ArrayList<>();
        for (Object it : cache) {
            final List<Object> out = new ArrayList<>();
            try {
                if (isReading) {
                    pipe.onReading(this, it, out);
                } else {
                    pipe.onWriting(this, it, out);
                }
            } catch (Exception cause) {
                processException(iterator, cause, isReading);
                return;
            }
            toForward.addAll(out);
        }
        if (toForward.size() == 0) {
            return;
        } else {
            cache.clear();
            cache.addAll(toForward);
        }
    }
    for (Object it : cache) {
        try {
            if (isReading) {
                inboundStream.onNext((I) it);
            } else {
                outboundStream.onNext((O) it);
            }
        } catch (ClassCastException ex) {
            continue;
        }
    }
}

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

/**
 * Updates occurred to the tokens. /*from ww w. j a  va 2  s.  c  om*/
 */
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
}