/** * Delegated to the underlying iterator. * * @return iterator size */ public long getSize() { return iterator.getSize(); }
public RangeIteratorImpl(RangeIterator rangeIterator) { this.iterator = rangeIterator; this.size = rangeIterator.getSize(); this.position = rangeIterator.getPosition(); }
/** * Returns an array of remote references to the next elements in this * iteration. * * @return array of remote references, or <code>null</code> * @throws RemoteException on RMI errors */ @Override public Object[] nextObjects() throws RemoteException { ArrayList items = new ArrayList(); while (items.size() < maxBufferSize && iterator.hasNext()) { items.add(getRemoteObject(iterator.next())); } if (items.size() > 0) { return items.toArray(new Object[items.size()]); } else { size = iterator.getPosition(); return null; } }
/** * Delegated to the underlying iterator. * * @return <code>true</code> if the iterator has more elements, * <code>false</code> otherwise */ public boolean hasNext() { return iterator.hasNext(); }
/** * Delegated to the underlying iterator. * * @return next element * @throws NoSuchElementException if there are no more elements */ public Object next() throws NoSuchElementException { return iterator.next(); }
/** * Advances the underlying iterator. * * @param skipNum number of elements to skip * @see RangeIterator#skip(long) */ public void skip(long skipNum) { iterator.skip(skipNum); }
/** * Delegated to the underlying iterator. * * @return iterator position */ public long getPosition() { return iterator.getPosition(); }
/** * Delegated to the underlying iterator. * * @throws UnsupportedOperationException if the operation is not supported * @throws IllegalStateException if there is no element to be removed */ public void remove() throws UnsupportedOperationException, IllegalStateException { iterator.remove(); } }
/** * Delegated to the underlying iterator. * * @return <code>true</code> if the iterator has more elements, * <code>false</code> otherwise */ public boolean hasNext() { return iterator.hasNext(); }
/** * Delegated to the underlying iterator. * * @return next element * @throws NoSuchElementException if there are no more elements */ public Object next() throws NoSuchElementException { return iterator.next(); }
/** * Delegated to the underlying iterator. * * @param n number of elements to skip * @throws NoSuchElementException if skipped past the last element */ public void skip(long n) throws NoSuchElementException { iterator.skip(n); }
/** * Delegated to the underlying iterator. * * @return iterator position */ public long getPosition() { return iterator.getPosition(); }
/** * Removes the current object from the underlying iterator. * * @see java.util.Iterator#remove() */ public void remove() { iterator.remove(); }
private static long getSize(Iterator<String> it) { if (it instanceof RangeIterator) { return ((RangeIterator) it).getSize(); } else { return -1; } }
/** * Returns the size of the <code>RangeIterator</code> <code>it</code>. * Note, that the <code>RangeIterator</code> might get consumed, because * {@link RangeIterator#getSize()} might return -1 (information unavailable). * @param it a <code>RangeIterator</code>. * @return the size of the iterator (number of elements). */ protected long getSize(RangeIterator it) { long size = it.getSize(); if (size != -1) { return size; } size = 0; while (it.hasNext()) { it.next(); size++; } return size; }
/** * Delegated to the underlying iterator. * * @return <code>true</code> if the iterator has more elements, * <code>false</code> otherwise */ public boolean hasNext() { return iterator.hasNext(); }