The iterator Java SequenceIterator methods are used to extract and iterate over the object's sequence elements, determine the sequence element type, size and position within the iterator's sequence, determine the sequence tile size, and, for RLE-encoded sequences, determine the repeat count or decode the RLE sequence to a non-RLE sequence.
The iterator operation can be one of the following:
public int get(Object buffer)Extracts the sequence elements into the provided arraybuffer. This array should have the same element type as the sequence element type. Returns the actual number of elements extracted (which can be smaller than the array size in case of reaching the end of the array).public Object next()Gets the next element of the sequence. Returns the object wrapper for the next sequence element ornullif the end of the sequence is reached.public int nextInt()Gets the next integer element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public long nextLong()Gets the next long integer element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public float nextFloat()Gets the next float element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public double nextDouble()Gets the next double element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public byte[] nextBytes()Gets the next char element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public String nextString()Gets the next string element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public Date nextDate()Gets the next date element of the sequence. Returns the next sequence element value (throws aNoSuchElementExceptionif the iterator has no more elements).public long firstPosition()Gets the position of the first sequence element. Returns the position of the element at which this sequence starts (inclusive).public long lastPosition()Gets the position of the last sequence element. Returns the position of the element at which this sequence ends (inclusive).public long nextPosition()Returns the position of the element returned by a subsequent invocation of thenext()ornextTile()method.public boolean nextTile()Advances the iterator to the next tile. Returnstrueif the iterator has successfully advanced,falseotherwise.public int elemSize()Returns the sequence element size.public Object tileItems()Gets the items of the current tile. Returns an array with tile items.public Sequence.Type type()Returns the type of the underlying sequence.static native public boolean isRLE()Checks if the underlying sequence implementation uses RLE format (in this case a repeat counter is associated with each sequence element).public int itemRepeatCount(int i)Gets the RLE count for the tile item (for non-RLE implementations of sequences, this method always returns 1).public SequenceIterator rleDecode()Decodes the RLE sequence to a non-RLE sequence (for non-RLE implementations, this method just copies the sequence iterator).public void reset()Resets (rewinds) the sequence position to the first element.public void close()Closes and releases the sequence's internal resources.Example
The following code snippet demonstrates sequence iteration using the
next()method:private static int printFloatSequence(Quote quote, SequenceIterator iterator) { System.out.print(quote.symbol + ": {"); Object elem; int i; for (i = 0; (elem = iterator.next()) != null; i++) { if (i != 0) System.out.print(","); System.out.format("%.3f", elem); } System.out.println("}"); return i; }