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.offbynull.coroutines.instrumenter.asm.InstructionUtils.java

/**
 * Clones an instruction list. All labels are remapped unless otherwise specified in {@code globalLabels}.
 * @param insnList instruction list to clone
 * @param globalLabels set of labels that should not be remapped
 * @throws NullPointerException if any argument is {@code null}
 * @return instruction list with cloned instructions
 *///from   www  .  j  av  a2  s. c  o m
public static InsnList cloneInsnList(InsnList insnList, Set<LabelNode> globalLabels) {
    Validate.notNull(insnList);

    // remap all labelnodes
    Map<LabelNode, LabelNode> labelNodeMapping = new HashMap<>();
    ListIterator<AbstractInsnNode> it = insnList.iterator();
    while (it.hasNext()) {
        AbstractInsnNode abstractInsnNode = it.next();
        if (abstractInsnNode instanceof LabelNode) {
            LabelNode existingLabelNode = (LabelNode) abstractInsnNode;
            labelNodeMapping.put(existingLabelNode, new LabelNode());
        }
    }

    // override remapping such that global labels stay the same
    for (LabelNode globalLabel : globalLabels) {
        labelNodeMapping.put(globalLabel, globalLabel);
    }

    // clone
    InsnList ret = new InsnList();
    it = insnList.iterator();
    while (it.hasNext()) {
        AbstractInsnNode abstractInsnNode = it.next();
        ret.add(abstractInsnNode.clone(labelNodeMapping));
    }

    return ret;
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.CDEBrowserTree.java

public DefaultMutableTreeNode buildTree(Hashtable treeParams) throws Exception {

    DefaultMutableTreeNode tree = null;

    BaseTreeNode baseNode = null;//from   w w w.  j  a  v  a  2s.  c  om

    //TimeUtils.recordStartTime("Tree");
    try {
        log.info("Tree Start " + TimeUtils.getEasternTime());

        baseNode = new BaseTreeNode(treeParams);
        CDEBrowserTreeCache cache = CDEBrowserTreeCache.getAnInstance();
        cache.init(baseNode, treeParams);
        WebNode contexts = new WebNode(cache.getIdGen().getNewId(), "caDSR Contexts",
                "javascript:" + baseNode.getJsFunctionName() + "('P_PARAM_TYPE=P_PARAM_TYPE&P_IDSEQ=P_IDSEQ&"
                        + baseNode.getExtraURLParameters() + "')");
        tree = new DefaultMutableTreeNode(contexts);
        List allContexts = cache.getAllContextHolders();

        if (allContexts == null)
            return tree;

        ListIterator contextIt = allContexts.listIterator();

        while (contextIt.hasNext()) {
            ContextHolder currContextHolder = (ContextHolder) contextIt.next();

            Context currContext = currContextHolder.getContext();
            DefaultMutableTreeNode contextNode = currContextHolder.getNode();

            //Adding data template nodes

            DefaultMutableTreeNode tmpLabelNode;
            DefaultMutableTreeNode otherTempNodes;

            if (Context.CTEP.equals(currContext.getName())) {

                cache.initCtepInfo(baseNode, currContext);

                tmpLabelNode = new DefaultMutableTreeNode(
                        new WebNode(cache.getIdGen().getNewId(), "Protocol Form Templates"));
                List ctepNodes = cache.getAllTemplatesForCtep();
                tmpLabelNode.add((DefaultMutableTreeNode) ctepNodes.get(0));
                tmpLabelNode.add((DefaultMutableTreeNode) ctepNodes.get(1));
                contextNode.add(tmpLabelNode);

                log.info("CTEP Templates End " + TimeUtils.getEasternTime());
            } else {
                log.info("Other Templates Start " + TimeUtils.getEasternTime());

                otherTempNodes = cache.getTemplateNodes(currContext.getConteIdseq());

                if (otherTempNodes != null) {
                    contextNode.add(otherTempNodes);
                }

                log.info("Other Templates End " + TimeUtils.getEasternTime());
            }

            //Adding classification nodes
            long startingTime = System.currentTimeMillis();
            log.info("Classification Start " + TimeUtils.getEasternTime());
            DefaultMutableTreeNode csNode = cache.getClassificationNodes(currContext.getConteIdseq());

            if (csNode != null)
                contextNode.add(csNode);

            long timeElsp = System.currentTimeMillis() - startingTime;
            log.info("Classification Took " + timeElsp);
            //End Adding Classification Node

            //Adding protocols nodes
            //Filtering CTEP context in data element search tree
            log.info("Proto forms Start " + TimeUtils.getEasternTime());

            /** Remove to TT 1892
             if ((!currContext.getName().equals(Context.CTEP) && treeType.equals(TreeConstants.DE_SEARCH_TREE))
             //Publish Change order
               || (baseNode.isCTEPUser().equals("Yes") && treeType.equals(TreeConstants.DE_SEARCH_TREE))
               || (treeType.equals(TreeConstants.FORM_SEARCH_TREE))) {
              if ((currContext.getName().equals(
                      Context.CTEP) && baseNode.isCTEPUser().equals("Yes")) || (!currContext.getName().equals(Context.CTEP)))
                      {
                              
             **/
            List protoNodes = cache.getProtocolNodes(currContext.getConteIdseq());

            /** for release 3.0.1, forms without protocol is not displayed, uncomment this
             * code to display them
               DefaultMutableTreeNode noProtocolFormNode =
               cache.getProtocolFormNodeWithNoProtocol(currContext.getConteIdseq());
            */
            DefaultMutableTreeNode protocolFormsLabelNode = null;

            /** for release 3.0.1, forms without protocol is not displayed, uncomment this
             * code to display them
               if ((protoNodes != null && !protoNodes.isEmpty()) || noProtocolFormNode != null ) {
            */
            if ((protoNodes != null && !protoNodes.isEmpty())) {
                protocolFormsLabelNode = new DefaultMutableTreeNode(
                        new WebNode(cache.getIdGen().getNewId(), "Protocol Forms"));
                /** for release 3.0.1, forms without protocol is not displayed, uncomment this
                 * code to display them
                        
                    // Add form with no protocol
                    if (noProtocolFormNode != null ) {
                      protocolFormsLabelNode.add(noProtocolFormNode);
                    }
                */
                // Add form with protocol
                if (protoNodes != null && !protoNodes.isEmpty()) {
                    Iterator tmpIter = protoNodes.iterator();

                    while (tmpIter.hasNext()) {
                        protocolFormsLabelNode.add((DefaultMutableTreeNode) tmpIter.next());
                    }
                }

                contextNode.add(protocolFormsLabelNode);
            }
            /** } TT 1892 
            }**/

            log.info("Proto forms End " + TimeUtils.getEasternTime());
            //End Add Protocol Nodes

            //Display Catalog

            //Get Publishing Node info
            log.info("Publish strat " + TimeUtils.getEasternTime());
            DefaultMutableTreeNode publishNode = cache.getPublishNode(currContext);

            if (publishNode != null)
                contextNode.add(publishNode);

            log.info("Publish end " + TimeUtils.getEasternTime());
            //End Catalog

            tree.add(contextNode);
        }

        log.info("Tree End " + TimeUtils.getEasternTime());
    } catch (Exception ex) {
        ex.printStackTrace();

        throw ex;
    }

    return tree;
}

From source file:annis.gui.frequency.FrequencyResultPanel.java

private String createFieldsString() {
    StringBuilder sb = new StringBuilder();

    ListIterator<FrequencyTableEntry> it = freqDefinition.listIterator();
    while (it.hasNext()) {
        FrequencyTableEntry e = it.next();

        sb.append(e.getReferencedNode()).append(":");
        if (e.getType() == FrequencyTableEntryType.span) {
            sb.append("tok");
        } else {/*from ww w.  j  ava2  s. c  o m*/
            sb.append(e.getKey());
        }

        if (it.hasNext()) {
            sb.append(",");
        }
    }

    return sb.toString();
}

From source file:RedundancyChecker.java

public boolean checkForRedundancy(List l) {
    ListIterator li1 = l.listIterator(); // Make a
    // general/*ww w.j  a  v a2  s.co  m*/
    // ListIterator
    // on the list

    while (li1.hasNext()) {
        // Store the value of the actual first checked
        // element of the List,
        // it needs to be stored because it calls the
        // .next(), which we can call only once per loop
        // in order to sweep the whole list.
        int check1 = ((Integer) li1.next()).intValue();

        // Make a second ListIterator that will start
        // with the element that is just after the
        // actual first checked one,
        // in order to avoid checking several times the
        // same elements.
        ListIterator li2 = l.listIterator(li1.nextIndex() + 1);

        while (li2.hasNext()) {
            // Store the following elements one by
            // one and check to see if they match
            // the actual one.
            int check2 = ((Integer) li2.next()).intValue();
            if (check1 == check2) {
                System.out.println("Oh no! The value " + check1 + " is redundant.");
                return true;
            }
        }
        // The .next() method has already been called at
        // the beginning of the loop.
    }
    return false;
}

From source file:com.replaymod.replaystudio.collection.PacketList.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof List) {
        PacketListIterator iter = this.listIterator();
        ListIterator<?> other = ((List<?>) obj).listIterator();
        while (other.hasNext() && iter.hasNext()) {
            if (!Objects.equals(other.next(), iter.next())) {
                return false;
            }/*from www. j  a  v a 2s.  co m*/
        }
        return !(other.hasNext() || iter.hasNext());
    }
    return super.equals(obj);
}

