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 TypeMethodDescriptionvoid
createDataArray
(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.int
Returns 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.void
Readslength
values from the stream and stores them into the array known to subclass, starting at indexoffset
.void
seek
(long position) Moves to the given position in the stream.void
Sets the destination to the given data array, which may benull
.view()
Returns the view created by the last call tocreateView()
, ornull
if 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()
, ornull
if 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.buffer
contains 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
Readslength
values from the stream and stores them into the array known to subclass, starting at indexoffset
.If a non-null
Buffer
is 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 withindest
to write.length
- the number of values to read.- Throws:
IOException
- if an error (including EOF) occurred while reading the stream.
-