List of usage examples for java.util ListIterator hasPrevious
boolean hasPrevious();
From source file:org.gluu.site.ldap.persistence.LdifDataUtility.java
/** * Remove base entry with all sub entries * // w ww . j a v a2 s . co 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:fr.norad.visuwall.core.business.process.capabilities.BuildCapabilityProcess.java
public void updatePreviousCompletedBuild(Project project) throws ProjectNotFoundException { List<String> buildIds = project.getBuildId(); if (buildIds.size() < 2) { // with only a build there is no previous completed build return;//from w w w. j a v a2 s . c om } try { int skip = 1; if (project.getLastBuild().isBuilding()) { if (buildIds.size() < 3) { // first build is building so we do not have enough builds to have a previous completed return; } skip = 2; } ListIterator<String> reverseBuildIt = project.getBuildId().listIterator(project.getBuildId().size()); for (int i = 0; reverseBuildIt.hasPrevious(); i++) { String buildId = reverseBuildIt.previous(); if (i < skip) { continue; } Build build = getCreatedWithContentBuild(project, buildId); if (build == null) { continue; } BuildState state = build.getState(); if (state == BuildState.UNKNOWN || state == BuildState.ABORTED) { continue; } project.setPreviousCompletedBuildId(build.getBuildId()); break; } } catch (BuildNotFoundException e) { LOG.warn("last build not found to update previous completed build", e); } }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule.java
private void pushOps(List<ILogicalOperator> opList, Mutable<ILogicalOperator> joinBranch, IOptimizationContext context) throws AlgebricksException { ILogicalOperator topOp = joinBranch.getValue(); ListIterator<ILogicalOperator> iter = opList.listIterator(opList.size()); while (iter.hasPrevious()) { ILogicalOperator op = iter.previous(); List<Mutable<ILogicalOperator>> opInpList = op.getInputs(); opInpList.clear();//from w w w . j a v a 2 s . c om opInpList.add(new MutableObject<ILogicalOperator>(topOp)); topOp = op; context.computeAndSetTypeEnvironmentForOperator(op); } joinBranch.setValue(topOp); }
From source file:com.tesora.dve.distribution.DistributionRange.java
public MappingSolution mapKeyToGeneration(IKeyValue key) throws PEException { StorageGroupGeneration groupGen = storageGroup.getLastGen(); setComparatorClass(key);/*from www . ja v a2 s. c om*/ ListIterator<GenerationKeyRange> i = rangeGenerations.listIterator(rangeGenerations.size()); while (i.hasPrevious()) { //TODO: this traverses from youngest to oldest, but returns oldest match or lastGen(), which can be confusing. -sgossard GenerationKeyRange genKeyRange = i.previous(); if (genKeyRange.isInRange(key)) groupGen = genKeyRange.getStorageGroupGeneration(); else break; } if (logger.isDebugEnabled()) { logger.debug("Mapping key " + key.toString() + " to generation " + groupGen.getVersion() + " using range " + this + " which has " + rangeGenerations.size() + " generations and is rep'd by object " + System.identityHashCode(this)); } return getMappingInGeneration(key, groupGen); }
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 *//*from www .j a v a2s . co m*/ 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 */// w w w . j a v a 2s . c o m 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 . j a v a 2s .co 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: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 . j a va 2s .c om*/ interceptor.postExecution(request, response, this, e); } catch (Throwable ex2) { logger.error("HandlerInterceptor.postExecution threw exception", ex2); } } }
From source file:hu.ppke.itk.nlpg.purepos.model.internal.NGramModel.java
@Override public void addWord(List<Integer> context, W word) { ListIterator<Integer> iterator = context.listIterator(context.size()); IntTrieNode<W> act = root;/*from www . j a va 2 s. c om*/ int i = 0; int size = n - 1; act.addWord(word); while (iterator.hasPrevious() && i < size) { act = (IntTrieNode<W>) act.addChild(iterator.previous()); act.addWord(word); i++; } }
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 ww . j av a2 s .c o m*/ defaultExecutor.finish(); } catch (Exception e) { Logger.severe(e.toString()); } } }