From source file:mediathek.controller.IoXmlSchreiben.java

private void xmlSchreibenAbo() {
    ListIterator<DatenAbo> iterator;
    //Abo schreibem
    DatenAbo datenAbo;//from  www . jav a  2s  . c om
    iterator = Daten.listeAbo.listIterator();
    while (iterator.hasNext()) {
        datenAbo = iterator.next();
        xmlSchreibenDaten(DatenAbo.ABO, DatenAbo.COLUMN_NAMES, datenAbo.arr, false);
    }
}

From source file:net.oneandone.stool.overview.ProcessesController.java

@RequestMapping(value = "{id}/log", method = RequestMethod.GET)
@ResponseBody/* w  w  w  . ja va 2s. com*/
public ResponseEntity log(@PathVariable(value = "id") String id,
        @RequestParam(defaultValue = "0") Integer index) throws IOException, InterruptedException {
    Node logfile;
    StringBuilder output;
    MultiValueMap<String, String> headers;
    output = new StringBuilder();
    List<String> strings;
    ListIterator<String> iterator;

    headers = new HttpHeaders();

    try {
        logfile = logFile(id);
    } catch (ResourceNotFoundException e) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    strings = logfile.readLines();
    iterator = strings.listIterator(index);
    while (iterator.hasNext()) {
        output.append(iterator.next()).append("<br />");
    }
    headers.set("X-index", "" + strings.size());
    return new ResponseEntity<>(output.toString(), headers, HttpStatus.OK);
}

