org.ajax4jsf.io

## Class CharBuffer

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

-     public class CharBuffer
      extends Object

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CharBuffer(char[] chars)` Creates instance of CharBuffer already filled by chars.
    `CharBuffer(int cacheSize)` Creates instance of CharBuffer with char array of required length.

  - ### Method Summary

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

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

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

- - ### Constructor Detail

    - #### CharBuffer

          public CharBuffer(char[] chars)

      Creates instance of CharBuffer already filled by chars.
      Parameters:
        `chars` -

    - #### CharBuffer

          public CharBuffer(int cacheSize)

      Creates instance of CharBuffer with char array of required length.
      Parameters:
        `cacheSize` - length of char array

  - ### Method Detail

    - #### append

          public CharBuffer append(char c)

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

    - #### append

          public CharBuffer append(char[] cs,
                                   int off,
                                   int len)

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

    - #### getChars

          public char[] getChars()

      Returns stored char array.
      Returns:
        stored char array

    - #### getCharAt

          public char getCharAt(int index)

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

    - #### getUsedSize

          public int getUsedSize()

      Returns actual number of characters stored in this link.
      Returns:
        actual number of characters 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 characters stored in this link and all its predecessors.
      Returns:
        total number of characters stored in this link and all its predecessors

    - #### getPrevious

          public CharBuffer getPrevious()

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

    - #### getNext

          public CharBuffer getNext()

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

    - #### setNext

          public void setNext(CharBuffer b)

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

    - #### toByteBuffer

          public ByteBuffer toByteBuffer(String encoding)
                                  throws UnsupportedEncodingException

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

    - #### toByteBuffer

          public ByteBuffer toByteBuffer()

      Transforms this instance to instance of ByteBuffer (a link of chain of byte arrays).
      Returns:
        link of chain of byte arrays

    - #### reset

          public void reset()

      Resets this char buffer to empty state
      Since:
        3.3.0

    - #### compact

          public void compact()

      Since:
        4.0

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