List of usage examples for java.util ListIterator hasPrevious
boolean hasPrevious();
From source file:org.deteter.test.deleterTest.java
@Test public void delete() { lista = new ArrayList<>(); //File dir = new File("C:\\Users\\JORGE_000\\Desktop\\nexus-oss"); File dir = new File( "c:\\abcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxyabcdefghijklmnopqrssttuvwxy"); //FileUtils.deleteDirectory(dir); //FileUtils.deleteDirectory(dir); //FileDeleteStrategy.FORCE.delete(dir); agregar(dir);//from w w w . j av a2 s . c o m System.out.println(dir.isDirectory()); /*for (File f : lista) { try { System.out.println(f.getCanonicalPath()); } catch (Exception ex) { System.out.println(ex); } }*/ ListIterator<File> i = lista.listIterator(lista.size()); try { while (i.hasPrevious()) { File f = i.previous(); //f.delete(); FileDeleteStrategy.FORCE.delete(f); //System.out.println(f.getCanonicalPath()); } FileDeleteStrategy.FORCE.delete(dir); } catch (Exception ex) { System.out.println(ex); } }
From source file:com.skelril.nitro.point.ValueMapping.java
public Collection<KeyType> satisfy(PointType value) { List<KeyType> results = new ArrayList<>(); ListIterator<PointValue<KeyType, PointType>> it = values.listIterator(values.size()); while (it.hasPrevious()) { PointValue<KeyType, PointType> cur = it.previous(); PointType amt = pointTypeDiv.apply(value, cur.getPoints()); value = pointTypeMod.apply(value, cur.getPoints()); results.addAll(collect(cur.getSatisfiers(), amt)); }//from ww w.jav a2 s . co m return results; }
From source file:com.skelril.nitro.point.ValueMapping.java
public Collection<KeyType> getBestSatisifers(PointType value) { ListIterator<PointValue<KeyType, PointType>> satisfier = values.listIterator(values.size()); while (satisfier.hasPrevious()) { PointValue<KeyType, PointType> curVal = satisfier.previous(); PointType type = curVal.getPoints(); if (type.compareTo(value) <= 0) { return curVal.getSatisfiers(); }//from ww w . j a v a 2 s. c om } return Collections.emptyList(); }
From source file:org.springframework.xd.greenplum.support.CleanableJdbcOperations.java
public void clean() { ListIterator<Operation> listIterator = operations.listIterator(operations.size()); while (listIterator.hasPrevious()) { Operation operation = (Operation) listIterator.previous(); try {//from w w w . ja v a2 s . co m log.info(operation.cleanSql); jdbcTemplate.execute(operation.cleanSql); } catch (DataAccessException e) { cleanException = e; } } }
From source file:org.springframework.cloud.gateway.rsocket.filter.AbstractFilterChain.java
private FC initChain(List<F> filters) { FC chain = create(filters, null, null); ListIterator<? extends F> iterator = filters.listIterator(filters.size()); while (iterator.hasPrevious()) { chain = create(filters, iterator.previous(), chain); }//from w ww. ja v a 2 s. c o m return chain; }
From source file:org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.java
@Override public Object call(final RenderContext renderContext, Object... arguments) { ExtensionUtils.checkArgumentCount(RuntimeFunction.USE, arguments, 2); RuntimeObjectModel runtimeObjectModel = renderContext.getObjectModel(); String identifier = runtimeObjectModel.toString(arguments[0]); if (StringUtils.isEmpty(identifier)) { throw new SightlyException("data-sly-use needs to be passed an identifier"); }/*from w ww . ja v a 2s .com*/ Map<String, Object> useArgumentsMap = runtimeObjectModel.toMap(arguments[1]); Bindings useArguments = new SimpleBindings(Collections.unmodifiableMap(useArgumentsMap)); ArrayList<UseProvider> providers = new ArrayList<>(providersMap.values()); ListIterator<UseProvider> iterator = providers.listIterator(providers.size()); while (iterator.hasPrevious()) { UseProvider provider = iterator.previous(); ProviderOutcome outcome = provider.provide(identifier, renderContext, useArguments); Throwable failureCause; if (outcome.isSuccess()) { return outcome.getResult(); } else if ((failureCause = outcome.getCause()) != null) { throw new SightlyException( "Identifier " + identifier + " cannot be correctly instantiated by the Use API", failureCause); } } throw new SightlyException("No use provider could resolve identifier " + identifier); }
From source file:ListOfLists.java
public int lastIndexOf(Object o) { ListIterator e = listIterator(size()); if (o == null) { while (e.hasPrevious()) { if (e.previous() == null) return e.nextIndex(); }//from w ww. j av a 2 s .c om } else { Object el; while (e.hasPrevious()) { el = e.previous(); if (el != null && el.equals(o)) return e.nextIndex(); } } return -1; }
From source file:org.xchain.impl.FilterChainImpl.java
public boolean postProcess(JXPathContext context, Exception exception) { ListIterator<Command> iterator = popIterator(); boolean handled = false; boolean result = false; while (iterator.hasPrevious()) { Command previous = iterator.previous(); if (previous instanceof Filter) { try { result = ((Filter) previous).postProcess(context, exception); if (result) { handled = true;//from w w w .ja va 2 s . co m } } catch (Exception e) { // Silently ignore } } } return handled; }
From source file:org.hyperic.hq.measurement.galerts.ResourceMetricTracker.java
/** * If there are any newer (or with the same timestamp) tracked metrics than * this one that just came in, remove those newer tracked metrics. This * accounts for the backfilled case where the backfilled metrics reported * one value, but then the agent starts reporting again with the "real" * values that should preempt the backfilled values. * //from w w w . j a va 2s . com * @param value The metric value that just came in. */ private void removeNewerTrackedMetrics(MetricValue value) { if (_chronOrderedValues.isEmpty()) { return; } if (value.getTimestamp() <= ((MetricValue) _chronOrderedValues.getLast()).getTimestamp()) { _log.debug("Removing tracked metrics newer than timestamp=" + value.getTimestamp()); ListIterator iter = _chronOrderedValues.listIterator(_chronOrderedValues.size()); while (iter.hasPrevious()) { MetricValue trackedValue = (MetricValue) iter.previous(); if (trackedValue.getTimestamp() >= value.getTimestamp()) { iter.remove(); } else { return; } } } }
From source file:br.com.esign.logistics.core.Route.java
public Route opposite() { if (routes == null || routes.isEmpty()) routes = Arrays.asList(new Route[] { this }); int size = routes.size(); if (size == 1) { return new Route(getDestination(), getOrigin(), getDistance()); } else {//w w w. ja v a 2 s. c o m List<Route> oppositeRoutes = new ArrayList<>(size); ListIterator<Route> iterator = routes.listIterator(size); while (iterator.hasPrevious()) { oppositeRoutes.add(iterator.previous().opposite()); } return new Route(oppositeRoutes); } }