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.smi.travel.monitor.MonitorGalileo.java

private void buildMap() {
    listGalileo = mGalileoService.getGalileoList();
    ListIterator<MGalileo> iterator = listGalileo.listIterator();
    galileoMap = new HashMap();
    while (iterator.hasNext()) {
        MGalileo gali = iterator.next();
        galileoMap.put(gali.getName(), gali);
    }/*from  w w  w .  ja v a  2  s  .c  o m*/
}

From source file:chat.viska.commons.pipelines.Pipeline.java

@Nullable
private ListIterator<Map.Entry<String, Pipe>> getIteratorOf(final String name) {
    if (StringUtils.isBlank(name)) {
        return null;
    }// w ww  . j a  v a 2  s.c  o  m
    final ListIterator<Map.Entry<String, Pipe>> iterator = pipes.listIterator();
    while (iterator.hasNext()) {
        Map.Entry entry = iterator.next();
        if (entry.getKey().equals(name)) {
            iterator.previous();
            return iterator;
        }
    }
    return null;
}

From source file:chat.viska.commons.pipelines.Pipeline.java

@Nullable
private ListIterator<Map.Entry<String, Pipe>> getIteratorOf(@Nullable final Pipe pipe) {
    if (pipe == null) {
        return null;
    }/*from  w w  w  .j a va  2s  .co  m*/
    final ListIterator<Map.Entry<String, Pipe>> iterator = pipes.listIterator();
    while (iterator.hasNext()) {
        Map.Entry entry = iterator.next();
        if (entry.getValue().equals(pipe)) {
            iterator.previous();
            return iterator;
        }
    }
    return null;
}

From source file:com.amalto.core.history.accessor.record.DataRecordAccessor.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//  w w  w.j  a  v  a  2s  . c o m
public String get() {
    initPath();
    DataRecord current = dataRecord;
    ListIterator<PathElement> listIterator = pathElements.listIterator();
    PathElement pathElement = null;
    while (listIterator.hasNext()) {
        pathElement = listIterator.next();
        if (!listIterator.hasNext()) {
            break;
        }
        if (!pathElement.field.isMany()) {
            if (pathElement.field instanceof ContainedTypeFieldMetadata
                    || pathElement.field instanceof ReferenceFieldMetadata) {
                current = (DataRecord) current.get(pathElement.field);
            }
        } else {
            List<Object> list = (List) current.get(pathElement.field);
            if (list == null) {
                list = new ArrayList<Object>();
                current.set(pathElement.field, list);
            }
            while (pathElement.index > list.size() - 1) { // Expand list size
                list.add(null);
            }
            if (pathElement.field instanceof ContainedTypeFieldMetadata) {
                current = (DataRecord) ((List) current.get(pathElement.field)).get(pathElement.index);
            }
        }
    }
    if (pathElement != null) {
        return pathElement.getter.get(current, pathElement);
    }
    throw new IllegalArgumentException("Path '" + path + "' does not exist in document."); //$NON-NLS-1$ //$NON-NLS-2$
}

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