From source file:com.github.vanroy.springdata.jest.CriteriaQueryProcessor.java

QueryBuilder createQueryFromCriteria(Criteria criteria) {
    if (criteria == null)
        return null;

    List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
    List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
    List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();

    ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();

    QueryBuilder firstQuery = null;/*from w  w w .  jav  a  2 s  .com*/
    boolean negateFirstQuery = false;

    while (chainIterator.hasNext()) {
        Criteria chainedCriteria = chainIterator.next();
        QueryBuilder queryFragmentForCriteria = createQueryFragmentForCriteria(chainedCriteria);
        if (queryFragmentForCriteria != null) {
            if (firstQuery == null) {
                firstQuery = queryFragmentForCriteria;
                negateFirstQuery = chainedCriteria.isNegating();
                continue;
            }
            if (chainedCriteria.isOr()) {
                shouldQueryBuilderList.add(queryFragmentForCriteria);
            } else if (chainedCriteria.isNegating()) {
                mustNotQueryBuilderList.add(queryFragmentForCriteria);
            } else {
                mustQueryBuilderList.add(queryFragmentForCriteria);
            }
        }
    }

    if (firstQuery != null) {
        if (!shouldQueryBuilderList.isEmpty() && mustNotQueryBuilderList.isEmpty()
                && mustQueryBuilderList.isEmpty()) {
            shouldQueryBuilderList.add(0, firstQuery);
        } else {
            if (negateFirstQuery) {
                mustNotQueryBuilderList.add(0, firstQuery);
            } else {
                mustQueryBuilderList.add(0, firstQuery);
            }
        }
    }

    BoolQueryBuilder query = null;

    if (!shouldQueryBuilderList.isEmpty() || !mustNotQueryBuilderList.isEmpty()
            || !mustQueryBuilderList.isEmpty()) {

        query = boolQuery();

        for (QueryBuilder qb : shouldQueryBuilderList) {
            query.should(qb);
        }
        for (QueryBuilder qb : mustNotQueryBuilderList) {
            query.mustNot(qb);
        }
        for (QueryBuilder qb : mustQueryBuilderList) {
            query.must(qb);
        }
    }

    return query;
}

