List of usage examples for java.util Iterator Iterator
Iterator
From source file:org.paxml.table.excel.ExcelRow.java
@Override protected Iterator<ICell> getAllCells() { Iterator<ICell> it;/*w w w .j a va 2s .c om*/ if (getTable().isCompact()) { it = new AbstractIteratorDecorator(row.cellIterator()) { @Override public Object next() { Cell cell = (Cell) getIterator().next(); return new ExcelCell(cell, ExcelRow.this); } }; } else { it = new Iterator<ICell>() { private int i; @Override public boolean hasNext() { return i < row.getLastCellNum(); } @Override public ICell next() { return getCell(i++); } @Override public void remove() { Cell c = row.getCell(i); if (c != null) { row.removeCell(c); } } }; } return it; }
From source file:com.github.jillesvangurp.osm2geojson.OsmBlobIterable.java
@Override public Iterator<String> iterator() { final Iterator<String> it = lineIterable.iterator(); return new Iterator<String>() { String next = null;/* www . ja va2s .c om*/ StringBuilder buf = new StringBuilder(); @Override public boolean hasNext() { if (next != null) { return true; } else { String line; while (it.hasNext() && next == null) { line = it.next(); if (line.length() > 0) { String stripped = StringUtils.strip(line); if (stripped.startsWith("<node")) { buf.delete(0, buf.length()); buf.append(line); if (!fastEndsWith(stripped, "/>")) { while (!fastEndsWith(StringUtils.strip(line), "</node>")) { line = it.next(); buf.append(line); } } next = StringUtils.strip(buf.toString()); } else if (stripped.startsWith("<way")) { buf.delete(0, buf.length()); buf.append(line); if (!fastEndsWith(line, "/>")) { while (!fastEndsWith(StringUtils.strip(line), "</way>")) { line = it.next(); buf.append(line); } } next = StringUtils.strip(buf.toString()); } else if (stripped.startsWith("<relation")) { buf.delete(0, buf.length()); buf.append(line); if (!fastEndsWith(line, "/>")) { while (!fastEndsWith(StringUtils.strip(line), "</relation>")) { line = it.next(); buf.append(line); } } next = StringUtils.strip(buf.toString()); } } } return next != null; } } @Override public String next() { if (hasNext()) { String result = next; next = null; return result; } else { throw new NoSuchElementException(); } } @Override public void remove() { throw new UnsupportedOperationException("Remove is not supported"); } }; }
From source file:org.nuxeo.connect.tools.report.viewer.ThreadDumpPrinter.java
public Iterator<ThreadInfo> iteratorOf() throws IOException { return new Iterator<ThreadInfo>() { Iterator<JsonNode> nodes = dump.iterator(); @Override/* w w w . ja v a 2 s .c o m*/ public boolean hasNext() { return nodes.hasNext(); } @Override public ThreadInfo next() { try { return ThreadInfo.from((CompositeData) converter.convertToObject( MappedMXBeanType.toOpenType(ThreadInfo.class), nodes.next().toString())); } catch (OpenDataException cause) { throw new AssertionError("Cannot parse thread info attributes", cause); } } }; }
From source file:com.simiacryptus.mindseye.applications.HadoopUtil.java
/** * To stream stream./*from w w w .j ava 2 s . com*/ * * @param <T> the type parameter * @param remoteIterator the remote iterator * @return the stream */ @Nonnull public static <T> Stream<T> toStream(final RemoteIterator<T> remoteIterator) { return StreamSupport.stream(Spliterators.spliterator(new Iterator<T>() { @Override public boolean hasNext() { try { return remoteIterator.hasNext(); } catch (Throwable e) { logger.warn("Error listing files", e); return false; } } @Override public T next() { try { return remoteIterator.next(); } catch (IOException e) { throw new RuntimeException(e); } } }, -1, Spliterator.IMMUTABLE), true); }
From source file:org.languagetool.dev.errorcorpus.SimpleCorpus.java
@Override public Iterator<ErrorSentence> iterator() { return new Iterator<ErrorSentence>() { @Override//from ww w . j a v a2 s . c o m public boolean hasNext() { return pos < lines.size(); } @Override public ErrorSentence next() { String line = lines.get(pos++); return getIncorrectSentence(line); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:org.datalorax.populace.core.populate.inspector.LoggingCollectionInspector.java
@SuppressWarnings("unchecked") @Override//from w ww .j a v a2s. c o m public Iterator<RawElement> getElements(final Object instance, final Inspectors inspectors) { final Iterator<RawElement> elements = CollectionInspector.INSTANCE.getElements(instance, inspectors); return new Iterator<RawElement>() { @Override public boolean hasNext() { return elements.hasNext(); } @Override public RawElement next() { return new LoggingCollectionElement(elements.next()); } }; }
From source file:SimpleSet.java
public Iterator iterator() { return new Iterator() { int pos = 0; public boolean hasNext() { return pos < count; }//from w ww . j a v a 2s . c om public Object next() { return elementObjects[pos++]; } public void remove() { if (pos < count) System.arraycopy(elementObjects, pos, elementObjects, pos - 1, count - pos); count--; pos--; } }; }
From source file:org.apache.solr.kelvin.ScorerLoader.java
public Iterator<Scorer> iterator() { return new Iterator<Scorer>() { private Iterator<IConfigurable> i = resources.iterator(); public boolean hasNext() { return i.hasNext(); }/* www. j av a2 s. c om*/ public Scorer next() { return (Scorer) i.next(); } public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:cloudlens.engine.CLIterator.java
public static CLIterator source(BlockEngine engine, InputStream inputStream, boolean withHistory) { final BlockObject wrap = engine.eval("function(message) { return {message:message}; }"); final CLIterator res = new CLIterator(engine, new Iterator<BlockObject>() { final Scanner scan = new Scanner(inputStream); @Override/* w w w . java 2 s. c o m*/ protected void finalize() throws IOException { if (scan != null) { scan.close(); } } @Override public boolean hasNext() { return scan.hasNext(); } @Override public BlockObject next() { final BlockObject record = wrap.call(scan.nextLine()); return record; } }, withHistory); if (withHistory) { res.iterate(); } ; return res; }
From source file:org.eurekastreams.server.service.actions.strategies.EmailerFactory.java
/** * Convenience routine to create a string containing a list of emails from a list of people objects. * * @param list/* w w w. j av a 2 s .c om*/ * List of objects which have an email property. * @return String of concatenated email addresses ready to pass to setTo/setCc/setBcc. */ public static String buildEmailList(final Iterable<? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator<? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { // Not used } }; return StringUtils.join(iter, ','); }