Package org.apfloat.internal
Class LongDiskDataStorage.BlockIterator
- java.lang.Object
-
- org.apfloat.spi.DataStorage.Iterator
-
- org.apfloat.spi.DataStorage.AbstractIterator
-
- org.apfloat.internal.LongDiskDataStorage.BlockIterator
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.AutoCloseable
- Enclosing class:
- LongDiskDataStorage
private class LongDiskDataStorage.BlockIterator extends DataStorage.AbstractIterator
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayAccessarrayAccessprivate long[]dataprivate intoffsetprivate intremainingprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description BlockIterator(int mode, long startPosition, long endPosition)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckAvailable()voidclose()Closes the iterator.<T> Tget(java.lang.Class<T> type)Gets the current element as a the specified element type.longgetLong()Gets the current element as along.voidnext()Advances the position in the stream by one element.<T> voidset(java.lang.Class<T> type, T value)Sets the current element as the specified element type.voidsetLong(long value)Sets the current element as along.-
Methods inherited from class org.apfloat.spi.DataStorage.AbstractIterator
checkGet, checkLength, checkSet, getDouble, getFloat, getIncrement, getInt, getLength, getMode, getPosition, hasNext, setDouble, setFloat, setInt
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
arrayAccess
private ArrayAccess arrayAccess
-
data
private long[] data
-
offset
private int offset
-
remaining
private int remaining
-
-
Constructor Detail
-
BlockIterator
public BlockIterator(int mode, long startPosition, long endPosition) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, ApfloatRuntimeException- Throws:
java.lang.IllegalArgumentExceptionjava.lang.IllegalStateExceptionApfloatRuntimeException
-
-
Method Detail
-
next
public void next() throws java.lang.IllegalStateException, ApfloatRuntimeExceptionDescription copied from class:DataStorage.AbstractIteratorAdvances 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 calledstartPosition - endPositiontimes. Theget()orset()methods should not be called for the last element.- Overrides:
nextin classDataStorage.AbstractIterator- Throws:
java.lang.IllegalStateException- If the iterator has been iterated to the end already.ApfloatRuntimeException
-
getLong
public long getLong() throws java.lang.IllegalStateException, ApfloatRuntimeExceptionDescription copied from class:DataStorage.IteratorGets the current element as along.The default implementation calls
DataStorage.Iterator.get(Class)with argumentLong.TYPE.- Overrides:
getLongin classDataStorage.AbstractIterator- Returns:
- The current element as a
long. - Throws:
java.lang.IllegalStateException- If the iterator is at the end.ApfloatRuntimeException
-
setLong
public void setLong(long value) throws java.lang.IllegalStateException, ApfloatRuntimeExceptionDescription copied from class:DataStorage.IteratorSets the current element as along.The default implementation calls
DataStorage.Iterator.set(Class,Object)with first argumentLong.TYPE.- Overrides:
setLongin classDataStorage.AbstractIterator- Parameters:
value- The value to be set to the current element as along.- Throws:
java.lang.IllegalStateException- If the iterator is at the end.ApfloatRuntimeException
-
get
public <T> T get(java.lang.Class<T> type) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateExceptionDescription copied from class:DataStorage.IteratorGets the current element as a the specified element type.The default implementation always throws
UnsupportedOperationException.- Overrides:
getin classDataStorage.Iterator- Type Parameters:
T- The type of the element.- Parameters:
type- The type of the element.- Returns:
- The current element as the specified type.
- Throws:
java.lang.UnsupportedOperationException- If the element type of the data storage can't be converted to the specified type.java.lang.IllegalStateException- If the iterator is at the end.
-
set
public <T> void set(java.lang.Class<T> type, T value) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException, java.lang.IllegalStateExceptionDescription copied from class:DataStorage.IteratorSets the current element as the specified element type.The default implementation always throws
UnsupportedOperationException.- Overrides:
setin classDataStorage.Iterator- Type Parameters:
T- The type of the element.- Parameters:
type- The type of the element.value- The value to be set to the current element as the specified type.- Throws:
java.lang.UnsupportedOperationException- If the element type of the data storage can't be converted to the specified type.java.lang.IllegalArgumentException- If the value is not of the specified type.java.lang.IllegalStateException- If the iterator is at the end.
-
close
public void close() throws ApfloatRuntimeExceptionCloses the iterator. This needs to be called only if the iterator is not iterated to the end.- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classDataStorage.Iterator- Throws:
ApfloatRuntimeException
-
checkAvailable
private void checkAvailable() throws ApfloatRuntimeException- Throws:
ApfloatRuntimeException
-
-