From source file:msearch.filmlisten.MSFilmlisteSchreiben.java

public void filmlisteSchreibenJson(String datei, ListeFilme listeFilme) {
    MSLog.systemMeldung("Filme schreiben (" + listeFilme.size() + " Filme) :");
    File file = new File(datei);
    File dir = new File(file.getParent());
    if (!dir.exists()) {
        if (!dir.mkdirs()) {
            MSLog.fehlerMeldung(915236478, MSLog.FEHLER_ART_PROG,
                    "MSearchIoXmlFilmlisteSchreiben.xmlSchreibenStart",
                    "Kann den Pfad nicht anlegen: " + dir.toString());
        }/*  w ww  . jav  a  2  s . c o m*/
    }
    MSLog.systemMeldung("   --> Start Schreiben nach: " + datei);
    try {
        String sender = "", thema = "";
        JsonFactory jsonF = new JsonFactory();
        JsonGenerator jg;
        if (datei.endsWith(MSConst.FORMAT_XZ)) {
            LZMA2Options options = new LZMA2Options();
            XZOutputStream out = new XZOutputStream(new FileOutputStream(file), options);
            jg = jsonF.createGenerator(out);
        } else if (datei.endsWith(MSConst.FORMAT_BZ2)) {
            bZip2CompressorOutputStream = new BZip2CompressorOutputStream(new FileOutputStream(file),
                    9 /*Blocksize: 1 - 9*/);
            jg = jsonF.createGenerator(bZip2CompressorOutputStream, JsonEncoding.UTF8);
        } else if (datei.endsWith(MSConst.FORMAT_ZIP)) {
            zipOutputStream = new ZipOutputStream(new FileOutputStream(file));
            ZipEntry entry = new ZipEntry(MSConst.XML_DATEI_FILME);
            zipOutputStream.putNextEntry(entry);
            jg = jsonF.createGenerator(zipOutputStream, JsonEncoding.UTF8);
        } else {
            jg = jsonF.createGenerator(new File(datei), JsonEncoding.UTF8);
        }
        jg.useDefaultPrettyPrinter(); // enable indentation just to make debug/testing easier
        jg.writeStartObject();
        // Infos zur Filmliste
        jg.writeArrayFieldStart(ListeFilme.FILMLISTE);
        for (int i = 0; i < ListeFilme.MAX_ELEM; ++i) {
            jg.writeString(listeFilme.metaDaten[i]);
        }
        jg.writeEndArray();
        // Infos der Felder in der Filmliste
        jg.writeArrayFieldStart(ListeFilme.FILMLISTE);
        for (int i = 0; i < DatenFilm.COLUMN_NAMES_JSON.length; ++i) {
            jg.writeString(DatenFilm.COLUMN_NAMES[DatenFilm.COLUMN_NAMES_JSON[i]]);
        }
        jg.writeEndArray();
        //Filme schreiben
        ListIterator<DatenFilm> iterator;
        DatenFilm datenFilm;
        iterator = listeFilme.listIterator();
        while (iterator.hasNext()) {
            datenFilm = iterator.next();
            jg.writeArrayFieldStart(DatenFilm.FILME_);
            for (int i = 0; i < DatenFilm.COLUMN_NAMES_JSON.length; ++i) {
                int m = DatenFilm.COLUMN_NAMES_JSON[i];
                if (m == DatenFilm.FILM_SENDER_NR) {
                    if (datenFilm.arr[m].equals(sender)) {
                        jg.writeString("");
                    } else {
                        sender = datenFilm.arr[m];
                        jg.writeString(datenFilm.arr[m]);
                    }
                } else if (m == DatenFilm.FILM_THEMA_NR) {
                    if (datenFilm.arr[m].equals(thema)) {
                        jg.writeString("");
                    } else {
                        thema = datenFilm.arr[m];
                        jg.writeString(datenFilm.arr[m]);
                    }
                } else {
                    jg.writeString(datenFilm.arr[m]);
                }
            }
            jg.writeEndArray();
        }
        jg.writeEndObject();
        jg.close();
        MSLog.systemMeldung("   --> geschrieben!");
    } catch (Exception ex) {
        MSLog.fehlerMeldung(846930145, MSLog.FEHLER_ART_PROG, "IoXmlSchreiben.FilmeSchreiben", ex,
                "nach: " + datei);
    }
}

