List of usage examples for java.util ListIterator next
E next();
From source file:com.projity.pm.assignment.HasAssignmentsImpl.java
public void forEachInterval(Closure visitor, Object type, WorkCalendar workCalendar) { NonGroupedCalculatedValues calculatedValues = new NonGroupedCalculatedValues(false, 0); ListIterator i = assignments.listIterator(); Assignment assignment = null;//from w w w .ja v a2s . co m while (i.hasNext()) { // add in all child groups assignment = (Assignment) i.next(); barCallback.setWorkCalendar(assignment.getEffectiveWorkCalendar()); // use this assignments cal because it might work on off calendar time assignment.calcDataBetween(type, null, calculatedValues); } calculatedValues.makeContiguousNonZero(barCallback, workCalendar); //calculatedValues.dump(); }
From source file:vteaexploration.plottools.panels.XYChartPanel.java
private double getRangeofData(ArrayList alVolumes, int x) { ListIterator litr = alVolumes.listIterator(); ArrayList<Number> al = new ArrayList<Number>(); Number low = 0;//from w ww. ja va2s . c o m Number high = 0; Number test; while (litr.hasNext()) { try { MicroObjectModel volume = (MicroObjectModel) litr.next(); Number Corrected = processPosition(x, volume); al.add(Corrected); if (Corrected.floatValue() < low.floatValue()) { low = Corrected; } if (Corrected.floatValue() > high.floatValue()) { high = Corrected; } } catch (NullPointerException e) { } } return high.longValue() - low.longValue(); }
From source file:com.google.gwt.emultest.java.util.ListTestBase.java
public void testListIteratorHasNextHasPreviousAndIndexes() { List l = makeEmptyList();/*from w w w . j a v a 2 s . c om*/ ListIterator i = l.listIterator(); assertFalse(i.hasNext()); assertFalse(i.hasPrevious()); i.add(new Integer(1)); assertEquals(1, i.nextIndex()); assertEquals(0, i.previousIndex()); i = l.listIterator(); assertEquals(0, i.nextIndex()); assertEquals(-1, i.previousIndex()); assertTrue(i.hasNext()); assertFalse(i.hasPrevious()); i.next(); assertEquals(1, i.nextIndex()); assertEquals(0, i.previousIndex()); assertFalse(i.hasNext()); assertTrue(i.hasPrevious()); }
From source file:io.github.swagger2markup.markup.builder.internal.confluenceMarkup.ConfluenceMarkupBuilder.java
@Override public MarkupDocBuilder tableWithColumnSpecs(List<MarkupTableColumn> columnSpecs, List<List<String>> cells) { Validate.notEmpty(cells, "cells must not be null"); documentBuilder.append(newLine);// w w w .j av a2 s.c o m if (columnSpecs != null && !columnSpecs.isEmpty()) { documentBuilder.append("||"); for (MarkupTableColumn column : columnSpecs) { documentBuilder.append(formatCellContent(defaultString(column.header))).append("||"); } documentBuilder.append(newLine); } for (List<String> row : cells) { documentBuilder.append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); ListIterator<String> cellIterator = row.listIterator(); while (cellIterator.hasNext()) { int cellIndex = cellIterator.nextIndex(); if (columnSpecs != null && columnSpecs.size() > cellIndex && columnSpecs.get(cellIndex).headerColumn) documentBuilder.append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); documentBuilder.append(formatCellContent(cellIterator.next())) .append(ConfluenceMarkup.TABLE_COLUMN_DELIMITER); } documentBuilder.append(newLine); } documentBuilder.append(newLine); return this; }
From source file:chat.viska.commons.pipelines.Pipeline.java
@SchedulerSupport(SchedulerSupport.IO) public Maybe<Pipe> replace(final Pipe oldPipe, final Pipe newPipe) { return Maybe.fromCallable(() -> { pipeLock.writeLock().lockInterruptibly(); try {//from www .ja v a2 s .c om final ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(oldPipe); if (iterator == null) { throw new NoSuchElementException(); } Map.Entry<String, Pipe> oldEntry = iterator.next(); iterator.set(new AbstractMap.SimpleImmutableEntry<>(oldEntry.getKey(), newPipe)); oldPipe.onRemovedFromPipeline(this); newPipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } return oldPipe; }).subscribeOn(Schedulers.io()); }
From source file:org.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel.java
/** * Build the data for the chart/*from ww w . j a v a 2 s. com*/ * * @return */ private JFreeChart getChartData() { // just need the list final List<CourseGrade> courseGrades = this.courseGradeMap.values().stream().collect(Collectors.toList()); // get current grading schema (from model so that it reflects current state) final List<GbGradingSchemaEntry> gradingSchemaEntries = this.model.getObject().getGradingSchemaEntries(); final DefaultCategoryDataset data = new DefaultCategoryDataset(); final Map<String, Integer> counts = new LinkedHashMap<>(); // must retain order so graph can be printed correctly // add all schema entries (these will be sorted according to {@link LetterGradeComparator}) gradingSchemaEntries.forEach(e -> { counts.put(e.getGrade(), 0); }); // now add the count of each course grade for those schema entries this.total = 0; for (final CourseGrade g : courseGrades) { // course grade may not be released so we have to skip it if (StringUtils.isBlank(g.getMappedGrade())) { continue; } counts.put(g.getMappedGrade(), counts.get(g.getMappedGrade()) + 1); this.total++; } // build the data final ListIterator<String> iter = new ArrayList<>(counts.keySet()).listIterator(0); while (iter.hasNext()) { final String c = iter.next(); data.addValue(counts.get(c), "count", c); } final JFreeChart chart = ChartFactory.createBarChart(null, // the chart title getString("settingspage.gradingschema.chart.xaxis"), // the label for the category (x) axis getString("label.statistics.chart.yaxis"), // the label for the value (y) axis data, // the dataset for the chart PlotOrientation.HORIZONTAL, // the plot orientation false, // show legend true, // show tooltips false); // show urls chart.getCategoryPlot().setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); chart.setBorderVisible(false); chart.setAntiAlias(false); final CategoryPlot plot = chart.getCategoryPlot(); final BarRenderer br = (BarRenderer) plot.getRenderer(); br.setItemMargin(0); br.setMinimumBarLength(0.05); br.setMaximumBarWidth(0.1); br.setSeriesPaint(0, new Color(51, 122, 183)); br.setBarPainter(new StandardBarPainter()); br.setShadowPaint(new Color(220, 220, 220)); BarRenderer.setDefaultShadowsVisible(true); br.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(getString("label.statistics.chart.tooltip"), NumberFormat.getInstance())); plot.setRenderer(br); // show only integers in the count axis plot.getRangeAxis().setStandardTickUnits(new NumberTickUnitSource(true)); // make x-axis wide enough so we don't get ... suffix plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(2.0f); plot.setBackgroundPaint(Color.white); chart.setTitle(getString("settingspage.gradingschema.chart.heading")); return chart; }
From source file:com.thomaztwofast.uhc.GameManager.java
private boolean isRecipeEx(ItemStack a) { ListIterator<Recipe> b = gA.getServer().getRecipesFor(a).listIterator(); while (b.hasNext()) { if (b.next().getResult().equals(a)) { return true; }/*from w ww .ja va 2 s . c o m*/ } return false; }
From source file:com.smi.travel.monitor.MonitorAmadeus.java
@Override void buildBookingFlight(BookingAirline bAir) { MAmadeus flightNumber = amadeusMap.get("flight number"); String ticketDateS = getField("ticket date"); String year = "20" + ticketDateS.substring(0, 2); //Check how many rows there is. ArrayList<String> lines = (ArrayList<String>) sectionData.get(flightNumber.getSection()); // System.out.println("Flight " + lines.size()); ListIterator<String> iterator = lines.listIterator(); BookingFlight bf = null;/*from w w w. ja v a2s . c om*/ while (iterator.hasNext()) { String line = iterator.next(); if (isVoidFlight(line)) { System.out.println("Skipping - " + line); continue; } // System.out.println("Line " + line); String flightNo = getField("flight number", line); flightNo = bAir.getAirlineCode() + flightNo.replaceAll("\\s+", ""); String sourceCode = getField("source", line); String desCode = getField("destination", line); String deptDateS = getField("departure date", line); String arrivalDateS = getField("arrive date", line); Date deptDate = null; if (!deptDateS.isEmpty()) { deptDate = convertStringToDate(deptDateS + year); } Date arrvDate = null; if (!arrivalDateS.isEmpty()) { arrvDate = convertStringToDate(arrivalDateS + year); } String deptTime = getField("departure time", line); String arrvTime = getField("arrive time", line); String flightClass = getField("flight class", line); bf = new BookingFlight(flightNo, sourceCode, desCode, deptDate, arrvDate, flightClass); bf.setDepartTime(deptTime); bf.setArriveTime(arrvTime); bf.setAdCost(0); bf.setAdPrice(0); bf.setAdTax(0); bf.setChCost(0); bf.setChPrice(0); bf.setChTax(0); bf.setInCost(0); bf.setInPrice(0); bf.setInTax(0); bf.setOtCost(0); bf.setOtPrice(0); bf.setOtTax(0); bAir.getBookingFlights().add(bf); bf.setBookingAirline(bAir); } }
From source file:edu.iu.daal_nn.NNDaalCollectiveMapper.java
private Tensor getTensorHDFS(DaalContext daal_Context, Configuration conf, String inputFiles, int vectorSize, int numRows) throws IOException { Path inputFilePaths = new Path(inputFiles); List<String> inputFileList = new LinkedList<>(); try {/*from w w w. java 2 s .c o m*/ FileSystem fs = inputFilePaths.getFileSystem(conf); RemoteIterator<LocatedFileStatus> iterator = fs.listFiles(inputFilePaths, true); while (iterator.hasNext()) { String name = iterator.next().getPath().toUri().toString(); inputFileList.add(name); } } catch (IOException e) { LOG.error("Fail to get test files", e); } int dataSize = vectorSize * numRows; // float[] data = new float[dataSize]; double[] data = new double[dataSize]; long[] dims = { numRows, vectorSize }; int index = 0; FSDataInputStream in = null; //loop over all the files in the list ListIterator<String> file_itr = inputFileList.listIterator(); while (file_itr.hasNext()) { String file_name = file_itr.next(); LOG.info("read in file name: " + file_name); Path file_path = new Path(file_name); try { FileSystem fs = file_path.getFileSystem(conf); in = fs.open(file_path); } catch (Exception e) { LOG.error("Fail to open file " + e.toString()); return null; } //read file content while (true) { String line = in.readLine(); if (line == null) break; String[] lineData = line.split(","); for (int t = 0; t < lineData.length; t++) { if (index < dataSize) { // data[index] = Float.parseFloat(lineData[t]); data[index] = Double.parseDouble(lineData[t]); index++; } else { LOG.error("Incorrect size of file: dataSize: " + dataSize + "; index val: " + index); return null; } } } in.close(); } if (index != dataSize) { LOG.error("Incorrect total size of file: dataSize: " + dataSize + "; index val: " + index); return null; } //debug check the vals of data // for(int p=0;p<60;p++) // LOG.info("data at: " + p + " is: " + data[p]); Tensor predictionData = new HomogenTensor(daal_Context, dims, data); return predictionData; }
From source file:eu.europa.esig.dss.asic.validation.ASiCContainerValidator.java
private void analyseEntries() throws DSSException { ZipInputStream asicsInputStream = null; try {/*from w w w.j a va 2s.co m*/ MimeType asicEntryMimeType = null; asicsInputStream = new ZipInputStream(asicContainer.openStream()); // The underlying stream is closed by the parent (asicsInputStream). for (ZipEntry entry = asicsInputStream.getNextEntry(); entry != null; entry = asicsInputStream .getNextEntry()) { String entryName = entry.getName(); if (isCAdES(entryName)) { if (xadesSigned) { throw new DSSNotETSICompliantException( DSSNotETSICompliantException.MSG.DIFFERENT_SIGNATURE_FORMATS); } addEntryElement(entryName, signatures, asicsInputStream); cadesSigned = true; } else if (isXAdES(entryName)) { if (cadesSigned) { throw new DSSNotETSICompliantException( DSSNotETSICompliantException.MSG.DIFFERENT_SIGNATURE_FORMATS); } addEntryElement(entryName, signatures, asicsInputStream); xadesSigned = true; } else if (isTimestamp(entryName)) { addEntryElement(entryName, signatures, asicsInputStream); timestamped = true; } else if (isASiCManifest(entryName)) { addAsicManifestEntryElement(entryName, detachedContents, asicsInputStream); } else if (isManifest(entryName)) { addEntryElement(entryName, detachedContents, asicsInputStream); } else if (isContainer(entryName)) { addEntryElement(entryName, detachedContents, asicsInputStream); } else if (isMetadata(entryName)) { addEntryElement(entryName, detachedContents, asicsInputStream); } else if (isMimetype(entryName)) { final DSSDocument mimeType = addEntryElement(entryName, detachedContents, asicsInputStream); asicEntryMimeType = getMimeType(mimeType); } else if (entryName.indexOf("/") == -1) { addEntryElement(entryName, detachedContents, asicsInputStream); } else if (entryName.endsWith("/")) { // Folder continue; } else { addEntryElement(entryName, detachedContents, asicsInputStream); } } asicMimeType = determinateAsicMimeType(asicContainer.getMimeType(), asicEntryMimeType); if (MimeType.ASICS == asicMimeType) { final ListIterator<DSSDocument> dssDocumentListIterator = detachedContents.listIterator(); while (dssDocumentListIterator.hasNext()) { final DSSDocument dssDocument = dssDocumentListIterator.next(); final String detachedContentName = dssDocument.getName(); if ("mimetype".equals(detachedContentName)) { dssDocumentListIterator.remove(); } else if (detachedContentName.indexOf('/') != -1) { dssDocumentListIterator.remove(); } } } } catch (Exception e) { if (e instanceof DSSException) { throw (DSSException) e; } throw new DSSException(e); } finally { IOUtils.closeQuietly(asicsInputStream); } }