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: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  ww w.  jav a2 s.c  o  m*/
        }
    }
}

From source file:net.erdfelt.android.sdkfido.project.SourceCopier.java

public void identifyCopiedFiles(Dir sourceDir) throws IOException {
    if (javalisting == null) {
        return; // nothing to do here
    }/*from   w  w  w .j av  a2  s.  c om*/
    File searchFile;
    String javafilename;
    ListIterator<String> iterlisting = javalisting.listIterator();
    while (iterlisting.hasNext()) {
        javafilename = iterlisting.next();
        searchFile = sourceDir.getFile(javafilename);
        if (searchFile.exists()) {
            iterlisting.remove();
            out.println("[FOUND] " + javafilename);
        }
    }
}

From source file:net.alchemiestick.katana.winehqappdb.Metrics.java

private void removeNamedData(String name) {
    ListIterator<NameValuePair> itr = webData.listIterator();
    while (itr.hasNext()) {
        NameValuePair t = itr.next();
        if (t.getName() == name) {
            itr.remove();// ww w  .  j a  va  2s .co  m
            return;
        }
    }
}

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();
        if (ind.getURI().equals(subjectUri)) {
            it.remove();//from   ww w  .  ja va2  s.c  om
        }
    }
    return individuals;
}

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  w ww  . ja v  a  2s .com
            iter.remove();
        }
    }
}

From source file:org.jasig.i18n.translate.AutoTranslationService.java

public Map<String, String> getAutoUpdatedTranslationMap(Map<String, String> mainMap,
        Map<String, String> targetMap, String languageKey) {

    // assemble a set of keys represented in the main map but not in the
    // target language map
    Set<String> missing = mainMap.keySet();
    missing.removeAll(targetMap.keySet());

    // put the keys in a list so that we have a consistent ordering
    List<String> keys = new ArrayList<String>();
    keys.addAll(missing);/*from   w w w.  j a  v  a  2 s  .c om*/

    // assemble a list of untranslated messages in the same order as our
    // missing key list
    List<String> untranslatedMessages = new ArrayList<String>();
    for (String key : keys) {
        untranslatedMessages.add(mainMap.get(key));
    }

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("key", this.apiKey);
    parameters.put("source", this.defaultLanguageKey);
    parameters.put("target", languageKey);
    parameters.put("query", untranslatedMessages);

    GoogleTranslationResponse response = this.restTemplate.getForObject(urlTemplate,
            GoogleTranslationResponse.class, parameters);
    List<Translation> translations = response.getTranslations();

    // iterate through the auto-translations, adding each to the target
    // map
    ListIterator<Translation> iter = translations.listIterator();
    while (iter.hasNext()) {
        Translation translation = iter.next();
        String key = keys.get(iter.previousIndex());
        targetMap.put(key, translation.getTranslatedText());
    }

    return targetMap;
}

From source file:com.adaptris.core.ServiceList.java

@Override
protected void applyServices(AdaptrisMessage msg) throws ServiceException {
    ListIterator<Service> itr = this.listIterator();
    while (itr.hasNext()) {
        Service service = itr.next();
        String serviceName = friendlyName(service);
        if (haltProcessing(msg)) {
            break;
        }/* w ww  . j  a va2s  .c  o m*/
        msg.setNextServiceId("");
        log.debug("Executing doService on [{}]", serviceName);
        try {
            service.doService(msg);
            msg.addEvent(service, true);
            // Should we resolveNext *regardless of exception?*
            itr = resolveNext(itr, msg.getNextServiceId());
        } catch (Exception e) {
            // add fail event
            msg.addEvent(service, false);
            handleException(service, msg, e);
        }
    }
}

From source file:org.yamj.core.database.dao.PlayerDao.java

/**
 * Delete a path from a player/*  w ww  . j av a2s  .co m*/
 *
 * @param playerId
 * @param pathId
 */
public void deletePlayerPath(Long playerId, Long pathId) {
    LOG.info("Attempting to delete path ID {} from player ID {}", pathId, playerId);
    PlayerInfo player = getById(PlayerInfo.class, playerId);

    ListIterator<PlayerPath> iter = player.getPaths().listIterator();
    while (iter.hasNext()) {
        PlayerPath path = iter.next();
        if (path.getId() == pathId) {
            LOG.info("Deleting path: {}", path.toString());
            iter.remove();
            break;
        }
    }

    // Update the Player record
    storePlayer(player);
}

From source file:com.blauadvisors.pentaho.plugins.redirect.RedirectPluginContentGenerator.java

public void createContent() throws Exception {
    this.session = PentahoSessionHolder.getSession();
    this.repository = PentahoSystem.get(IUnifiedRepository.class, session);

    RepositoryFile repositoryFile = (RepositoryFile) parameterProviders.get("path").getParameter("file");

    SimpleRepositoryFileData data = repository.getDataForRead(repositoryFile.getId(),
            SimpleRepositoryFileData.class);

    RedirectPluginFileContectExtractor fileData = new RedirectPluginFileContectExtractor(data.getInputStream());

    /*//  w  ww  . ja  v a  2 s . c o  m
     * Redirect to Specified URL
     */
    try {
        // Get informations about user context
        IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
        String roles = "";
        ListIterator li = service.getRolesForUser(null, session.getName()).listIterator();
        while (li.hasNext()) {
            roles = roles + li.next().toString() + ",";
        }

        // Build URL
        String redirectURL = fileData.getUrl();
        String parameters = "";
        parameters += (fileData.getIncludeRoles() ? "&" + fileData.getRolesParameterName() + "=" + roles : "");
        parameters += (fileData.getIncludeUserName()
                ? "&" + fileData.getUserNameParameterName() + "=" + session.getName()
                : "");
        parameters += (fileData.getIncludeTimeStamp() ? "&" + "timeStamp=" + (new Date()).toString() : "");
        redirectURL += (!fileData.getUrlIncludesParameters() ? "?" : "") + parameters;

        // Redirect
        HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path")
                .getParameter("httpresponse");
        response.sendRedirect(redirectURL);
    } catch (Exception e) {
        Logger.error(getClass().getName(), e.getMessage());
    }
}

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

@Override
public void buildSummary(MrBayesOutput output) throws OperationException {
    try {/* w  w w . j  a va2  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);
    }
}