Class ChannelDataInput.ArrayReader
java.lang.Object
org.apache.sis.internal.storage.io.ChannelDataInput.ArrayReader
- All Implemented Interfaces:
DataTransfer
- Direct Known Subclasses:
ChannelDataInput.BytesReader,ChannelDataInput.CharsReader,ChannelDataInput.DoublesReader,ChannelDataInput.FloatsReader,ChannelDataInput.IntsReader,ChannelDataInput.LongsReader,ChannelDataInput.ShortsReader
- Enclosing class:
- ChannelDataInput
Helper class for the
readFully(…) methods,
in order to avoid duplicating almost identical code many times.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal Stringfilename()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.final voidseek(long n) Moves to the given position in the stream.private voidskipInBuffer(int n) Skips the given amount of bytes in the buffer.(package private) abstract voidtransfer(int offset, int n) Transfers the data from the buffer created byDataTransfer.createView()to array of primitive Java type known by the subclass.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.sis.internal.storage.io.DataTransfer
createDataArray, createView, dataArray, dataArrayAsBuffer, dataSizeShift, setDest, view
-
Constructor Details
-
ArrayReader
ArrayReader()For subclass constructors only.
-
-
Method Details
-
filename
Returns a file identifier for error messages or debugging purpose.- Specified by:
filenamein interfaceDataTransfer
-
transfer
abstract void transfer(int offset, int n) Transfers 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. -
skipInBuffer
private void skipInBuffer(int n) Skips the given amount of bytes in the buffer. It is caller responsibility to ensure that there is enough bytes remaining in the buffer. -
seek
Moves to the given position in the stream.- Specified by:
seekin interfaceDataTransfer- Parameters:
n- 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).- Specified by:
readFullyin interfaceDataTransfer- 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.
-