From source file:msearch.io.MSFilmlisteSchreiben.java

public void filmlisteSchreibenJson(String datei, ListeFilme listeFilme) {
    MSLog.systemMeldung("Filme Schreiben (" + listeFilme.size() + " Filme) :");
    File file = new File(datei);
    File dir = new File(file.getParent());
    if (!dir.exists()) {
        if (!dir.mkdirs()) {
            MSLog.fehlerMeldung(915236478, MSLog.FEHLER_ART_PROG,
                    "MSearchIoXmlFilmlisteSchreiben.xmlSchreibenStart",
                    "Kann den Pfad nicht anlegen: " + dir.toString());
        }/*  w w  w. j  av  a2  s . com*/
    }
    MSLog.systemMeldung("   --> Start Schreiben nach: " + datei);
    try {
        String sender = "", thema = "";
        JsonFactory jsonF = new JsonFactory();
        JsonGenerator jg;
        if (datei.endsWith(MSConst.FORMAT_XZ)) {
            LZMA2Options options = new LZMA2Options();
            XZOutputStream out = new XZOutputStream(new FileOutputStream(file), options);
            jg = jsonF.createGenerator(out);
        } else if (datei.endsWith(MSConst.FORMAT_BZ2)) {
            bZip2CompressorOutputStream = new BZip2CompressorOutputStream(new FileOutputStream(file),
                    9 /*Blocksize: 1 - 9*/);
            jg = jsonF.createGenerator(bZip2CompressorOutputStream, JsonEncoding.UTF8);
        } else if (datei.endsWith(MSConst.FORMAT_ZIP)) {
            zipOutputStream = new ZipOutputStream(new FileOutputStream(file));
            ZipEntry entry = new ZipEntry(MSConst.XML_DATEI_FILME);
            zipOutputStream.putNextEntry(entry);
            jg = jsonF.createGenerator(zipOutputStream, JsonEncoding.UTF8);
        } else {
            jg = jsonF.createGenerator(new File(datei), JsonEncoding.UTF8);
        }
        jg.useDefaultPrettyPrinter(); // enable indentation just to make debug/testing easier
        jg.writeStartObject();
        // Infos zur Filmliste
        jg.writeArrayFieldStart(ListeFilme.FILMLISTE);
        for (int i = 0; i < ListeFilme.MAX_ELEM; ++i) {
            jg.writeString(listeFilme.metaDaten[i]);
        }
        jg.writeEndArray();
        // Infos der Felder in der Filmliste
        jg.writeArrayFieldStart(ListeFilme.FILMLISTE);
        for (int i = 0; i < DatenFilm.COLUMN_NAMES_JSON.length; ++i) {
            jg.writeString(DatenFilm.COLUMN_NAMES[DatenFilm.COLUMN_NAMES_JSON[i]]);
        }
        jg.writeEndArray();
        //Filme schreiben
        ListIterator<DatenFilm> iterator;
        DatenFilm datenFilm;
        iterator = listeFilme.listIterator();
        while (iterator.hasNext()) {
            datenFilm = iterator.next();
            jg.writeArrayFieldStart(DatenFilm.FILME_);
            for (int i = 0; i < DatenFilm.COLUMN_NAMES_JSON.length; ++i) {
                int m = DatenFilm.COLUMN_NAMES_JSON[i];
                if (m == DatenFilm.FILM_SENDER_NR) {
                    if (datenFilm.arr[m].equals(sender)) {
                        jg.writeString("");
                    } else {
                        sender = datenFilm.arr[m];
                        jg.writeString(datenFilm.arr[m]);
                    }
                } else if (m == DatenFilm.FILM_THEMA_NR) {
                    if (datenFilm.arr[m].equals(thema)) {
                        jg.writeString("");
                    } else {
                        thema = datenFilm.arr[m];
                        jg.writeString(datenFilm.arr[m]);
                    }
                } else {
                    jg.writeString(datenFilm.arr[m]);
                }
            }
            jg.writeEndArray();
        }
        jg.writeEndObject();
        jg.close();
        MSLog.systemMeldung("   --> geschrieben!");
    } catch (Exception ex) {
        MSLog.fehlerMeldung(846930145, MSLog.FEHLER_ART_PROG, "IoXmlSchreiben.FilmeSchreiben", ex,
                "nach: " + datei);
    }
}