org.apfloat.spi
Class DataStorage.Iterator

java.lang.Object
  extended byorg.apfloat.spi.DataStorage.Iterator
Direct Known Subclasses:
DataStorage.AbstractIterator
Enclosing class:
DataStorage

public abstract static class DataStorage.Iterator
extends java.lang.Object

Iterator for iterating through elements of the data storage.


Constructor Summary
protected DataStorage.Iterator()
          Default constructor.
 
Method Summary
 void close()
          Closes the iterator.
 double getDouble()
          Gets the current element as a double.
 float getFloat()
          Gets the current element as a float.
 int getInt()
          Gets the current element as an int.
 long getLong()
          Gets the current element as a long.
 boolean hasNext()
          Check if next() can be called without going past the end of the sequence.
 void next()
          Advances the position in the stream by one element.
 void setDouble(double value)
          Sets the current element as a double.
 void setFloat(float value)
          Sets the current element as a float.
 void setInt(int value)
          Sets the current element as an int.
 void setLong(long value)
          Sets the current element as a long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataStorage.Iterator

protected DataStorage.Iterator()
Default constructor. Can be used e.g. for simple anonymous subclasses.

Method Detail

hasNext

public boolean hasNext()
Check if next() can be called without going past the end of the sequence.

That is, if next() can be called without deliberately causing an exception. Note: It is important that the iterator is iterated past the last element; that is next() is called startPosition - endPosition times. The get() or set() methods should not be called for the last element.

The default implementation always returns false.

Returns:
true if next() can be called, otherwise false.

next

public void next()
          throws java.lang.IllegalStateException,
                 ApfloatRuntimeException
Advances the position in the stream by one element.

Note: It is important that the iterator is iterated past the last element; that is next() is called startPosition - endPosition times. The get() or set() methods should not be called for the last element.

The default implementation always throws IllegalStateException.

Throws:
java.lang.IllegalStateException - If the iterator has been iterated to the end already.
ApfloatRuntimeException

getInt

public int getInt()
           throws java.lang.UnsupportedOperationException,
                  java.lang.IllegalStateException,
                  ApfloatRuntimeException
Gets the current element as an int.

The default implementation always throws UnsupportedOperationException.

Returns:
The current element as an int.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to an int.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

getLong

public long getLong()
             throws java.lang.UnsupportedOperationException,
                    java.lang.IllegalStateException,
                    ApfloatRuntimeException
Gets the current element as a long.

The default implementation always throws UnsupportedOperationException.

Returns:
The current element as a long.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a long.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

getFloat

public float getFloat()
               throws java.lang.UnsupportedOperationException,
                      java.lang.IllegalStateException,
                      ApfloatRuntimeException
Gets the current element as a float.

The default implementation always throws UnsupportedOperationException.

Returns:
The current element as a float.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a float.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

getDouble

public double getDouble()
                 throws java.lang.UnsupportedOperationException,
                        java.lang.IllegalStateException,
                        ApfloatRuntimeException
Gets the current element as a double.

The default implementation always throws UnsupportedOperationException.

Returns:
The current element as a double.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a double.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

setInt

public void setInt(int value)
            throws java.lang.UnsupportedOperationException,
                   java.lang.IllegalStateException,
                   ApfloatRuntimeException
Sets the current element as an int.

The default implementation always throws UnsupportedOperationException.

Parameters:
value - The value to be set to the current element as an int.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to an int.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

setLong

public void setLong(long value)
             throws java.lang.UnsupportedOperationException,
                    java.lang.IllegalStateException,
                    ApfloatRuntimeException
Sets the current element as a long.

The default implementation always throws UnsupportedOperationException.

Parameters:
value - The value to be set to the current element as a long.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a long.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

setFloat

public void setFloat(float value)
              throws java.lang.UnsupportedOperationException,
                     java.lang.IllegalStateException,
                     ApfloatRuntimeException
Sets the current element as a float.

The default implementation always throws UnsupportedOperationException.

Parameters:
value - The value to be set to the current element as a float.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a float.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

setDouble

public void setDouble(double value)
               throws java.lang.UnsupportedOperationException,
                      java.lang.IllegalStateException,
                      ApfloatRuntimeException
Sets the current element as a double.

The default implementation always throws UnsupportedOperationException.

Parameters:
value - The value to be set to the current element as a double.
Throws:
java.lang.UnsupportedOperationException - If the element type of the data storage can't be converted to a double.
java.lang.IllegalStateException - If the iterator is at the end.
ApfloatRuntimeException

close

public void close()
           throws ApfloatRuntimeException
Closes the iterator. This needs to be called only if the iterator is not iterated to the end.

Throws:
ApfloatRuntimeException