List of usage examples for java.util ListIterator hasPrevious
boolean hasPrevious();
From source file:arun.com.chromer.webheads.WebHeadService.java
private void openContextActivity() { final ListIterator<String> it = new ArrayList<>(webHeads.keySet()).listIterator(webHeads.size()); final ArrayList<Website> websites = new ArrayList<>(); while (it.hasPrevious()) { final String key = it.previous(); final WebHead webHead = webHeads.get(key); if (webHead != null) { websites.add(webHead.getWebsite()); }//from w w w .j a va 2 s. c o m } ContextActivityHelper.open(this, websites); }
From source file:org.saiku.reporting.core.builder.SimpleCrosstabBuilder.java
public void build() throws ReportProcessingException { /*/*from w w w. j av a 2 s . co m*/ * Generate the Details-Row */ final CrosstabCellBody cellBody = new CrosstabCellBody(); //--------------------------------- DetailsHeader detailsHeader = new DetailsHeader(); detailsHeader.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); detailsHeader.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_ROW); ArrayList<FieldDefinition> detailFieldDefinitions = this.reportSpecification.getFieldDefinitions(); final float[] computedWidth = ReportBuilderUtil.correctFieldWidths(detailFieldDefinitions, definition); DetailsHeaderBuilder detailsHeaderBuilder = new DetailsHeaderBuilder(attributeContext, definition, flowController, reportSpecification); int j = 0; for (FieldDefinition field : detailFieldDefinitions) { detailsHeaderBuilder.build(detailsHeader, field, computedWidth[j], j); j++; } cellBody.setHeader(detailsHeader); //--------------------------------- cellBody.addElement(createCell(null, INNERMOST, INNERMOST)); GroupBody body = cellBody; /* * Generate the Column-Groups */ ArrayList<GroupDefinition> groupDefinitions = this.reportSpecification.getGroupDefinitions(); ListIterator<GroupDefinition> colGrpItr = groupDefinitions.listIterator(groupDefinitions.size()); while (colGrpItr.hasPrevious()) { final GroupDefinition colGrp = colGrpItr.previous(); if (colGrp.getType().equals(GroupType.CT_COLUMN)) { final CrosstabColumnGroup columnGroup = new CrosstabColumnGroup(body); columnGroup.setName("Group " + colGrp.getGroupName()); columnGroup.setField(colGrp.getFieldId()); /* 1) Chrosstab Header 2) Title Header 3) Summary Header */ final List<RootBandFormat> headerFormats = colGrp.getHeaderFormats(); int index = groupDefinitions.indexOf(colGrp); String uid = RPT_GROUP_HEADER + index; String htmlClass = "saiku " + uid; RootBandFormat headerFormat = null; if (headerFormats.size() < 1 || headerFormats.get(0) == null) { headerFormat = new RootBandFormat(); headerFormats.add(0, headerFormat); } else { headerFormat = headerFormats.get(0); } Element headerItem = createFieldItem(colGrp.getFieldId()); //MergeFormatUtil.mergeElementFormats(headerItem, headerFormat); MergeFormatUtil.mergeElementFormats(columnGroup.getHeader(), headerFormat); headerItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-0"); headerItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-0"); //Is this used for style definitions? headerItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Xml.ID, uid + "-0"); columnGroup.getHeader().addElement(headerItem); columnGroup.getHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); columnGroup.getHeader().getStyle().setStyleProperty(TextStyleKeys.BOLD, Boolean.TRUE); RootBandFormat titleFormat = null; if (headerFormats.size() < 2 || headerFormats.get(1) == null) { titleFormat = new RootBandFormat(); headerFormats.add(1, titleFormat); } else { titleFormat = headerFormats.get(1); } String titleLabel = titleFormat.getLabel() != null ? titleFormat.getLabel() : colGrp.getDisplayName(); Element titleItem = createLabel(titleLabel); MergeFormatUtil.mergeElementFormats(titleItem, titleFormat); titleItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-1"); titleItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-1"); columnGroup.getTitleHeader().addElement(titleItem); columnGroup.getTitleHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); RootBandFormat summaryFormat = null; if (headerFormats.size() < 3 || headerFormats.get(2) == null) { summaryFormat = new RootBandFormat(); headerFormats.add(1, summaryFormat); } else { summaryFormat = headerFormats.get(2); } String summaryLabel = summaryFormat.getLabel() != null ? summaryFormat.getLabel() : "Total"; Element summaryItem = createLabel(summaryLabel); MergeFormatUtil.mergeElementFormats(summaryItem, summaryFormat); summaryItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-2"); summaryItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-2"); columnGroup.getSummaryHeader().addElement(summaryItem); columnGroup.getSummaryHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); columnGroup.setPrintSummary(colGrp.isPrintSummary()); if (colGrp.isPrintSummary()) { //create cell needs to be enhanced later to always pick the correct group combination for the //element formats final CrosstabCell cell = createCell("Group " + colGrp.getFieldId(), colGrp.getFieldId(), INNERMOST); cell.setColumnField(colGrp.getFieldId()); cell.setName(colGrp.getFieldId()); cellBody.addElement(cell); } body = new CrosstabColumnGroupBody(columnGroup); } } /* * Generate the Row-Groups */ ListIterator<GroupDefinition> rowGrpItr = groupDefinitions.listIterator(groupDefinitions.size()); while (rowGrpItr.hasPrevious()) { final GroupDefinition rowGrp = rowGrpItr.previous(); if (rowGrp.getType().equals(GroupType.CT_ROW)) { final CrosstabRowGroup rowGroup = new CrosstabRowGroup(body); int index = groupDefinitions.indexOf(rowGrp); String uid = RPT_GROUP_HEADER + index; String htmlClass = "saiku " + uid; rowGroup.setName("Group " + rowGrp.getGroupName()); rowGroup.setField(rowGrp.getFieldId()); final List<RootBandFormat> headerFormats = rowGrp.getHeaderFormats(); RootBandFormat headerFormat = null; if (headerFormats.size() < 1 || headerFormats.get(0) == null) { headerFormat = new RootBandFormat(); headerFormats.add(0, headerFormat); } else { headerFormat = headerFormats.get(0); } Element headerItem = createFieldItem(rowGrp.getFieldId()); //MergeFormatUtil.mergeElementFormats(headerItem, headerFormat); MergeFormatUtil.mergeElementFormats(rowGroup.getHeader(), headerFormat); headerItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-0"); headerItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-0"); rowGroup.getHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); rowGroup.getHeader().getStyle().setStyleProperty(TextStyleKeys.BOLD, Boolean.TRUE); rowGroup.getHeader().addElement(headerItem); RootBandFormat titleFormat = null; if (headerFormats.size() < 2 || headerFormats.get(1) == null) { titleFormat = new RootBandFormat(); headerFormats.add(1, titleFormat); } else { titleFormat = headerFormats.get(1); } String titleLabel = titleFormat.getLabel() != null ? titleFormat.getLabel() : rowGrp.getDisplayName(); Element titleItem = createLabel(titleLabel); MergeFormatUtil.mergeElementFormats(titleItem, titleFormat); titleItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-1"); titleItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-1"); rowGroup.getTitleHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); rowGroup.getTitleHeader().addElement(titleItem); RootBandFormat summaryFormat = null; if (headerFormats.size() < 3 || headerFormats.get(2) == null) { summaryFormat = new RootBandFormat(); headerFormats.add(1, summaryFormat); } else { summaryFormat = headerFormats.get(2); } String summaryLabel = summaryFormat.getLabel() != null ? summaryFormat.getLabel() : "Total"; Element summaryItem = createLabel(summaryLabel); MergeFormatUtil.mergeElementFormats(summaryItem, summaryFormat); summaryItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.STYLE_CLASS, htmlClass + "-2"); summaryItem.setAttribute(AttributeNames.Html.NAMESPACE, AttributeNames.Html.XML_ID, uid + "-2"); rowGroup.getSummaryHeader().getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, -100f); rowGroup.getSummaryHeader().addElement(summaryItem); rowGroup.setPrintSummary(rowGrp.isPrintSummary()); if (rowGrp.isPrintSummary()) { final CrosstabCell cell = createCell("Group " + rowGroup.getField(), INNERMOST, rowGrp.getFieldId()); cell.setRowField(rowGrp.getFieldId()); cell.setName(rowGrp.getFieldId()); cellBody.addElement(cell); ListIterator<GroupDefinition> colGrpItrInner = groupDefinitions .listIterator(groupDefinitions.size()); while (colGrpItrInner.hasPrevious()) { final GroupDefinition colGrp = colGrpItrInner.previous(); if (colGrp.getType().equals(GroupType.CT_COLUMN)) { if (colGrp.isPrintSummary()) { final CrosstabCell crosstabCell = createCell("Group " + rowGroup.getField(), colGrp.getFieldId(), rowGrp.getFieldId()); crosstabCell.setColumnField(colGrp.getFieldId()); crosstabCell.setRowField(rowGrp.getFieldId()); crosstabCell.setName(colGrp.getFieldId() + "," + rowGroup.getField()); cellBody.addElement(crosstabCell); } } } } body = new CrosstabRowGroupBody(rowGroup); } } /* * Let's ommit Other-Groups for now */ // At The end we need to wrap the generated stuff in a crosstabgroup and put it in the // report CrosstabGroup crosstabRootGroup = new CrosstabGroup(body); crosstabRootGroup.setPrintColumnTitleHeader(true); crosstabRootGroup.setPrintDetailsHeader(true); insertCrosstab(crosstabRootGroup); //remove all relational groups GroupUtils.removedUnusedTemplateGroups(0, definition); }
From source file:net.sourceforge.fenixedu.domain.degreeStructure.DegreeModule.java
public ICurricularRule getMostRecentActiveCurricularRule(final CurricularRuleType ruleType, final CourseGroup parentCourseGroup, final ExecutionYear executionYear) { final List<ICurricularRule> curricularRules = new ArrayList<ICurricularRule>( getCurricularRules(ruleType, parentCourseGroup, (ExecutionYear) null)); Collections.sort(curricularRules, ICurricularRule.COMPARATOR_BY_BEGIN); if (curricularRules.isEmpty()) { return null; }/*from w w w . j av a 2 s .c o m*/ if (executionYear == null) { final ListIterator<ICurricularRule> iter = curricularRules.listIterator(curricularRules.size()); while (iter.hasPrevious()) { final ICurricularRule curricularRule = iter.previous(); if (curricularRule.isActive()) { return curricularRule; } } return null; } ICurricularRule result = null; for (final ICurricularRule curricularRule : curricularRules) { if (curricularRule.isValid(executionYear)) { if (result != null) { // TODO: remove this throw when curricular rule ensures // that it can be only one active for execution period // and replace by: return curricularRule throw new DomainException( "error.degree.module.has.more.than.one.credits.limit.for.executionYear", getName()); } result = curricularRule; } } return result; }
From source file:org.commonjava.maven.ext.common.model.Project.java
private void resolveDeps(MavenSessionHandler session, List<Dependency> deps, boolean includeManagedDependencies, HashMap<ArtifactRef, Dependency> resolvedDependencies) throws ManipulationException { ListIterator<Dependency> iterator = deps.listIterator(deps.size()); // Iterate in reverse order so later deps take precedence while (iterator.hasPrevious()) { Dependency d = iterator.previous(); String g = PropertyResolver.resolveInheritedProperties(session, this, "${project.groupId}".equals(d.getGroupId()) ? getGroupId() : d.getGroupId()); String a = PropertyResolver.resolveInheritedProperties(session, this, "${project.artifactId}".equals(d.getArtifactId()) ? getArtifactId() : d.getArtifactId()); String v = PropertyResolver.resolveInheritedProperties(session, this, d.getVersion()); if (includeManagedDependencies && isEmpty(v)) { v = "*"; }// ww w. ja va2 s .c o m if (isNotEmpty(g) && isNotEmpty(a) && isNotEmpty(v)) { SimpleArtifactRef sar = new SimpleArtifactRef(g, a, v, d.getType(), d.getClassifier()); // If the GAVTC already exists within the map it means we have a duplicate entry. While Maven // technically allows this it does warn that this leads to unstable models. In PME case this breaks // the indexing as we don't have duplicate entries. Given they are exact matches, remove older duplicate. if (resolvedDependencies.containsKey(sar)) { logger.error("Found duplicate entry within dependency list. Key of {} and dependency {}", sar, d); iterator.remove(); } else { Dependency old = resolvedDependencies.put(sar, d); if (old != null) { logger.error( "Internal project dependency resolution failure ; replaced {} in store by {}:{}:{}.", old, g, a, v); throw new ManipulationException( "Internal project dependency resolution failure ; replaced " + old + " by " + d); } } } } }
From source file:org.commonjava.maven.ext.common.model.Project.java
private void resolvePlugins(MavenSessionHandler session, List<Plugin> plugins, HashMap<ProjectVersionRef, Plugin> resolvedPlugins) throws ManipulationException { ListIterator<Plugin> iterator = plugins.listIterator(plugins.size()); // Iterate in reverse order so later plugins take precedence while (iterator.hasPrevious()) { Plugin p = iterator.previous();// w ww .jav a 2 s . c o m String g = PropertyResolver.resolveInheritedProperties(session, this, "${project.groupId}".equals(p.getGroupId()) ? getGroupId() : p.getGroupId()); String a = PropertyResolver.resolveInheritedProperties(session, this, "${project.artifactId}".equals(p.getArtifactId()) ? getArtifactId() : p.getArtifactId()); String v = PropertyResolver.resolveInheritedProperties(session, this, p.getVersion()); // Its possible the internal plugin list is either abbreviated or empty. Attempt to fill in default values for // comparison purposes. if (isEmpty(g)) { g = PLUGIN_DEFAULTS.getDefaultGroupId(a); } // Theoretically we could default an empty v via PLUGIN_DEFAULTS.getDefaultVersion( g, a ) but // this means managed plugins would be included which confuses things. if (isNotEmpty(g) && isNotEmpty(a) && isNotEmpty(v)) { SimpleProjectVersionRef spv = new SimpleProjectVersionRef(g, a, v); // If the GAV already exists within the map it means we have a duplicate entry. While Maven // technically allows this it does warn that this leads to unstable models. In PME case this breaks // the indexing as we don't have duplicate entries. Given they are exact matches, remove older duplicate. if (resolvedPlugins.containsKey(spv)) { logger.error("Found duplicate entry within plugin list. Key of {} and plugin {}", spv, p); iterator.remove(); } else { Plugin old = resolvedPlugins.put(spv, p); if (old != null) { logger.error("Internal project plugin resolution failure ; replaced {} in store by {}.", old, spv); throw new ManipulationException( "Internal project plugin resolution failure ; replaced " + old + " by " + spv); } } } } }
From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java
/** * /*from ww w . j a v a 2s . c om*/ * Compares available fields and selected partition key fields for * hive input and output components. * */ public boolean compare_fields(TableItem[] items, List<String> sourceFieldsList) { ListIterator<String> t_itr, s_itr; boolean is_equal = true; List<String> target_fields = new ArrayList<String>(); if (items.length > 0) { for (TableItem tableItem : items) { target_fields.add((String) tableItem.getText()); } List<String> source_field = new ArrayList<String>(sourceFieldsList); t_itr = target_fields.listIterator(target_fields.size()); s_itr = source_field.listIterator(source_field.size()); while (t_itr.hasPrevious() & s_itr.hasPrevious()) { if (StringUtils.equals(s_itr.previous(), t_itr.previous())) { is_equal = true; } else { is_equal = false; break; } } } return is_equal; }
From source file:chat.viska.commons.pipelines.Pipeline.java
private void processObject(final Object obj, final boolean isReading) { final ListIterator<Map.Entry<String, Pipe>> iterator = isReading ? pipes.listIterator() : pipes.listIterator(pipes.size()); final List<Object> cache = new ArrayList<>(); cache.add(obj);//from w ww. j av a2 s . c o m while (isReading ? iterator.hasNext() : iterator.hasPrevious()) { final Pipe pipe = isReading ? iterator.next().getValue() : iterator.previous().getValue(); final List<Object> toForward = new ArrayList<>(); for (Object it : cache) { final List<Object> out = new ArrayList<>(); try { if (isReading) { pipe.onReading(this, it, out); } else { pipe.onWriting(this, it, out); } } catch (Exception cause) { processException(iterator, cause, isReading); return; } toForward.addAll(out); } if (toForward.size() == 0) { return; } else { cache.clear(); cache.addAll(toForward); } } for (Object it : cache) { try { if (isReading) { inboundStream.onNext((I) it); } else { outboundStream.onNext((O) it); } } catch (ClassCastException ex) { continue; } } }
From source file:org.apache.hadoop.hbase.regionserver.RegionMergeTransactionImpl.java
@Override public boolean rollback(final Server server, final RegionServerServices services) throws IOException { assert this.mergedRegionInfo != null; this.server = server; this.rsServices = services; // Coprocessor callback if (rsCoprocessorHost != null) { rsCoprocessorHost.preRollBackMerge(this.region_a, this.region_b); }/*from w w w .java2 s .c o m*/ boolean result = true; ListIterator<JournalEntry> iterator = this.journal.listIterator(this.journal.size()); // Iterate in reverse. while (iterator.hasPrevious()) { JournalEntry je = iterator.previous(); transition(je.getPhase(), true); switch (je.getPhase()) { case SET_MERGING: if (services != null && !services.reportRegionStateTransition(TransitionCode.MERGE_REVERTED, mergedRegionInfo, region_a.getRegionInfo(), region_b.getRegionInfo())) { return false; } break; case CREATED_MERGE_DIR: this.region_a.writestate.writesEnabled = true; this.region_b.writestate.writesEnabled = true; this.region_a.getRegionFileSystem().cleanupMergesDir(); break; case CLOSED_REGION_A: try { // So, this returns a seqid but if we just closed and then reopened, // we should be ok. On close, we flushed using sequenceid obtained // from hosting regionserver so no need to propagate the sequenceid // returned out of initialize below up into regionserver as we // normally do. this.region_a.initialize(); } catch (IOException e) { LOG.error("Failed rollbacking CLOSED_REGION_A of region " + region_a.getRegionInfo().getRegionNameAsString(), e); throw new RuntimeException(e); } break; case OFFLINED_REGION_A: if (services != null) services.addToOnlineRegions(this.region_a); break; case CLOSED_REGION_B: try { this.region_b.initialize(); } catch (IOException e) { LOG.error("Failed rollbacking CLOSED_REGION_A of region " + region_b.getRegionInfo().getRegionNameAsString(), e); throw new RuntimeException(e); } break; case OFFLINED_REGION_B: if (services != null) services.addToOnlineRegions(this.region_b); break; case STARTED_MERGED_REGION_CREATION: this.region_a.getRegionFileSystem().cleanupMergedRegion(this.mergedRegionInfo); break; case PONR: // We got to the point-of-no-return so we need to just abort. Return // immediately. Do not clean up created merged regions. return false; // Informational states only case STARTED: case PREPARED: case COMPLETED: break; default: throw new RuntimeException("Unhandled journal entry: " + je); } } // Coprocessor callback if (rsCoprocessorHost != null) { rsCoprocessorHost.postRollBackMerge(this.region_a, this.region_b); } return result; }
From source file:org.commonjava.maven.ext.manip.impl.DependencyManipulator.java
/** * This will load the remote overrides. It will first try to load any overrides that might have * been prepopulated by the REST scanner, failing that it will load from a remote POM file. * * @param state the dependency state//www . j ava 2s . c om * @return the loaded overrides * @throws ManipulationException if an error occurs. */ private Map<ArtifactRef, String> loadRemoteOverrides(final DependencyState state) throws ManipulationException { Map<ArtifactRef, String> overrides = state.getRemoteRESTOverrides(); if (overrides == null) { overrides = new LinkedHashMap<>(); final List<ProjectVersionRef> gavs = state.getRemoteBOMDepMgmt(); if (gavs == null || gavs.isEmpty()) { return overrides; } final ListIterator<ProjectVersionRef> iter = gavs.listIterator(gavs.size()); // Iterate in reverse order so that the first GAV in the list overwrites the last while (iter.hasPrevious()) { final ProjectVersionRef ref = iter.previous(); overrides.putAll(effectiveModelBuilder.getRemoteDependencyVersionOverrides(ref)); } } return overrides; }
From source file:org.springframework.ldap.core.DistinguishedName.java
private String format(boolean compact) { // empty path if (names.size() == 0) return ""; StringBuffer buffer = new StringBuffer(256); ListIterator i = names.listIterator(names.size()); while (i.hasPrevious()) { LdapRdn rdn = (LdapRdn) i.previous(); buffer.append(rdn.getLdapEncoded()); // add comma, except in last iteration if (i.hasPrevious()) { if (compact) { buffer.append(","); } else { buffer.append(", "); }//from ww w . j a va 2s . c o m } } return buffer.toString(); }