Example usage for java.util List listIterator

List of usage examples for java.util List listIterator

Introduction

In this page you can find the example usage for java.util List listIterator.

Prototype

ListIterator<E> listIterator();

Source Link

Document

Returns a list iterator over the elements in this list (in proper sequence).

Usage

From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void removeJenaClassesFromStackTrace(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (ste.getClassName().startsWith("com.hp.hpl.jena.")) {
            iter.remove();/*from  w w w. j  a  va 2s  .c o m*/
        }
    }
}

From source file:org.apache.gobblin.salesforce.SalesforceExtractor.java

private static String buildUrl(String path, List<NameValuePair> qparams) throws RestApiClientException {
    URIBuilder builder = new URIBuilder();
    builder.setPath(path);// w w w.j a v  a  2s.c o m
    ListIterator<NameValuePair> i = qparams.listIterator();
    while (i.hasNext()) {
        NameValuePair keyValue = i.next();
        builder.setParameter(keyValue.getName(), keyValue.getValue());
    }
    URI uri;
    try {
        uri = builder.build();
    } catch (Exception e) {
        throw new RestApiClientException("Failed to build url; error - " + e.getMessage(), e);
    }
    return new HttpGet(uri).getURI().toString();
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void trimStackTraceAtBeginning(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (ste.getClassName().equals(lowestClassInStackTrace.getName())) {
            break;
        } else {/*from   ww  w. j a v a 2 s. com*/
            iter.remove();
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.loggers.StackTraceUtility.java

private void trimStackTraceAtEnd(List<StackTraceElement> list) {
    ListIterator<StackTraceElement> iter = list.listIterator();
    boolean trimming = false;
    while (iter.hasNext()) {
        StackTraceElement ste = iter.next();
        if (trimming) {
            iter.remove();/*from  www.j  a v a2s. co m*/
        } else if (ste.getClassName().contains("ApplicationFilterChain")) {
            trimming = true;
        }
    }
}

From source file:lcn.module.batch.web.guide.support.StagingItemWriter.java

/**
 * BATCH_STAGING? write/*from  w  w  w  . j  a va2 s  .  com*/
 */
public void write(final List<? extends T> items) {

    final ListIterator<? extends T> itemIterator = items.listIterator();
    getJdbcTemplate().batchUpdate("INSERT into BATCH_STAGING (ID, JOB_ID, VALUE, PROCESSED) values (?,?,?,?)",
            new BatchPreparedStatementSetter() {

                public int getBatchSize() {
                    return items.size();
                }

                public void setValues(PreparedStatement ps, int i) throws SQLException {

                    long id = incrementer.nextLongValue();
                    long jobId = stepExecution.getJobExecution().getJobId();

                    Assert.state(itemIterator.nextIndex() == i,
                            "Item ordering must be preserved in batch sql update");

                    byte[] blob = SerializationUtils.serialize((Serializable) itemIterator.next());

                    ps.setLong(1, id);
                    ps.setLong(2, jobId);
                    ps.setBytes(3, blob);
                    ps.setString(4, NEW);
                }
            });

}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSearchQueryOptions.java

private List<Individual> removeSubjectUri(List<Individual> individuals, String subjectUri) {
    ListIterator<Individual> it = individuals.listIterator();
    while (it.hasNext()) {
        Individual ind = it.next();//from ww  w.j  a v  a 2 s  . co  m
        if (ind.getURI().equals(subjectUri)) {
            it.remove();
        }
    }
    return individuals;
}

From source file:io.dyn.core.fsm.StateMachine.java

public StateMachine(List<String> states) {
    Assert.notNull(states, "States cannot be null");
    this.states = states;
    this.cursor = states.listIterator();
}

From source file:ua.aits.crc.controller.MainController.java

@RequestMapping(value = { "/{lan}/index", "/{lan}/main", "/{lan}/home" }, method = RequestMethod.GET)
public ModelAndView index(@PathVariable("lan") String lan, HttpServletRequest request,
        HttpServletResponse response) throws SQLException, ClassNotFoundException, InstantiationException,
        IllegalAccessException, ParseException {
    ModelAndView model = new ModelAndView("index" + lan.toUpperCase());
    List<ProjectModel> energy = Projects.getProjectsByCategory("1");
    for (ListIterator<ProjectModel> iter = energy.listIterator(); iter.hasNext();) {
        ProjectModel a = iter.next();// w ww .j  a v a2 s  . com
        if (a.project_id == 1) {
            iter.remove();
        }
    }
    model.addObject("energy", energy);
    model.addObject("ecology", Projects.getProjectsByCategory("2"));
    model.addObject("tourism", Projects.getProjectsByCategory("3"));
    model.addObject("soc-projects", Projects.getProjectsByCategory("4"));
    return model;
}

From source file:org.cleverbus.admin.web.log.LogController.java

@RequestMapping("/")
public String getLogSearch(@RequestParam(value = "fromDate", required = false) DateTime fromDate,
        @RequestParam MultiValueMap<String, String> params, Model model) throws UnsupportedEncodingException {
    if (fromDate != null) {
        params.remove("fromDate");
        // remove empty values:
        for (List<String> valueList : params.values()) {
            ListIterator<String> values = valueList.listIterator();
            while (values.hasNext()) {
                if (!StringUtils.hasText(values.next())) {
                    values.remove();/* w  ww  .  j a  va2  s  .  co m*/
                }
            }
        }
        model.mergeAttributes(params);
        return "redirect:"
                + UriUtils.encodePath(LogParserConstants.LOGBACK_ISO8601_FORMAT.print(fromDate), "UTF-8");
    }

    model.addAttribute("fromDate", LogParserConstants.LOGBACK_ISO8601_FORMAT.print(
            DateTime.now().minusHours(2).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0)));

    LogParserConfig logParserConfig = new LogParserConfig();
    logParserConfig.setGroupBy(LogParserConstants.DEFAULT_GROUP_BY_PROPERTY);
    logParserConfig.setGroupLimit(LogParserConstants.DEFAULT_GROUP_SIZE);
    model.addAttribute("config", logParserConfig);

    return "logSearch";
}

From source file:es.uvigo.ei.sing.adops.operations.running.mrbayes.MrBayes3_2ProcessManager.java

@Override
public void buildSummary(MrBayesOutput output) throws OperationException {
    try {//  ww  w .  j  a  va  2 s.  co m
        FileUtils.moveFile(new File(output.getConFile().getAbsolutePath() + ".tre"), output.getConFile());

        final List<String> lines = FileUtils.readLines(output.getConFile());
        final ListIterator<String> itLines = lines.listIterator();
        while (itLines.hasNext()) {
            final String line = itLines.next();

            if (line.contains("tree con_50_majrule")) {
                final String[] lineSplit = line.split("=");
                final String tree = lineSplit[1].trim();

                itLines.set(lineSplit[0] + "= " + Newick.parse(tree.trim()));
            }
        }

        FileUtils.writeLines(output.getConFile(), lines);

        super.buildSummary(output);
    } catch (Exception e) {
        throw new OperationException("Error while working with consensus tree", e);
    }
}