Interface DataTransfer
- All Known Implementing Classes:
ChannelDataInput.ArrayReader,ChannelDataInput.BytesReader,ChannelDataInput.CharsReader,ChannelDataInput.DoublesReader,ChannelDataInput.FloatsReader,ChannelDataInput.IntsReader,ChannelDataInput.LongsReader,ChannelDataInput.ShortsReader,MemoryDataTransfer
interface DataTransfer
Transfers data from a buffer to an array specified at construction time.
The kind of buffer and the primitive type in the array depend on the implementation.
- Since:
- 0.7
- Version:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDataArray(int length) 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.ReturnsdataArray()wrapped in a buffer.intReturns the size of the Java primitive type which is the element of the array.filename()Returns a file identifier for error messages or debugging purpose.voidReadslengthvalues from the stream and stores them into the array known to subclass, starting at indexoffset.voidseek(long position) Moves to the given position in the stream.voidSets the destination to the given data array, which may benull.view()Returns the view created by the last call tocreateView(), ornullif none.
-
Method Details
-
filename
String filename()Returns a file identifier for error messages or debugging purpose. -
dataSizeShift
int dataSizeShift()Returns 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
Object dataArray()Returns 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 bycreateDataArray(int). -
dataArrayAsBuffer
Buffer dataArrayAsBuffer()ReturnsdataArray()wrapped in a buffer. -
createDataArray
void createDataArray(int length) Creates a destination array of the given length. -
setDest
Sets the destination to the given data array, which may benull.- Throws:
ClassCastException
-
view
Buffer view()Returns the view created by the last call tocreateView(), ornullif none. -
createView
Buffer createView()Creates 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. -
seek
Moves to the given position in the stream.- Parameters:
position- the position where to move.- Throws:
IOException- if the stream cannot be moved to the given position.
-
readFully
Readslengthvalues 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).- 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.
-