Class ShortBufferData

All Implemented Interfaces:
Savable

public class ShortBufferData extends IndexBufferData<ShortBuffer> implements Savable
Simple data class storing a buffer of shorts
  • Constructor Details

    • ShortBufferData

      public ShortBufferData()
      Instantiates a new ShortBufferData.
    • ShortBufferData

      public ShortBufferData(int size)
      Instantiates a new ShortBufferData with a buffer of the given size.
      Parameters:
      size - the size
    • ShortBufferData

      public ShortBufferData(ShortBuffer buffer)
      Creates a new ShortBufferData.
      Parameters:
      buffer - Buffer holding the data. Must not be null.
  • Method Details

    • getClassTag

      public Class<? extends ShortBufferData> getClassTag()
      Specified by:
      getClassTag in interface Savable
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class AbstractBufferData<ShortBuffer>
      Throws:
      IOException
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class AbstractBufferData<ShortBuffer>
      Throws:
      IOException
    • get

      public int get()
      Specified by:
      get in class IndexBufferData<ShortBuffer>
      Returns:
      the next value from this object, as an int, incrementing our position by 1 entry. Buffer types smaller than an int should return unsigned values.
    • get

      public int get(int index)
      Specified by:
      get in class IndexBufferData<ShortBuffer>
      Parameters:
      index - the absolute position to get our value from. This is in entries, not bytes, and is 0 based. So for a ShortBuffer, 2 would be the 3rd short from the beginning, etc.
      Returns:
      the value from this object, as an int, at the given absolute entry position. Buffer types smaller than an int should return unsigned values.
    • put

      public ShortBufferData put(int value)
      Description copied from class: IndexBufferData
      Sets the value of this buffer at the current position, incrementing our position by 1 entry.
      Specified by:
      put in class IndexBufferData<ShortBuffer>
      Parameters:
      value - the value to place into this object at the current position.
      Returns:
      this object, for chaining.
    • put

      public ShortBufferData put(int index, int value)
      Description copied from class: IndexBufferData
      Sets the value of this buffer at the given index.
      Specified by:
      put in class IndexBufferData<ShortBuffer>
      Parameters:
      index - the absolute position to put our value at. This is in entries, not bytes, and is 0 based. So for a ShortBuffer, 2 would be the 3rd short from the beginning, etc.
      value - the value to place into this object
      Returns:
      this object, for chaining.
    • put

      public void put(IndexBufferData<?> buf)
      Description copied from class: IndexBufferData
      Write the contents of the given IndexBufferData into this one. Note that data conversion is handled using the get/put methods in IndexBufferData.
      Specified by:
      put in class IndexBufferData<ShortBuffer>
      Parameters:
      buf - the source buffer object.
    • put

      public void put(int[] array)
      Description copied from class: IndexBufferData
      Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using the get/put methods in IndexBufferData.
      Specified by:
      put in class IndexBufferData<ShortBuffer>
      Parameters:
      array - the source int array.
    • put

      public void put(int[] array, int offset, int length)
      Description copied from class: IndexBufferData
      Write the contents of the given int array into this IndexBufferData. Note that data conversion is handled using the get/put methods in IndexBufferData.
      Specified by:
      put in class IndexBufferData<ShortBuffer>
      Parameters:
      array - the source int array.
      offset - the offset
      length - the length
    • getByteCount

      public int getByteCount()
      Specified by:
      getByteCount in class AbstractBufferData<ShortBuffer>
      Returns:
      the number of bytes per entry in the buffer. For example, an IntBuffer would return 4.
    • getBuffer

      public ShortBuffer getBuffer()
      Description copied from class: IndexBufferData
      Get the underlying nio buffer.
      Specified by:
      getBuffer in class IndexBufferData<ShortBuffer>
      Returns:
      the buffer
    • asIntBuffer

      public IntBuffer asIntBuffer()
      Specified by:
      asIntBuffer in class IndexBufferData<ShortBuffer>
      Returns:
      a new, non-direct IntBuffer containing a snapshot of the contents of this buffer.
    • makeCopy

      public ShortBufferData makeCopy()
      Specified by:
      makeCopy in class IndexBufferData<ShortBuffer>
      Returns:
      a deep copy of this buffer data object