|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.array.DefaultArrayDescription
uk.ac.starlink.array.DefaultArrayAccess
public class DefaultArrayAccess
Default implementation of the ArrayAccess interface, based on an AccessImpl. The underlying AccessImpl must be private to this object, and not used by any other clients during the lifetime of this object.
Exemplifies the Bridge Pattern.
Field Summary |
---|
Fields inherited from class uk.ac.starlink.array.DefaultArrayDescription |
---|
arrayDims, arrayHandler, arrayIsRandom, arrayIsReadable, arrayIsWritable, arrayNdim, arrayNpix, arrayOrder, arrayOrigin, arrayShape, arrayType |
Constructor Summary | |
---|---|
DefaultArrayAccess(ArrayDescription adesc,
AccessImpl impl,
Object mappedArray)
Constructs an ArrayAccess object from a description of the array's characteristics and a basic implementation of pixel access functionality. |
Method Summary | |
---|---|
protected void |
checkOpen()
|
void |
close()
Shuts down this accessor for further data access. |
protected void |
doClose()
|
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(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(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. |
String |
toString()
|
void |
write(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(Object buffer,
NDShape tile)
Writes a tile of pixels from a supplied primitive array. |
Methods inherited from class uk.ac.starlink.array.DefaultArrayDescription |
---|
getBadHandler, getShape, getType, isRandom, isReadable, isWritable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uk.ac.starlink.array.ArrayDescription |
---|
getBadHandler, getShape, getType, isRandom, isReadable, isWritable |
Constructor Detail |
---|
public DefaultArrayAccess(ArrayDescription adesc, AccessImpl impl, 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 providedMethod Detail |
---|
public long getOffset()
ArrayAccess
getOffset
in interface ArrayAccess
public void setOffset(long off) throws IOException
ArrayAccess
setOffset
in interface ArrayAccess
off
- the position at which the next read/write will start
IOException
- if some unexpected I/O error occurspublic long[] getPosition()
ArrayAccess
getPosition
in interface ArrayAccess
public void setPosition(long[] pos) throws IOException
ArrayAccess
setPosition
in interface ArrayAccess
pos
- an N-element array giving the coordinates for the next
read/write
IOException
- if some unexpected I/O error occurspublic void read(Object buffer, int start, int size) throws IOException
ArrayAccess
An IOException during the read will have the effect of closing this accessor for further access.
read
in interface ArrayAccess
buffer
- 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)
IOException
- if there is an I/O errorpublic void readTile(Object buffer, NDShape tile) throws IOException
ArrayAccess
The 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 ArrayAccess
buffer
- 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 read
IOException
- if there is an I/O errorpublic void write(Object buffer, int start, int size) throws IOException
ArrayAccess
If an IOException occurs during the read, this will have the additional effect of closing this accessor for further access.
write
in interface ArrayAccess
buffer
- 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)
IOException
- if there is an I/O errorpublic void writeTile(Object buffer, NDShape tile) throws IOException
ArrayAccess
The 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 ArrayAccess
buffer
- 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 written
IOException
- if there is an I/O errorpublic boolean isMapped()
ArrayAccess
isMapped
in interface ArrayAccess
public Object getMapped()
ArrayAccess
The method will fail unless isMapped returns true.
getMapped
in interface ArrayAccess
public void close() throws IOException
ArrayAccess
close
in interface ArrayAccess
IOException
- if there is an I/O errorprotected void doClose()
protected void checkOpen()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |