|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apfloat.spi.ArrayAccess
The ArrayAccess
class simulates a C
language pointer.
With one ArrayAccess
object you can point to a location within an
array. You can easily add or subtract a value to this "pointer", thus
essentially emulating C
pointer arithmetic. An ArrayAccess
provides an array, the starting index within that array and the length of
accessible data within the array, all in one convenient package.
Just like pointers in the C
language, ArrayAccess
objects are inherently unsafe and must be used cautiously. It is the
responsibility of the user of an ArrayAccess
object to make sure
that he doesn't access the provided array outside the allowed range. The
ArrayAccess
object itself does nothing to enforce this, except
of course the mandatory bounds check of Java, which can throw an
ArrayIndexOutOfBoundsException
.
Constructor Summary | |
protected |
ArrayAccess(int offset,
int length)
Create an array access. |
Method Summary | |
abstract void |
close()
Close this array access and commit any changes to the underlying data storage if applicable. |
abstract java.lang.Object |
getData()
Returns the array of this array access. |
double[] |
getDoubleData()
Returns the array of this array access as a double[] . |
float[] |
getFloatData()
Returns the array of this array access as a float[] . |
int[] |
getIntData()
Returns the array of this array access as an int[] . |
int |
getLength()
Returns the length of the access segment within the backing array. |
long[] |
getLongData()
Returns the array of this array access as a long[] . |
int |
getOffset()
Returns the offset of the access segment within the backing array. |
abstract ArrayAccess |
subsequence(int offset,
int length)
Create a sub-sequence view of this array access. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ArrayAccess(int offset, int length)
offset
- The offset of the access segment within the array.length
- The access segment.Method Detail |
public abstract ArrayAccess subsequence(int offset, int length)
Note that the changes done to the sub-sequence array
are not necessarily committed to the underlying data
storage when the sub-sequence is closed (with close()
),
but only when the "base" ArrayAccess
is closed.
offset
- The sub-sequence starting offset within this ArrayAccess.length
- The sub-sequence length.public abstract java.lang.Object getData() throws ApfloatRuntimeException
ApfloatRuntimeException
public int[] getIntData() throws java.lang.UnsupportedOperationException, ApfloatRuntimeException
int[]
.
java.lang.UnsupportedOperationException
- In case the backing array can't be presented as int[]
.
ApfloatRuntimeException
public long[] getLongData() throws java.lang.UnsupportedOperationException, ApfloatRuntimeException
long[]
.
java.lang.UnsupportedOperationException
- In case the backing array can't be presented as long[]
.
ApfloatRuntimeException
public float[] getFloatData() throws java.lang.UnsupportedOperationException, ApfloatRuntimeException
float[]
.
java.lang.UnsupportedOperationException
- In case the backing array can't be presented as float[]
.
ApfloatRuntimeException
public double[] getDoubleData() throws java.lang.UnsupportedOperationException, ApfloatRuntimeException
double[]
.
java.lang.UnsupportedOperationException
- In case the backing array can't be presented as double[]
.
ApfloatRuntimeException
public int getOffset()
public int getLength()
public abstract void close() throws ApfloatRuntimeException
If the ArrayAccess
was obtained in write
mode, the changes are saved to the data storage. Note
that even if the ArrayAccess
was obtained
for reading only, any changes made to the array data
may still be committed to the data storage.
Note that changes done to a sub-sequence array
are not necessarily committed to the underlying data
storage when the sub-sequence is closed,
but only when the "base" ArrayAccess
is closed.
ApfloatRuntimeException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |