Example usage for java.util ListIterator previous

List of usage examples for java.util ListIterator previous

Introduction

In this page you can find the example usage for java.util ListIterator previous.

Prototype

E previous();

Source Link

Document

Returns the previous element in the list and moves the cursor position backwards.

Usage

From source file:org.gluu.site.ldap.persistence.LdifDataUtility.java

/**
 * Remove base entry with all sub entries
 * /*w w  w .ja v a  2  s  .c  o m*/
 * @param connection
 *            Connection to LDAP server
 * @param baseDN
 *            Base DN entry
 * @return The result code for the processing that was performed.
 */
public ResultCode deleteEntryWithAllSubs(LDAPConnection connection, String baseDN) {
    ResultCode resultCode = ResultCode.SUCCESS;
    SearchResult searchResult = null;
    try {
        searchResult = connection.search(baseDN, SearchScope.SUB, "objectClass=*");
        if ((searchResult == null) || (searchResult.getEntryCount() == 0)) {
            return ResultCode.LOCAL_ERROR;
        }
    } catch (LDAPSearchException le) {
        log.error("Failed to search subordinate entries", le);
        return ResultCode.LOCAL_ERROR;
    }

    LinkedList<String> dns = new LinkedList<String>();
    for (SearchResultEntry entry : searchResult.getSearchEntries()) {
        dns.add(entry.getDN());
    }

    ListIterator<String> listIterator = dns.listIterator(dns.size());
    while (listIterator.hasPrevious()) {
        try {
            connection.delete(listIterator.previous());
        } catch (LDAPException le) {
            log.error("Failed to delete entry", le);
            resultCode = ResultCode.LOCAL_ERROR;
            break;
        }
    }

    return resultCode;
}

From source file:org.apache.http2.impl.conn.tsccm.RouteSpecificPool.java

/**
 * Obtains a free entry from this pool, if one is available.
 *
 * @return an available pool entry, or <code>null</code> if there is none
 *///  w  w  w .  j a va  2  s.c om
