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 Type
    Method
    Description
    void
    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 a char[], short[], int[], long[], float[] or double[] array.
    Returns dataArray() wrapped in a buffer.
    int
    Returns the size of the Java primitive type which is the element of the array.
    Returns a file identifier for error messages or debugging purpose.
    void
    readFully(Buffer view, int offset, int length)
    Reads length values from the stream and stores them into the array known to subclass, starting at index offset.
    void
    seek(long position)
    Moves to the given position in the stream.
    void
    setDest(Object array)
    Sets the destination to the given data array, which may be null.
    Returns the view created by the last call to createView(), or null 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 a char[], short[], int[], long[], float[] or double[] array. This is either the array given in argument to the subclass constructor, or the array created by createDataArray(int).
    • dataArrayAsBuffer

      Buffer dataArrayAsBuffer()
      Returns dataArray() wrapped in a buffer.
    • createDataArray

      void createDataArray(int length)
      Creates a destination array of the given length.
    • setDest

      void setDest(Object array) throws ClassCastException
      Sets the destination to the given data array, which may be null.
      Throws:
      ClassCastException
    • view

      Buffer view()
      Returns the view created by the last call to createView(), or null 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 the ChannelData.buffer contains enough data.
    • seek

      void seek(long position) throws IOException
      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

      void readFully(Buffer view, int offset, int length) throws IOException
      Reads length values from the stream and stores them into the array known to subclass, starting at index offset.

      If a non-null Buffer is given in argument to this method, then it must be a view over the full content of ChannelData.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 over ChannelData.buffer, or null.
      offset - the starting position within dest to write.
      length - the number of values to read.
      Throws:
      IOException - if an error (including EOF) occurred while reading the stream.