@Override
protected void replaceHTML(HTMLNode node, ListIterator<HTMLNode> iter, RenderContext context) {
    if (node.getPair() == null) {
        log.warn("Unexpect case: No close div tag for " + this.getClass().getName());
        return;/*  w  ww . java2 s . com*/
    }
    //remove all HTML tag, as any these tag must from RichEditor, which is invalid to add style to code macro part...
    HTMLNode subnode;
    StringBuffer sb = new StringBuffer();

    //!!! Here changes ListIterator cursor position!!!
    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 {
            sb.append(subnode.getText());
        }
    }

    //do reverse replace, refer to CodeHandler...
    if (sb.length() > 0) {
        String code = sb.toString();
        code = code.replaceAll("&lt;", "<");
        code = code.replaceAll("&amp;", "&");
        //if code content is not empty, node must has next()
        node.next().reset(code, true);

        String src = "";
        if (node.getAttributes() != null && node.getAttributes().get(NameConstants.CLASS) != null) {
            String srcName = StringUtils.substringAfter(node.getAttributes().get(NameConstants.CLASS), ":");
            if (!DEFAULT_CODE.equalsIgnoreCase(srcName)) {
                src = "|" + NameConstants.SRC + "=" + srcName;
            }
        }

        //as above Iterator cursor already move to end of pair node, so move them back and restore around insertMarkup method

        moveIteratorCursorTo(node, iter, false); //move from end to start 
        resetMacroMarkup(TIDY_STYLE_BLOCK, node, iter, "{code" + src + "}", "{code}");
        moveIteratorCursorTo(node.getPair(), iter, true); // move from start to end

    }
}

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/*w ww.j a v a 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:com.amalto.core.history.accessor.record.DataRecordAccessor.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//from w  w  w  . j ava  2s . c  om
public void set(String value) {
    try {
        initPath();
        DataRecord current = dataRecord;
        ListIterator<PathElement> listIterator = pathElements.listIterator();
        PathElement pathElement = null;
        while (listIterator.hasNext()) {
            pathElement = listIterator.next();
            if (!listIterator.hasNext()) {
                break;
            }
            if (!pathElement.field.isMany()) {
                if (pathElement.field instanceof ContainedTypeFieldMetadata) {
                    current = (DataRecord) current.get(pathElement.field);
                }
            } else {
                List<Object> list = (List) current.get(pathElement.field);
                if (list == null) {
                    list = new ArrayList<Object>();
                    current.set(pathElement.field, list);
                }
                while (pathElement.index > list.size() - 1) { // Expand list size
                    list.add(null);
                }
                if (pathElement.field instanceof ContainedTypeFieldMetadata) {
                    current = (DataRecord) ((List) current.get(pathElement.field)).get(pathElement.index);
                }
            }
        }
        if (pathElement != null) {
            pathElement.setter.set(repository, current, pathElement, value);
        }
    } finally {
        cachedExist = true;
    }
}

From source file:chat.viska.commons.pipelines.Pipeline.java

/**
 * Removes a {@link Pipe}. Fails silently if the specified {@link Pipe} does
 * not exist in the pipeline.//from  w ww . jav a  2s . co m
 */
@SchedulerSupport(SchedulerSupport.IO)
public Maybe<Pipe> remove(final Pipe pipe) {
    return Maybe.fromCallable((Callable<@Nullable Pipe>) () -> {
        pipeLock.writeLock().lockInterruptibly();
        try {
            final ListIterator iterator = getIteratorOf(pipe);
            if (iterator == null) {
                return null;
            }
            iterator.next(); // For the remove() to work
            iterator.remove();
            pipe.onRemovedFromPipeline(this);
        } finally {
            pipeLock.writeLock().unlock();
        }
        return pipe;
    }).subscribeOn(Schedulers.io());
}

From source file:com.amalto.core.history.accessor.record.DataRecordAccessor.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from   w w  w . ja v  a2 s. c o m*/
public void delete() {
    if (!exist()) {
        return; // Value is already deleted.
    }
    try {
        initPath();
        DataRecord current = dataRecord;
        ListIterator<PathElement> listIterator = pathElements.listIterator();
        PathElement pathElement = null;
        while (listIterator.hasNext()) {
            pathElement = listIterator.next();
            if (!listIterator.hasNext()) {
                break;
            }
            if (!pathElement.field.isMany()) {
                if (pathElement.field instanceof ContainedTypeFieldMetadata) {
                    current = (DataRecord) current.get(pathElement.field);
                }
            } else {
                if (pathElement.field instanceof ContainedTypeFieldMetadata) {
                    current = (DataRecord) ((List) current.get(pathElement.field)).get(pathElement.index);
                } else {
                    List<Object> list = (List) dataRecord.get(pathElement.field);
                    if (list == null) {
                        list = new ArrayList<Object>();
                        dataRecord.set(pathElement.field, list);
                    }
                }
            }
        }
        if (pathElement != null) {
            if (pathElement.field.isMany()) {
                if (pathElement.index < 0) {
                    ((List) current.get(pathElement.field)).clear();
                } else {
                    ((List) current.get(pathElement.field)).remove(pathElement.index);
                }
            } else {
                current.set(pathElement.field, null);
            }
        }
    } finally {
        cachedExist = false;
    }
}

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

protected void putIntermediateVersions(ListIterator<S3ObjectVersion> versions, String key) {
    while (versions.hasNext()) {
        S3ObjectVersion version = versions.next();
        try {//from w  ww. j  a va  2  s . 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());
                    s3.deleteObject(bucketName, key);
                } 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);
        }
    }
}