com.jogamp.common.util

## Class Bitstream.ByteBufferStream

- java.lang.Object
- - com.jogamp.common.util.Bitstream.ByteBufferStream

- All Implemented Interfaces:
    Bitstream.ByteStream<ByteBuffer>
  Enclosing class:
    Bitstream<T>

      public static class Bitstream.ByteBufferStream
      extends Object
      implements Bitstream.ByteStream<ByteBuffer>

  Specific `byte stream`.

  Can handle `input` and `output` operations.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Bitstream.ByteBufferStream(ByteBuffer stream)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canInput()` Return true if stream can handle input, i.e.
    `boolean` | `canOutput()` Return true if stream can handle output, i.e.
    `void` | `close()` Closing the underlying stream, implies `Bitstream.ByteStream.flush()`.
    `void` | `flush()` Synchronizes all underlying `output stream` operations, or do nothing.
    `ByteBuffer` | `getStream()` Returns the underlying stream
    `void` | `mark(int readLimit)` Set markpos to current position, allowing the stream to be `Bitstream.ByteStream.reset()`.
    `long` | `position()` Returns the byte position in the stream.
    `int` | `read()` Reads one byte from the stream.
    `void` | `reset()` Reset stream position to markpos as set via `Bitstream.ByteStream.mark(int)`.
    `void` | `setStream(ByteBuffer stream)` Sets the underlying stream, without `Bitstream.ByteStream.close()`ing the previous one.
    `long` | `skip(long n)` It is implementation dependent, whether backward skip giving a negative number is supported or not.
    `int` | `write(byte val)` Writes one byte, to the stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Bitstream.ByteBufferStream

          public Bitstream.ByteBufferStream(ByteBuffer stream)

  - ### Method Detail

    - #### setStream

          public void setStream(ByteBuffer stream)

      Description copied from interface: `Bitstream.ByteStream`
      Sets the underlying stream, without `Bitstream.ByteStream.close()`ing the previous one.
      Specified by:
        `setStream` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### getStream

          public ByteBuffer getStream()

      Description copied from interface: `Bitstream.ByteStream`
      Returns the underlying stream
      Specified by:
        `getStream` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### close

          public void close()

      Description copied from interface: `Bitstream.ByteStream`
      Closing the underlying stream, implies `Bitstream.ByteStream.flush()`.

      Implementation will `null` the stream references, hence `Bitstream.ByteStream.setStream(Object)` must be called before re-using instance.

      Specified by:
        `close` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### flush

          public void flush()

      Description copied from interface: `Bitstream.ByteStream`
      Synchronizes all underlying `output stream` operations, or do nothing.
      Specified by:
        `flush` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### canInput

          public boolean canInput()

      Description copied from interface: `Bitstream.ByteStream`
      Return true if stream can handle input, i.e. `Bitstream.ByteStream.read()`.
      Specified by:
        `canInput` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### canOutput

          public boolean canOutput()

      Description copied from interface: `Bitstream.ByteStream`
      Return true if stream can handle output, i.e. `Bitstream.ByteStream.write(byte)`
      Specified by:
        `canOutput` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### position

          public long position()

      Description copied from interface: `Bitstream.ByteStream`
      Returns the byte position in the stream.
      Specified by:
        `position` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### skip

          public long skip(long n)

      Description copied from interface: `Bitstream.ByteStream`
      It is implementation dependent, whether backward skip giving a negative number is supported or not.
      Specified by:
        `skip` in interface `Bitstream.ByteStream<ByteBuffer>`
      Parameters:
        `n` - number of bytes to skip
      Returns:
        actual skipped bytes

    - #### mark

          public void mark(int readLimit)

      Description copied from interface: `Bitstream.ByteStream`
      Set markpos to current position, allowing the stream to be `Bitstream.ByteStream.reset()`.
      Specified by:
        `mark` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### reset

          public void reset()
                     throws IllegalStateException

      Description copied from interface: `Bitstream.ByteStream`
      Reset stream position to markpos as set via `Bitstream.ByteStream.mark(int)`.

      markpos is kept, hence `Bitstream.ByteStream.reset()` can be called multiple times.

      Specified by:
        `reset` in interface `Bitstream.ByteStream<ByteBuffer>`
      Throws:
        `IllegalStateException` - if markpos has not been set via `Bitstream.ByteStream.mark(int)` or reset operation failed.

    - #### read

          public int read()

      Description copied from interface: `Bitstream.ByteStream`
      Reads one byte from the stream.

      Returns `Bitstream.EOS` is end-of-stream is reached, otherwise the resulting value.

      Specified by:
        `read` in interface `Bitstream.ByteStream<ByteBuffer>`

    - #### write

          public int write(byte val)

      Description copied from interface: `Bitstream.ByteStream`
      Writes one byte, to the stream.

      Returns `Bitstream.EOS` is end-of-stream is reached, otherwise the written value.

      Specified by:
        `write` in interface `Bitstream.ByteStream<ByteBuffer>`