Class ChannelDataInput.BytesReader
java.lang.Object
org.apache.sis.internal.storage.io.ChannelDataInput.ArrayReader
org.apache.sis.internal.storage.io.ChannelDataInput.BytesReader
- All Implemented Interfaces:
DataTransfer
- Enclosing class:
- ChannelDataInput
Reads bytes from the enclosing stream and stores them into the given destination array. This implementation
actually redirects the reading process to
ChannelDataInput.readFully(byte[], int, int) because this
specialization does not need a view. This implementation is useless for ChannelDataInput, but avoid
the need to implement special cases in other classes like HyperRectangleReader.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDataArray(int n) Creates a destination array of the given length.Creates a new buffer of the type required by the array to fill.Returns the data as achar[],short[],int[],long[],float[]ordouble[]array.ReturnsDataTransfer.dataArray()wrapped in a buffer.intReturns the size of the Java primitive type which is the element of the array.voidReadslengthvalues from the stream, and stores them into the array known to subclass, starting at indexoffset.voidSets the destination to the given data array, which may benull.(package private) voidtransfer(int p, int n) Transfers the data from the buffer created byDataTransfer.createView()to array of primitive Java type known by the subclass.view()Returns the view created by the last call toDataTransfer.createView(), ornullif none.Methods inherited from class org.apache.sis.internal.storage.io.ChannelDataInput.ArrayReader
filename, seek
-
Field Details
-
dest
private byte[] destThe array where to store the values.
-
-
Constructor Details
-
BytesReader
BytesReader(byte[] dest)
-
-
Method Details
-
dataSizeShift
public int dataSizeShift()Description copied from interface:DataTransferReturns the size of the Java primitive type which is the element of the array. The size is expressed as the number of bits to shift:java dataSize = 1 << dataSizeShift; -
dataArray
Description copied from interface:DataTransferReturns the data as achar[],short[],int[],long[],float[]ordouble[]array. This is either the array given in argument to the subclass constructor, or the array created byDataTransfer.createDataArray(int). -
dataArrayAsBuffer
Description copied from interface:DataTransferReturnsDataTransfer.dataArray()wrapped in a buffer. -
view
Description copied from interface:DataTransferReturns the view created by the last call toDataTransfer.createView(), ornullif none. -
createView
Description copied from interface:DataTransferCreates a new buffer of the type required by the array to fill. This method is guaranteed to be invoked exactly once, after theChannelData.buffercontains enough data. -
createDataArray
public void createDataArray(int n) Description copied from interface:DataTransferCreates a destination array of the given length. -
transfer
void transfer(int p, int n) Description copied from class:ChannelDataInput.ArrayReaderTransfers the data from the buffer created byDataTransfer.createView()to array of primitive Java type known by the subclass. This method may be invoked an arbitrary number of time.- Specified by:
transferin classChannelDataInput.ArrayReader
-
setDest
Description copied from interface:DataTransferSets the destination to the given data array, which may benull. -
readFully
Description copied from class:ChannelDataInput.ArrayReaderReadslengthvalues from the stream, and stores them into the array known to subclass, starting at indexoffset.If a non-null
Bufferis given in argument to this method, then it must be a view over the full content ofChannelData.buffer(i.e. the view element at index 0 shall be defined by the buffer elements starting at index 0).- Specified by:
readFullyin interfaceDataTransfer- Overrides:
readFullyin classChannelDataInput.ArrayReader- Parameters:
view- existing buffer to use as a view overChannelData.buffer, ornull.offset- the starting position withindestto write.length- the number of values to read.- Throws:
IOException- if an error (including EOF) occurred while reading the stream.
-