public class DefaultArrayAccess extends DefaultArrayDescription implements ArrayAccess
Exemplifies the Bridge Pattern.
arrayDims, arrayHandler, arrayIsRandom, arrayIsReadable, arrayIsWritable, arrayNdim, arrayNpix, arrayOrder, arrayOrigin, arrayShape, arrayType| Constructor and Description |
|---|
DefaultArrayAccess(ArrayDescription adesc,
AccessImpl impl,
java.lang.Object mappedArray)
Constructs an ArrayAccess object from a description of the array's
characteristics and a basic implementation of pixel access
functionality.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkOpen() |
void |
close()
Shuts down this accessor for further data access.
|
protected void |
doClose() |
java.lang.Object |
getMapped()
Returns a single primitive array holding all the data of this array.
|
long |
getOffset()
Returns the current offset into the array for read/write.
|
long[] |
getPosition()
Returns the coordinates at which the next read/write will occur.
|
boolean |
isMapped()
Indicates whether mapped access is available.
|
void |
read(java.lang.Object buffer,
int start,
int size)
Reads a number of pixels from the current offset into a specified
part of a supplied primitive array.
|
void |
readTile(java.lang.Object buffer,
NDShape tile)
Reads a tile of pixels into a supplied primitive array.
|
void |
setOffset(long off)
Sets the offset into the array for the next read/write to occur.
|
void |
setPosition(long[] pos)
Sets the coordinates for the next read/write to occur.
|
java.lang.String |
toString() |
void |
write(java.lang.Object buffer,
int start,
int size)
Writes a number of pixels starting at the current offset from a
specified part of a supplied primitive array.
|
void |
writeTile(java.lang.Object buffer,
NDShape tile)
Writes a tile of pixels from a supplied primitive array.
|
getBadHandler, getShape, getType, isRandom, isReadable, isWritableclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBadHandler, getShape, getType, isRandom, isReadable, isWritablepublic DefaultArrayAccess(ArrayDescription adesc, AccessImpl impl, java.lang.Object mappedArray)
adesc - array characteristics descriptionimpl - array access service provider, available for
exclusive use by this objectmappedArray - a java primitve array containing all the pixel
data of the accessed array. May be null if
mapped access is not providedpublic long getOffset()
ArrayAccessgetOffset in interface ArrayAccesspublic void setOffset(long off)
throws java.io.IOException
ArrayAccesssetOffset in interface ArrayAccessoff - the position at which the next read/write will startjava.io.IOException - if some unexpected I/O error occurspublic long[] getPosition()
ArrayAccessgetPosition in interface ArrayAccesspublic void setPosition(long[] pos)
throws java.io.IOException
ArrayAccesssetPosition in interface ArrayAccesspos - an N-element array giving the coordinates for the next
read/writejava.io.IOException - if some unexpected I/O error occurspublic void read(java.lang.Object buffer,
int start,
int size)
throws java.io.IOException
ArrayAccessAn IOException during the read will have the effect of closing this accessor for further access.
read in interface ArrayAccessbuffer - an array of the appropriate primitive type for this
accessor into whose elements
start..start+size the next size
pixels will be readstart - the starting offset into buffer into which the
pixels should be readsize - the number of pixels to read (also the amount by
which the current offset will be incremented)java.io.IOException - if there is an I/O errorpublic void readTile(java.lang.Object buffer,
NDShape tile)
throws java.io.IOException
ArrayAccessThe current offset will be updated to the point after the last pixel in the intersection between the tile and this accessor.
It is possible to read a tile when random access is not available, but only if the first pixel in the requested tile is ahead of the current offset.
An IOException during the read will have the effect of closing this accessor for further access.
readTile in interface ArrayAccessbuffer - an array of the appropriate primitive type for this
accessor and at least as long as the number of
pixels in tileShapetile - an NDShape object specifying the shape of the tile
to be readjava.io.IOException - if there is an I/O errorpublic void write(java.lang.Object buffer,
int start,
int size)
throws java.io.IOException
ArrayAccessIf an IOException occurs during the read, this will have the additional effect of closing this accessor for further access.
write in interface ArrayAccessbuffer - an array of the appropriate primitive type for this
NDArray whose elements start..start+size
will be written outstart - the starting point in buffer from which pixels
will be writtensize - the number of pixels to write (also the amount by
which the current offset will be incremented)java.io.IOException - if there is an I/O errorpublic void writeTile(java.lang.Object buffer,
NDShape tile)
throws java.io.IOException
ArrayAccessThe current offset will be updated to the point after the last pixel in the intersection between the tile and this accessor.
It is possible to read a tile when random access is not available, but only if the first pixel in the requested tile is ahead of the current offset.
If an IOException occurs during the write, this will have the additional effect of closing this accessor for further access.
writeTile in interface ArrayAccessbuffer - an array of the appropriate primitive type for this
NDArray and at least as long as the number of
pixels in tileShape (elements after this limit
will be ignored)tile - an NDShape object specifying the shape of the tile
to be writtenjava.io.IOException - if there is an I/O errorpublic boolean isMapped()
ArrayAccessisMapped in interface ArrayAccesspublic java.lang.Object getMapped()
ArrayAccessThe method will fail unless isMapped returns true.
getMapped in interface ArrayAccesspublic void close()
throws java.io.IOException
ArrayAccessclose in interface ArrayAccessjava.io.IOException - if there is an I/O errorprotected void doClose()
protected void checkOpen()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.