protected abstract class DataStorage.AbstractIterator extends DataStorage.Iterator
DataStorage.
This class provides most of the common functionality needed.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractIterator(int mode,
long startPosition,
long endPosition)
Construct a new iterator.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkGet()
Checks if any of the
get() methods can be called. |
protected void |
checkLength()
Checks if the iterator is at the end yet.
|
protected void |
checkSet()
Checks if any of the
set() methods can be called. |
double |
getDouble()
Gets the current element as a
double. |
float |
getFloat()
Gets the current element as a
float. |
protected int |
getIncrement()
Returns the increment of the iterator.
|
int |
getInt()
Gets the current element as an
int. |
protected long |
getLength()
Returns the remaining length in the iterator.
|
long |
getLong()
Gets the current element as a
long. |
protected int |
getMode()
Returns the mode in which the iterator was created.
|
protected long |
getPosition()
Returns the current position of the iterator.
|
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. |
close, get, setprotected AbstractIterator(int mode,
long startPosition,
long endPosition)
throws IllegalArgumentException,
IllegalStateException,
ApfloatRuntimeException
startPosition
is less than or greater than endPosition, correspondingly.mode - Access mode for iterator: DataStorage.READ, DataStorage.WRITE or both.startPosition - Starting position of iterator in the data set. For reverse access, the first element in the iterator is startPosition - 1.endPosition - End position of iterator in the data set. For forward access, the last accessible element in the iterator is endPosition - 1.IllegalArgumentException - If the requested block is out of bounds of the data storage.IllegalStateException - If write access is requested for a read-only data storage.ApfloatRuntimeExceptionpublic boolean hasNext()
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.
hasNext in class DataStorage.Iteratortrue if next() can be called, otherwise false.public void next()
throws IllegalStateException,
ApfloatRuntimeException
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.
next in class DataStorage.IteratorIllegalStateException - If the iterator has been iterated to the end already.ApfloatRuntimeExceptionpublic int getInt()
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorint.
The default implementation calls DataStorage.Iterator.get(Class) with argument Integer.TYPE.
getInt in class DataStorage.Iteratorint.UnsupportedOperationException - If the element type of the data storage can't be converted to an int.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic long getLong()
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorlong.
The default implementation calls DataStorage.Iterator.get(Class) with argument Long.TYPE.
getLong in class DataStorage.Iteratorlong.UnsupportedOperationException - If the element type of the data storage can't be converted to a long.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic float getFloat()
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorfloat.
The default implementation calls DataStorage.Iterator.get(Class) with argument Float.TYPE.
getFloat in class DataStorage.Iteratorfloat.UnsupportedOperationException - If the element type of the data storage can't be converted to a float.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic double getDouble()
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratordouble.
The default implementation calls DataStorage.Iterator.get(Class) with argument Double.TYPE.
getDouble in class DataStorage.Iteratordouble.UnsupportedOperationException - If the element type of the data storage can't be converted to a double.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic void setInt(int value)
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorint.
The default implementation calls DataStorage.Iterator.set(Class,Object) with first argument Integer.TYPE.
setInt in class DataStorage.Iteratorvalue - The value to be set to the current element as an int.UnsupportedOperationException - If the element type of the data storage can't be converted to an int.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic void setLong(long value)
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorlong.
The default implementation calls DataStorage.Iterator.set(Class,Object) with first argument Long.TYPE.
setLong in class DataStorage.Iteratorvalue - The value to be set to the current element as a long.UnsupportedOperationException - If the element type of the data storage can't be converted to a long.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic void setFloat(float value)
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratorfloat.
The default implementation calls DataStorage.Iterator.set(Class,Object) with first argument Float.TYPE.
setFloat in class DataStorage.Iteratorvalue - The value to be set to the current element as a float.UnsupportedOperationException - If the element type of the data storage can't be converted to a float.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionpublic void setDouble(double value)
throws UnsupportedOperationException,
IllegalStateException,
ApfloatRuntimeException
DataStorage.Iteratordouble.
The default implementation calls DataStorage.Iterator.set(Class,Object) with first argument Double.TYPE.
setDouble in class DataStorage.Iteratorvalue - The value to be set to the current element as a double.UnsupportedOperationException - If the element type of the data storage can't be converted to a double.IllegalStateException - If the iterator is at the end.ApfloatRuntimeExceptionprotected void checkGet()
throws IllegalStateException
get() methods can be called.
This checks both that the iterator is not at the end yet, and
that the iterator was opened in a readable mode.IllegalStateException - If the iterator is at end or is not readable.protected void checkSet()
throws IllegalStateException
set() methods can be called.
This checks both that the iterator is not at the end yet, and
that the iterator was opened in a writable mode.IllegalStateException - If the iterator is at end or is not writable.protected void checkLength()
throws IllegalStateException
IllegalStateException - If the iterator is at end.protected int getMode()
protected long getPosition()
protected long getLength()
protected int getIncrement()
Copyright © 2025. All rights reserved.