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:hu.sztaki.lpds.pgportal.services.dspace.DSpaceUtil.java

/**
 * Returns a string representing METS XML metadata file to be included
 * with DSpace SIP/*from  w w  w. ja va 2  s. c  o m*/
 *
 * @param event
 * @return XML String
 */
private String getMETS(ActionRequest request) {
    // Get Author
    String authorFirst = request.getParameter("firstName");
    String authorLast = request.getParameter("lastName");

    // Get Information
    String title = request.getParameter("title");
    String keywords = request.getParameter("keywords");
    String grid = request.getParameter("grid");
    String vo = request.getParameter("vo");
    String type = "Workflow";//request.getParameter("type");
    //String language =

    // Get Abstract
    String wfAbstract = request.getParameter("abstract").trim();//event.getTextAreaBean("abstractArea").getValue();
    String wfDescription = request.getParameter("description").trim();//event.getTextAreaBean("descriptionArea").getValue();;

    // MODS XML metadata to send with SIP
    // At this time, "type" is sent as a keyword, rather than its DC element
    // dc.type. Also, "language" is not collected/sent. It may be possible to
    // overcome this by editing [dspace]/config/crosswalks/mods-submission.xsl
    String modsxml = "<?xml version='1.0' encoding='UTF-8'?>"
            + "<mods:mods xmlns:mods='http://www.loc.gov/mods/v3'"
            + "xmlns:xlink='http://www.w3.org/1999/xlink'"
            + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
            + "xsi:schemaLocation='http://www.loc.gov/mods/v3"
            + "http://www.loc.gov/standards/mods/v3/mods-3-0.xsd' version='3.0'>" + "<mods:titleInfo>"
            + "<mods:title>" + title + "</mods:title>" + "</mods:titleInfo>" + "<mods:name>" + "<mods:namePart>"
            + authorLast + ", " + authorFirst + "</mods:namePart>" + "<mods:role>"
            + "<mods:roleTerm type='text'>author</mods:roleTerm>" + "</mods:role>" + "</mods:name>";

    String allKeywords = keywords + "," + grid + "," + vo + "," + type;
    ListIterator<String> iterator = parseKeywords(allKeywords);

    while (iterator.hasNext()) {
        modsxml = modsxml.concat(
                "<mods:subject>" + "<mods:topic>" + iterator.next() + "</mods:topic>" + "</mods:subject>");
    }

    if (!"".equals(wfAbstract) && !wfAbstract.equals("[Enter an abstract of your workflow here]")) {
        modsxml = modsxml.concat("<mods:abstract>" + wfAbstract + "</mods:abstract>");

        //if (!wfDescription.isEmpty() &&

    }
    if (!"".equals(wfDescription)
            && !wfDescription.equals("[Enter a detailed description of your workflow here]")) {
        modsxml = modsxml.concat("<mods:note xlink:type='simple'>" + wfDescription + "</mods:note>");

    }
    modsxml = modsxml.concat("</mods:mods>");

    // Tried to make DC metadata to send to DSpace, but doesn't work..
    // Here it is if you want to give it a go
    /*String dcxml = "<?xml version='1.0' encoding='UTF-8'?>" +
    "<dc:dc xmlns:dc='http://www.openarchives.org/OAI/2.0/oai_dc/' xsi:schemaLocation='http://www.openarchives.org/OAI/2.0/oai_dc.xsd'>" +
    "<dc:title>" + title + "</dc:title>" +
    "<dc:creator>" + authorFirst + " " + authorLast + "</dc:creator>" +
    "<dc:subject>Subject1</dc:subject>" +
    "<dc:subject>Subject2</dc:subject>" +
    "<dc:issued>" + getDateTime() + "</dc:issued>" +
    "<dc:language>" + language + "</dc:language>" +
    "<dc:type>" + type + "</dc:type>" +
    "<dc:abstract>Abstract will go here</dc:abstract>" +
    "<dc:description>Description will go here</dc:description>" +
    "</dc:dc>";*/

    // Decide which to use
    //if (METS.equals("MODS")) return modsxml;
    //else if (METS.equals("DC")) return dcxml;
    //else
    return modsxml;
}

From source file:org.wikipedia.nirvana.statistics.Rating.java

public void putFromDb(ArchiveDatabase2 db) throws IllegalStateException {
    totalUserStat.clear();//  w w  w  .ja  v a 2s.com
    ListIterator<ArchiveItem> it = null;
    if (this.year == 0)
        it = db.getIterator();
    else
        it = db.getYearIterator(year);
    ArchiveItem item = null;
    if (it.hasNext()) {
        item = it.next();
        if (this.year != 0 && item.year != this.year)
            throw new IllegalStateException("year processing: " + this.year + ", item's year: " + item.year
                    + ", item: " + item.article);
        if (!(this.filterBySize && item.size < this.minSize))
            this.totalUserStat.put(item.user, 1);
    }
    while (it.hasNext()) {
        item = it.next();
        if (this.year != 0 && item.year != this.year)
            throw new IllegalStateException("year processing: " + this.year + ", item's year: " + item.year
                    + ", item: " + item.article);
        if (this.filterBySize && item.size < this.minSize)
            continue;
        Integer n = totalUserStat.get(item.user);
        if (n == null)
            this.totalUserStat.put(item.user, 1);
        else
            this.totalUserStat.put(item.user, n + 1);
    }
}

