org.ajax4jsf.io

## Class ByteBuffer

- java.lang.Object
- - org.ajax4jsf.io.ByteBuffer

-     public class ByteBuffer
      extends Object

  A single link in chain of byte arrays.
  Author:
    glory

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ByteBuffer(byte[] bytes)` Creates instance of ByteBuffer already filled by bytes.
    `ByteBuffer(int cacheSize)` Creates instance of ByteBuffer with byte array of required length.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ByteBuffer` | `append(byte c)` Appends byte to array if there are unfilled positions in it.
    `ByteBuffer` | `append(byte[] bs, int off, int len)` Appends segment of a byte array to array if there are unfilled positions in it.
    `void` | `compact()`
    `byte` | `getByteAt(int index)` Returns byte at index.
    `byte[]` | `getBytes()` Returns stored byte array.
    `int` | `getCacheSize()` Returns capacity of this link.
    `ByteBuffer` | `getLast()`
    `ByteBuffer` | `getNext()` Returns the next link in the chain.
    `ByteBuffer` | `getPrevious()` Returns the previous link in the chain.
    `int` | `getTotalSize()` Returns total number of bytes stored in this link and all its predecessors.
    `int` | `getUsedSize()` Returns actual number of byte stored in this link.
    `void` | `reset()` Resets this byte buffer to empty state
    `void` | `setNext(ByteBuffer b)` Sets the next link in the chain.
    `CharBuffer` | `toCharBuffer()` Transforms this instance to instance of CharBuffer (a link of chain of char arrays).
    `CharBuffer` | `toCharBuffer(String encoding)` Transforms this instance to instance of CharBuffer (a link of chain of char arrays).

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

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

- - ### Constructor Detail

    - #### ByteBuffer

          public ByteBuffer(byte[] bytes)

      Creates instance of ByteBuffer already filled by bytes.
      Parameters:
        `bytes` -

    - #### ByteBuffer

          public ByteBuffer(int cacheSize)

      Creates instance of ByteBuffer with byte array of required length.
      Parameters:
        `cacheSize` - length of byte array

  - ### Method Detail

    - #### append

          public ByteBuffer append(byte c)

      Appends byte to array if there are unfilled positions in it. Otherwize creates next link in the chain, and appends the byte to it.
      Parameters:
        `c` -
      Returns:
        instance of ByteBuffer to which byte was appended.

    - #### append

          public ByteBuffer append(byte[] bs,
                          int off,
                          int len)

      Appends segment of a byte array to array if there are unfilled positions in it. Otherwize creates next link in the chain, and appends data to it.
      Parameters:
        `bs` -
        `off` -
        `len` -
      Returns:
        instance of ByteBuffer to which byte array was appended.

    - #### getBytes

          public byte[] getBytes()

      Returns stored byte array.
      Returns:
        stored byte array

    - #### getByteAt

          public byte getByteAt(int index)

      Returns byte at index. No check is fulfilled to provide high speed.
      Parameters:
        `index` -
      Returns:
        byte at index

    - #### getUsedSize

          public int getUsedSize()

      Returns actual number of byte stored in this link.
      Returns:
        actual number of byte stored in this link

    - #### getCacheSize

          public int getCacheSize()

      Returns capacity of this link.
      Returns:
        capacity of this link

    - #### getTotalSize

          public int getTotalSize()

      Returns total number of bytes stored in this link and all its predecessors.
      Returns:
        total number of bytes stored in this link and all its predecessors

    - #### getPrevious

          public ByteBuffer getPrevious()

      Returns the previous link in the chain.
      Returns:
        the previous link in the chain

    - #### getNext

          public ByteBuffer getNext()

      Returns the next link in the chain.
      Returns:
        the next link in the chain

    - #### setNext

          public void setNext(ByteBuffer b)

      Sets the next link in the chain.
      Parameters:
        `b` -

    - #### toCharBuffer

          public CharBuffer toCharBuffer(String encoding)
                                  throws UnsupportedEncodingException

      Transforms this instance to instance of CharBuffer (a link of chain of char arrays).
      Parameters:
        `encoding` -
      Returns:
        link of chain of char arrays
      Throws:
        `UnsupportedEncodingException`

    - #### toCharBuffer

          public CharBuffer toCharBuffer()

      Transforms this instance to instance of CharBuffer (a link of chain of char arrays).
      Returns:
        link of chain of char arrays

    - #### reset

          public void reset()

      Resets this byte buffer to empty state
      Since:
        3.3.0

    - #### compact

          public void compact()

      Since:
        4.0

    - #### getLast

          public ByteBuffer getLast()

Copyright © 2014 JBoss by Red Hat. All Rights Reserved.