public BasicPoolEntry allocEntry(final Object state) {
    if (!freeEntries.isEmpty()) {
        ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
        while (it.hasPrevious()) {
            BasicPoolEntry entry = it.previous();
            if (entry.getState() == null || LangUtils.equals(state, entry.getState())) {
                it.remove();
                return entry;
            }
        }
    }
    if (getCapacity() == 0 && !freeEntries.isEmpty()) {
        BasicPoolEntry entry = freeEntries.remove();
        entry.shutdownEntry();
        OperatedClientConnection conn = entry.getConnection();
        try {
            conn.close();
        } catch (IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
        return entry;
    }
    return null;
}

From source file:org.apache.http.impl.conn.tsccm.RouteSpecificPool.java

/**
 * Obtains a free entry from this pool, if one is available.
 *
 * @return an available pool entry, or <code>null</code> if there is none
 *///from www . j  a  v  a2 s. c om
public BasicPoolEntry allocEntry(final Object state) {
    if (!freeEntries.isEmpty()) {
        final ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
        while (it.hasPrevious()) {
            final BasicPoolEntry entry = it.previous();
            if (entry.getState() == null || LangUtils.equals(state, entry.getState())) {
                it.remove();
                return entry;
            }
        }
    }
    if (getCapacity() == 0 && !freeEntries.isEmpty()) {
        final BasicPoolEntry entry = freeEntries.remove();
        entry.shutdownEntry();
        final OperatedClientConnection conn = entry.getConnection();
        try {
            conn.close();
        } catch (final IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
        return entry;
    }
    return null;
}

From source file:hu.ppke.itk.nlpg.purepos.model.internal.NGramModel.java

@Override
public List<Double> getWordFrequency(List<Integer> context, W word) {
    ArrayList<Double> ret = new ArrayList<Double>();

    ret.add(root.getAprioriProb(word));/*  w ww . ja va2 s  .c o  m*/
    if (!(context == null || context.size() == 0)) {
        ListIterator<Integer> it = context.listIterator(context.size());
        Integer previous;
        IntTrieNode<W> actNode = root;
        while (it.hasPrevious() && actNode != null) {
            previous = it.previous();
            if (actNode.hasChild(previous)) {
                actNode = (IntTrieNode<W>) actNode.getChild(previous);
                ret.add(actNode.getAprioriProb(word));
            } else {
                ret.add(0.0);
                while (it.hasPrevious()) {
                    ret.add(0.0);
                }
                actNode = null;
            }
        }

    }

    return ret;
}

From source file:de.innovationgate.webgate.api.templates.LazyBeanList.java

public int lastIndexOf(Object arg0) {
    ListIterator keys = _keys.listIterator();
    Object key;/*from   w ww. j  a  v a  2 s . c o  m*/
    Object bean;
    while (keys.hasPrevious()) {
        key = keys.previous();
        try {
            bean = fetch(key);
        } catch (WGAPIException e) {
            throw new IllegalStateException("Unable to execute internal fetch() bc. of exception: "
                    + e.getClass().getName() + " message: " + e.getMessage());
        }
        if (bean.equals(arg0)) {
            return _keys.indexOf(key);
        }
    }
    return -1;
}

From source file:org.eclipse.jubula.client.core.utils.RefToken.java

/**
 * gets the real value for a reference/*from www.  ja  va 2s .  c  o  m*/
 * @param stack current execution stack
 * @param locale currently used locale for testexecution
 * @return the real value for this reference token and given dataset number
 * @throws InvalidDataException if given reference is not resolvable
 */
public String getExecutionString(List<ExecObject> stack, Locale locale) throws InvalidDataException {
    String refGuid = extractCore(getModelString());
    ListIterator<ExecObject> it = stack.listIterator(stack.size());
    while (it.hasPrevious()) {
        ExecObject obj = it.previous();
        String parameterValue = obj.getParameterValue(refGuid);
        if (parameterValue != null) {
            return parameterValue;
        }
    }
    throwInvalidDataException(extractCore(getGuiString()));
    return null;
}

From source file:hws.core.ExecutorThread.java

private void finishExecutors() {
    ListIterator<DefaultExecutor> li = this.outputStartingOrder.listIterator(this.outputStartingOrder.size());
    while (li.hasPrevious()) {
        DefaultExecutor defaultExecutor = li.previous();
        try {/*from w  w w  .  ja v  a 2  s. co  m*/
            defaultExecutor.finish();
        } catch (Exception e) {
            Logger.severe(e.toString());
        }
    }
}

From source file:hws.core.ExecutorThread.java

public void run() {
    Logger.info("Starting stream processing pipeline");
    for (DefaultExecutor defaultExecutor : this.startingOrder) {
        try {//from www  .j  av  a 2s.c  o m
            defaultExecutor.start();
        } catch (Exception e) {
            Logger.severe(e.toString());
        }
    }
    Logger.info("Finishing stream processing pipeline");
    ListIterator<DefaultExecutor> li = this.startingOrder.listIterator(this.startingOrder.size());
    while (li.hasPrevious()) {
        DefaultExecutor defaultExecutor = li.previous();
        try {
            defaultExecutor.finish();
        } catch (Exception e) {
            Logger.severe(e.toString());
        }
    }
    //zk.createPersistent(finishZnode, "");
    Logger.info("Latch Counting Down.");
    this.latch.countDown();
    Logger.info("End of ExecutorThread");
    //this.executor.start();
    //this.executor.finish();

}

From source file:org.apereo.portal.portlet.rendering.worker.PortletFailureExecutionWorker.java

private void doPostExecution(Exception e) {
    //Iterate over handlers in reverse for post execution
    final ListIterator<IPortletExecutionInterceptor> listIterator = this.interceptors
            .listIterator(this.interceptors.size());
    while (listIterator.hasPrevious()) {
        final IPortletExecutionInterceptor interceptor = listIterator.previous();
        try {/*  w w w  .  ja  va  2 s . c  o m*/
            interceptor.postExecution(request, response, this, e);
        } catch (Throwable ex2) {
            logger.error("HandlerInterceptor.postExecution threw exception", ex2);
        }
    }
}

From source file:com.redhat.lightblue.query.Projection.java

private Inclusion getFieldInclusion(Path field, ProjectionList p, Path context) {
    LOGGER.debug("Checking if a projection list projects {}", field);
    Inclusion lastResult = Inclusion.undecided;
    List<Projection> items = p.getItems();
    ListIterator<Projection> itemsItr = items.listIterator(items.size());
    while (itemsItr.hasPrevious()) {
        Inclusion ret = itemsItr.previous().getFieldInclusion(field, context);
        if (ret != Inclusion.undecided) {
            lastResult = ret;/*from www  .j a  v a  2s .c  o m*/
            break;
        }
    }
    LOGGER.debug("Projection list projects {}: {}", field, lastResult);
    return lastResult;
}