From source file:com.xpn.xwiki.plugin.tag.TagPlugin.java

/**
 * Remove a tag from a document. The document is saved (minor edit) after this operation.
 * /*from w  w w  .java  2 s .  co m*/
 * @param tag tag to remove.
 * @param document the document.
 * @param context XWiki context.
 * @return the {@link TagOperationResult result} of the operation
 * @throws XWikiException if document save fails for some reason (Insufficient rights, DB access, etc).
 */
public TagOperationResult removeTagFromDocument(String tag, XWikiDocument document, XWikiContext context)
        throws XWikiException {
    List<String> tags = getTagsFromDocument(document);
    boolean needsUpdate = false;

    ListIterator<String> it = tags.listIterator();
    while (it.hasNext()) {
        if (tag.equalsIgnoreCase(it.next())) {
            needsUpdate = true;
            it.remove();
        }
    }

    if (needsUpdate) {
        setDocumentTags(document, tags, context);
        List<String> commentArgs = new ArrayList<String>();
        commentArgs.add(tag);
        String comment = context.getMessageTool().get("plugin.tag.editcomment.removed", commentArgs);

        // Since we're changing the document we need to set the new author
        document.setAuthorReference(context.getUserReference());

        context.getWiki().saveDocument(document, comment, true, context);

        return TagOperationResult.OK;
    } else {
        // Document doesn't contain this tag.
        return TagOperationResult.NO_EFFECT;
    }
}

From source file:com.ivli.roim.controls.ChartControl.java

void removeMarker(DomainMarker aM) {
    ListIterator<Interpolation> it = iInterpolations.listIterator();

    while (it.hasNext()) {
        Interpolation i = it.next();/*  ww w .j  ava  2  s  .c o m*/
        if (i.iLhs == aM || i.iRhs == aM) {
            it.remove();
            i.close();
        }
    }

    getChart().getXYPlot().removeRangeMarker(aM.getLinkedMarker(), Layer.FOREGROUND);
    getChart().getXYPlot().removeDomainMarker(aM, Layer.FOREGROUND);
}

From source file:com.manydesigns.portofino.dispatcher.Dispatcher.java

protected Dispatch getDispatch(List<PageInstance> initialPath, ListIterator<String> fragmentsIterator) {
    try {/*  w  w  w  .  ja v a 2 s . c o  m*/
        makePageInstancePath(initialPath, fragmentsIterator);
    } catch (PageNotActiveException e) {
        logger.debug("Page not active, not creating dispatch");
        return null;
    } catch (Exception e) {
        logger.error("Couldn't create dispatch", e);
        return null;
    }

    if (fragmentsIterator.hasNext()) {
        logger.debug("Not all fragments matched");
        return null;
    }

    // check path contains root page and some child page at least
    if (initialPath.size() <= 1) {
        return null;
    }

    PageInstance[] pageArray = new PageInstance[initialPath.size()];
    initialPath.toArray(pageArray);

    Dispatch dispatch = new Dispatch(pageArray);
    return dispatch;
    //return checkDispatch(dispatch);
}

From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java

private void placeVoidNodes(List list) {
    ListIterator i = list.listIterator();
    while (i.hasNext()) {
        GraphicNode gnode = (GraphicNode) i.next();
        //if (!gnode.isGroup()){ //Already disabled if sorters or groupers are working
        placeVoidNodes(i, gnode.getNode());
        //}/*  ww  w  .  j  a v  a  2  s.  co  m*/
    }
    placeVoidNodes(i, (Node) refCache.getModel().getRoot());
}

From source file:edu.cornell.mannlib.vitro.webapp.dao.filtering.IndividualFiltering.java

@Override
public List<DataProperty> getDataPropertyList() {
    List<DataProperty> dprops = _innerIndividual.getDataPropertyList();
    LinkedList<DataProperty> outdProps = new LinkedList<DataProperty>();
    if (dprops == null)
        return outdProps;
    Filter.filter(dprops, _filters.getDataPropertyFilter(), outdProps);

    ListIterator<DataProperty> it = outdProps.listIterator();
    while (it.hasNext()) {
        DataProperty dp = it.next();/*w ww.j a va2 s  . co m*/
        List<DataPropertyStatement> filteredStmts = new LinkedList<DataPropertyStatement>();
        Filter.filter(dp.getDataPropertyStatements(), _filters.getDataPropertyStatementFilter(), filteredStmts);
        if (filteredStmts.size() == 0) {
            it.remove();
        } else {
            dp.setDataPropertyStatements(filteredStmts);
        }
    }
    return outdProps;
}

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

private double getMaximumOfData(ArrayList alVolumes, int x) {

    ListIterator litr = alVolumes.listIterator();

    //ArrayList<Number> al = new ArrayList<Number>();
    Number high = 0;/*  w ww .  j a v  a  2  s . c  o m*/

    while (litr.hasNext()) {
        try {
            MicroObjectModel volume = (MicroObjectModel) litr.next();
            Number Corrected = processPosition(x, volume);
            if (Corrected.floatValue() > high.floatValue()) {
                high = Corrected;
            }
        } catch (NullPointerException e) {
        }
    }
    return high.longValue();

}