List of usage examples for java.util ListIterator previous
E previous();
From source file:org.flowable.cmmn.converter.ConversionHelper.java
public void addEntryCriterionToCurrentElement(Criterion entryCriterion) { addEntryCriterion(entryCriterion);/*from w w w .j ava 2 s . c o m*/ ListIterator<CmmnElement> iterator = currentCmmnElements.listIterator(currentCmmnElements.size()); HasEntryCriteria hasEntryCriteria = null; while (hasEntryCriteria == null && iterator.hasPrevious()) { CmmnElement cmmnElement = iterator.previous(); if (cmmnElement instanceof HasEntryCriteria) { hasEntryCriteria = (HasEntryCriteria) cmmnElement; } } if (hasEntryCriteria != null) { if (StringUtils.isEmpty(entryCriterion.getId())) { // An id is expected by the evaluation algorithm, so setting an internal one if there isn't one entryCriterion.setId("entryCriterion_" + (hasEntryCriteria.getEntryCriteria().size() + 1)); } entryCriterion.setAttachedToRefId(hasEntryCriteria.getId()); hasEntryCriteria.getEntryCriteria().add(entryCriterion); } else { throw new FlowableException("Cannot add an entry criteria " + entryCriterion.getId() + " no matching plan item found to attach it to"); } }
From source file:org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun.java
/** * Inserts paragraph break before all close group marks. * * @throws IOException for I/O problems * @return The paragraph break element/* w ww. j av a2s .c om*/ */ public RtfParagraphBreak addParagraphBreak() throws IOException { // get copy of children list List children = getChildren(); Stack tmp = new Stack(); RtfParagraphBreak par = null; // delete all previous CloseGroupMark int deletedCloseGroupCount = 0; ListIterator lit = children.listIterator(children.size()); while (lit.hasPrevious() && (lit.previous() instanceof RtfCloseGroupMark)) { tmp.push(Integer.valueOf(((RtfCloseGroupMark) lit.next()).getBreakType())); lit.remove(); deletedCloseGroupCount++; } if (children.size() != 0) { // add paragraph break and restore all deleted close group marks setChildren(children); par = new RtfParagraphBreak(this, writer); for (int i = 0; i < deletedCloseGroupCount; i++) { addCloseGroupMark(((Integer) tmp.pop()).intValue()); } } return par; }
From source file:com.numenta.taurus.instance.InstanceDetailPageFragment.java
void updateServerHeader() { if (_chartData == null) { return;/* w w w. j a v a 2s.c o m*/ } if (_instanceChartFrag == null) { return; } // Update server header _instanceChartFrag.setChartData(_chartData); // Update time slider Date endDate = _chartData.getEndDate(); long endTime; if (endDate == null) { endTime = System.currentTimeMillis(); } else { endTime = endDate.getTime(); } _timeView.setAggregation(_chartData.getAggregation()); _timeView.setEndDate(endTime); // Check if need to collapse to market hours if (_collapseAfterHours) { EnumSet<MetricType> anomalousMetrics = _chartData.getAnomalousMetrics(); if (anomalousMetrics.contains(MetricType.TwitterVolume)) { // Collapse to market hours if twitter anomalies occurred during market hours MarketCalendar marketCalendar = TaurusApplication.getMarketCalendar(); boolean collapsed = true; // Check if is there any twitter anomaly on the last visible bars List<Pair<Long, Float>> data = _chartData.getData(); ListIterator<Pair<Long, Float>> iterator = data.listIterator(data.size()); for (int i = 0; i < TaurusApplication.getTotalBarsOnChart() && iterator.hasPrevious(); i++) { Pair<Long, Float> value = iterator.previous(); if (value != null && value.second != null && !Float.isNaN(value.second)) { double scaled = DataUtils.logScale(value.second); if (scaled >= TaurusApplication.getYellowBarFloor() && !marketCalendar.isOpen(value.first)) { // Found anomaly, don't collapse collapsed = false; break; } } } _marketHoursCheckbox.setChecked(collapsed); } else { // Collapse to market hours if we only have stock anomalies _marketHoursCheckbox.setChecked(true); } // Prevent collapsing during scroll _collapseAfterHours = false; } }
From source file:org.netflux.core.Record.java
/** * Removes from this record all the field metadata and all the fields with names included in the supplied collection. * // ww w . j a v a 2 s.c o m * @param fieldNames the names of the field metadata and fields to remove. * @throws NullPointerException if the specified collection is <code>null</code>. */ public void remove(Collection<String> fieldNames) { List<String> fieldsToRemove = new LinkedList<String>(this.metadata.getFieldNames()); fieldsToRemove.retainAll(fieldNames); ListIterator<String> fieldIndexIterator = fieldsToRemove.listIterator(fieldsToRemove.size()); while (fieldIndexIterator.hasPrevious()) { this.data.remove(fieldIndexIterator.previous()); } this.metadata.remove(fieldNames); }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.WindowManager.java
private void dispatchObjectEventControls(ObjectEvent objectEvent) { List<Control> cursors = null; synchronized (cursorHandler) { cursors = cursorHandler.getCursors(); }//from w w w . j a v a2 s. c o m Control activeControl = null; LinkedList<ObjectObserverEvent> consumedOoes = new LinkedList<ObjectObserverEvent>(); ListIterator<Control> listIterator = controls.listIterator(controls.size()); while (listIterator.hasPrevious()) { Control control = listIterator.previous(); if ((!control.isVisible()) || (cursors.contains(control))) { continue; } ObjectEvent copiedObjectEvent = objectEvent.copy(); // check how many of Ooes are within this control LinkedList<ObjectObserverEvent> ooes = new LinkedList<ObjectObserverEvent>(); for (ObjectObserverEvent ooe : objectEvent.getObjectObserverEvents()) { if (!consumedOoes.contains(ooe)) { if (control.isWithin(new Point(ooe.getX(), ooe.getY()))) { ooes.add(ooe); consumedOoes.add(ooe); } } } copiedObjectEvent.setObjectObserverEvents(ooes); ObjectObserverEvent targetOoe = objectEvent.getTargetObjectObserverEvent(); if (ooes.contains(targetOoe)) { activeControl = control; } else { targetOoe = null; } copiedObjectEvent.setTargetObjectObserverEvent(targetOoe); //log.debug("Ooes: "+ooes.size()); if (ooes.size() > 0) { log.debug(control.getClass().toString() + "[" + control.getPosition().toString() + "]" + ": Sending " + ooes.size() + " ooes"); control.dispatchEvent(copiedObjectEvent); } } if ((activeControl != null) && (!activeControl.equals(backgroundControl))) { if (!activeControl.equals(controls.getLast())) { controls.remove(activeControl); controls.add(activeControl); } } }
From source file:eu.scidipes.toolkits.pawebapp.web.ItemsController.java
public String editItemHelper(final List<Form> formSubset, final Form form, final Model model, final RedirectAttributes redirectAttrs) { final ListIterator<Form> formIterator = formSubset.listIterator(); while (formIterator.hasNext()) { final Form theForm = formIterator.next(); if (theForm.equals(form)) { /* Jump back: */ formIterator.previous(); if (formIterator.hasPrevious()) { model.addAttribute("previous", Integer.valueOf(formSubset.get(formIterator.previousIndex()).getFormID().intValue())); }/*from ww w . j a v a 2s . c om*/ /* Jump forward: */ formIterator.next(); if (formIterator.hasNext()) { model.addAttribute("next", Integer.valueOf(formSubset.get(formIterator.nextIndex()).getFormID().intValue())); } } } model.addAttribute("saveAction", EDIT); final CurationPersistentIdentifier manifestCPID = form.getManifestCPID(); final Map<DatasetRIL, Set<CoreRIType>> rilMembership = new HashMap<>(); /* Fetch the current RIL membership for this form instance: */ for (final DatasetRIL dsRIL : form.getParentBundle().getRils()) { final RepresentationInformation[] repInfo = dsRIL.getRil().getRepresentationInformationChildren(); for (final RepresentationInformation coreRI : repInfo) { if (coreRI.getRepresentationInformation() instanceof RepInfoGroup) { final RepInfoGroup repInfoGroup = (RepInfoGroup) coreRI.getRepresentationInformation(); for (final RepresentationInformation ri : repInfoGroup.getRepresentationInformationChildren()) { if (ri.getCpid().equals(manifestCPID)) { if (!rilMembership.containsKey(dsRIL)) { rilMembership.put(dsRIL, new HashSet<CoreRIType>()); } rilMembership.get(dsRIL).add(CoreRIType.fromClass(coreRI.getClass())); } } } } } model.addAttribute("rilMembership", rilMembership); model.addAttribute("form", form); return "datasets/items/edit"; }
From source file:org.apache.stratos.autoscaler.service.util.IaasContext.java
/** * This will return the public IP of the node which is belong to the * requesting domain, sub domain and which is the most recently created. If it cannot find a * matching public IP, this will return <code>null</code>. * @param domain service domain. /*w ww . j a va2 s . co m*/ * @param subDomain service sub domain. * @return the public IP of the node */ public String getLastMatchingPublicIp(String domain, String subDomain) { InstanceContext ctx = getInstanceContext(domain, subDomain); if (ctx == null) { return null; } // iterate in reverse order ListIterator<String> iter = new ArrayList<String>(ctx.getNodeIdToIpMap().keySet()) .listIterator(ctx.getNodeIdToIpMap().size()); while (iter.hasPrevious()) { return ctx.getNodeIdToIpMap().get(iter.previous()); } return null; // // traverse from the last entry of the map // ListIterator<Map.Entry<String, String>> iter = // new ArrayList<Entry<String, String>>(publicIpToDomainMap.entrySet()). // listIterator(publicIpToDomainMap.size()); // // while (iter.hasPrevious()) { // Map.Entry<String, String> entry = iter.previous(); // if (entry.getValue().equals(domain)) { // return entry.getKey(); // } // } // // return null; }
From source file:org.xchain.impl.ChainImpl.java
public boolean execute(JXPathContext context) throws Exception { // Verify our parameters if (context == null) { throw new IllegalArgumentException(); }//from ww w .ja va 2s . co m // Execute the commands in this list until one returns true // or throws an exception boolean saveResult = false; Exception saveException = null; ListIterator<Command> iterator = commandList.listIterator(); while (iterator.hasNext()) { try { saveResult = iterator.next().execute(context); if (saveResult) { break; } } catch (Exception e) { saveException = e; break; } } boolean handled = false; boolean result = false; while (iterator.hasPrevious()) { Object previous = iterator.previous(); if (previous instanceof Filter) { try { result = ((Filter) previous).postProcess(context, saveException); if (result) { handled = true; } } catch (Exception e) { // Silently ignore } } } // Return the exception or result state from the last execute() if ((saveException != null) && !handled) { throw saveException; } else { return (saveResult); } }
From source file:org.jboss.set.aphrodite.repository.services.github.GithubPullRequestHomeService.java
private GHPullRequestReview findReviewStateByUser(PullRequest pullRequest, GHUser user) { URL url = pullRequest.getURL(); int pullRequestId = Integer.parseInt(pullRequest.getId()); String repositoryId = createRepositoryIdFromUrl(url); try {//from w ww.j av a 2 s. com GHRepository repository = github.getRepository(repositoryId); GHPullRequest ghPullRequest = repository.getPullRequest(pullRequestId); List<GHPullRequestReview> reviews = ghPullRequest.listReviews().asList(); ListIterator<GHPullRequestReview> li = reviews.listIterator(reviews.size()); // Iterate in reverse. created date and updated date are always Null, Is this really safe? while (li.hasPrevious()) { GHPullRequestReview review = li.previous(); if (review.getUser().equals(user)) return review; } } catch (IOException e) { Utils.logException(LOG, e); } return null; }
From source file:org.apache.cocoon.components.pipeline.impl.CachingPointProcessingPipeline.java
/** * Cache longest cacheable path plus cache points. *///from ww w . ja v a 2 s . c o m protected void cacheResults(Environment environment, OutputStream os) throws Exception { if (this.toCacheKey != null) { if (this.cacheCompleteResponse) { if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("Cached: caching complete response; pSisze" + this.toCacheKey.size() + " Key " + this.toCacheKey); } CachedResponse response = new CachedResponse(this.toCacheSourceValidities, ((CachingOutputStream) os).getContent()); response.setContentType(environment.getContentType()); this.cache.store(this.toCacheKey.copy(), response); // // Scan back along the pipelineCacheKey for // for any cachepoint(s) // this.toCacheKey.removeUntilCachePoint(); // // adjust the validities object // to reflect the new length of the pipeline cache key. // // REVISIT: Is it enough to simply reduce the length of the validities array? // if (this.toCacheKey.size() > 0) { SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()]; System.arraycopy(this.toCacheSourceValidities, 0, copy, 0, copy.length); this.toCacheSourceValidities = copy; } } if (this.toCacheKey.size() > 0) { ListIterator itt = this.xmlSerializerArray.listIterator(this.xmlSerializerArray.size()); while (itt.hasPrevious()) { XMLSerializer serializer = (XMLSerializer) itt.previous(); CachedResponse response = new CachedResponse(this.toCacheSourceValidities, (byte[]) serializer.getSAXFragment()); this.cache.store(this.toCacheKey.copy(), response); if (this.getLogger().isDebugEnabled()) { this.getLogger().debug("Caching results for the following key: " + this.toCacheKey); } // // Check for further cachepoints // toCacheKey.removeUntilCachePoint(); if (this.toCacheKey.size() == 0) // no cachePoint found in key break; // // re-calculate validities array // SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()]; System.arraycopy(this.toCacheSourceValidities, 0, copy, 0, copy.length); this.toCacheSourceValidities = copy; } //end serializer loop } } }