uk.ac.starlink.array
Interface AccessImpl


public interface AccessImpl

Interface for the implementation of read/write access to the pixels of an array. This is the interface via which array implementations provide pixel read/write services to the BridgeNDArray class. BridgeNDArray, which performs parameter validations, is expected to be the only client of AccessImpl, so that implementations of this interface can in general assume that the arguments they receive make sense.

Author:
Mark Taylor (Starlink)

Method Summary
 void close()
          This method will be called when read/write access to this object is no longer required.
 void read(Object buffer, int start, int size)
          Reads a number of pixels from the current offset into a specified part of a supplied java array.
 void setOffset(long off)
          Sets the offset into the array at which the next read/write will occur.
 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 array.
 

Method Detail

setOffset

void setOffset(long off)
               throws IOException
Sets the offset into the array at which the next read/write will occur. Parameter validation will have occurred prior to this call, so it may be assumed that the offset is a legal value (between 0 and the array length implied by the dimensions of its owner ArrayImpl, and in the case of non-random access, >= the current offset).

Parameters:
off - the offset into the data array
Throws:
IOException

read

void read(Object buffer,
          int start,
          int size)
          throws IOException
Reads a number of pixels from the current offset into a specified part of a supplied java array. The offset will be updated accordingly (to the point after the read pixels). Parameter validation will have occurred prior to this call, so it may be assumed that the buffer is an array of the right type and long enough, and the requested size will not exceed the number of pixels remaining between the length and offset of this reader. This method will not be called if this accessor was obtained from a non-readable ArrayImpl.

Parameters:
buffer - an array of the appropriate primitive type for this NDArray into whose elements start..start+size the pixels will be read
start - the starting offset into array into which the pixels should be read
size - the number of pixels to read (also the amount by which the current offset will be incremented)
Throws:
IOException - if there is an I/O error

write

void write(Object buffer,
           int start,
           int size)
           throws IOException
Writes a number of pixels starting at the current offset from a specified part of a supplied array. The current offset will be updated accordingly (to the point after the last write). Parameter validation will have occurred prior to this call, so it may be assumed that the buffer of the right type and long enough, and the requested size will not exceed the number of pixels remaining between the length and offset of this writer. This method will not be called if this accessor was obtained from a non-writable AccessImpl.

Parameters:
buffer - an array of the appropriate primitive type for this ArrayImpl whose elements start..start+size will be written out
start - the starting point in the array from which pixels will be written
size - the number of pixels to write (also the amount by which the current offset will be incremented)
Throws:
IOException - if there is an I/O error

close

void close()
           throws IOException
This method will be called when read/write access to this object is no longer required. It should free such non-memory resources and flush such buffers associated with this accessor (not with the parent ArrayImpl) as are required. Following this call no write or set method invocations will be attempted.

This method will not be invoked more than once.

Throws:
IOException - if there is an I/O error


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.