org.eclipse.jetty.io

## Class ByteArrayBuffer

- java.lang.Object
- - org.eclipse.jetty.io.AbstractBuffer
  - - org.eclipse.jetty.io.ByteArrayBuffer

- All Implemented Interfaces:
    Cloneable, Buffer
  Direct Known Subclasses:
    ByteArrayBuffer.CaseInsensitive, IndirectNIOBuffer

      public class ByteArrayBuffer
      extends AbstractBuffer

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ByteArrayBuffer.CaseInsensitive`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Buffer

      `Buffer.CaseInsensitve`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected byte[]` | `_bytes`

    - ### Fields inherited from class org.eclipse.jetty.io.AbstractBuffer

      `__IMMUTABLE, __READONLY, __READWRITE, __VOLATILE, _access, _get, _hash, _hashGet, _hashPut, _mark, _put, _string, _view, _volatile`

    - ### Fields inherited from interface org.eclipse.jetty.io.Buffer

      `IMMUTABLE, NON_VOLATILE, READONLY, READWRITE, VOLATILE`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `ByteArrayBuffer(byte[] bytes)`
    `` | `ByteArrayBuffer(byte[] bytes, int index, int length)`
    `` | `ByteArrayBuffer(byte[] bytes, int index, int length, int access)`
    `` | `ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)`
    `` | `ByteArrayBuffer(int size)`
    `protected` | `ByteArrayBuffer(int size, int access, boolean isVolatile)`
    `` | `ByteArrayBuffer(String value)`
    `` | `ByteArrayBuffer(String value, boolean immutable)`
    `` | `ByteArrayBuffer(String value, String encoding)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `array()` Get the underlying array, if one exists.
    `int` | `capacity()` The capacity of the buffer.
    `void` | `compact()` Compact the buffer by discarding bytes before the postion (or mark if set).
    `boolean` | `equals(Object obj)`
    `boolean` | `equalsIgnoreCase(Buffer b)`
    `byte` | `get()` Get the byte at the current getIndex and increment it.
    `int` | `hashCode()`
    `byte` | `peek(int index)` Get the byte at a specific index in the buffer.
    `int` | `peek(int index, byte[] b, int offset, int length)`
    `int` | `poke(int index, Buffer src)` Put the contents of the buffer at the specific index.
    `void` | `poke(int index, byte b)` Put a specific byte to a specific getIndex.
    `int` | `poke(int index, byte[] b, int offset, int length)` Put a specific byte to a specific getIndex.
    `int` | `readFrom(InputStream in, int max)` Read the buffer's contents from the input stream
    `int` | `space()` the space remaining in the buffer.
    `void` | `writeTo(OutputStream out)` Write the buffer's contents to the output stream

    - ### Methods inherited from class org.eclipse.jetty.io.AbstractBuffer

      `asArray, asImmutableBuffer, asMutableBuffer, asNonVolatileBuffer, asReadOnlyBuffer, buffer, clear, duplicate, get, get, getIndex, hasContent, isImmutable, isReadOnly, isVolatile, length, mark, mark, markIndex, peek, peek, put, put, put, put, putIndex, reset, rewind, setGetIndex, setMarkIndex, setPutIndex, skip, slice, sliceFromMark, sliceFromMark, toDebugString, toDetailString, toString, toString, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _bytes

          protected final byte[] _bytes

  - ### Constructor Detail

    - #### ByteArrayBuffer

          protected ByteArrayBuffer(int size,
                         int access,
                         boolean isVolatile)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(byte[] bytes)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(byte[] bytes,
                         int index,
                         int length)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(byte[] bytes,
                         int index,
                         int length,
                         int access)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(byte[] bytes,
                         int index,
                         int length,
                         int access,
                         boolean isVolatile)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(int size)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(String value)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(String value,
                         boolean immutable)

    - #### ByteArrayBuffer

          public ByteArrayBuffer(String value,
                         String encoding)
                          throws UnsupportedEncodingException

      Throws:
        `UnsupportedEncodingException`

  - ### Method Detail

    - #### array

          public byte[] array()

      Description copied from interface: `Buffer`
      Get the underlying array, if one exists.
      Returns:
        a `byte[]` backing this buffer or null if none exists.

    - #### capacity

          public int capacity()

      Description copied from interface: `Buffer`
      The capacity of the buffer. This is the maximum putIndex that may be set.
      Returns:
        an `int` value

    - #### compact

          public void compact()

      Description copied from interface: `Buffer`
      Compact the buffer by discarding bytes before the postion (or mark if set). Bytes from the getIndex (or mark) to the putIndex are moved to the beginning of the buffer and the values adjusted accordingly.
      Specified by:
        `compact` in interface `Buffer`
      Overrides:
        `compact` in class `AbstractBuffer`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `AbstractBuffer`

    - #### equalsIgnoreCase

          public boolean equalsIgnoreCase(Buffer b)

      Specified by:
        `equalsIgnoreCase` in interface `Buffer`
      Overrides:
        `equalsIgnoreCase` in class `AbstractBuffer`
      Returns:
        a `boolean` value true if case sensitive comparison on this buffer

    - #### get

          public byte get()

      Description copied from interface: `Buffer`
      Get the byte at the current getIndex and increment it.
      Specified by:
        `get` in interface `Buffer`
      Overrides:
        `get` in class `AbstractBuffer`
      Returns:
        The `byte` value from the current getIndex.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `AbstractBuffer`

    - #### peek

          public byte peek(int index)

      Description copied from interface: `Buffer`
      Get the byte at a specific index in the buffer.
      Parameters:
        `index` - an `int` value
      Returns:
        a `byte` value

    - #### peek

          public int peek(int index,
                 byte[] b,
                 int offset,
                 int length)

      Parameters:
        `index` - an `int` value
        `b` - The byte array to peek into
        `offset` - The offset into the array to start peeking
        `length` - an `int` value
      Returns:
        The number of bytes actually peeked

    - #### poke

          public void poke(int index,
                  byte b)

      Description copied from interface: `Buffer`
      Put a specific byte to a specific getIndex.
      Parameters:
        `index` - an `int` value
        `b` - a `byte` value

    - #### poke

          public int poke(int index,
                 Buffer src)

      Description copied from interface: `Buffer`
      Put the contents of the buffer at the specific index.
      Specified by:
        `poke` in interface `Buffer`
      Overrides:
        `poke` in class `AbstractBuffer`
      Parameters:
        `index` - an `int` value
        `src` - a `Buffer`. If the source buffer is not modified
      Returns:
        The number of bytes actually poked

    - #### poke

          public int poke(int index,
                 byte[] b,
                 int offset,
                 int length)

      Description copied from interface: `Buffer`
      Put a specific byte to a specific getIndex.
      Specified by:
        `poke` in interface `Buffer`
      Overrides:
        `poke` in class `AbstractBuffer`
      Parameters:
        `index` - an `int` value
        `b` - a `byte array` value
      Returns:
        The number of bytes actually poked

    - #### writeTo

          public void writeTo(OutputStream out)
                       throws IOException

      Description copied from interface: `Buffer`
      Write the buffer's contents to the output stream
      Specified by:
        `writeTo` in interface `Buffer`
      Overrides:
        `writeTo` in class `AbstractBuffer`
      Throws:
        `IOException`

    - #### readFrom

          public int readFrom(InputStream in,
                     int max)
                       throws IOException

      Description copied from interface: `Buffer`
      Read the buffer's contents from the input stream
      Specified by:
        `readFrom` in interface `Buffer`
      Overrides:
        `readFrom` in class `AbstractBuffer`
      Parameters:
        `in` - input stream
        `max` - maximum number of bytes that may be read
      Returns:
        actual number of bytes read or -1 for EOF
      Throws:
        `IOException`

    - #### space

          public int space()

      Description copied from interface: `Buffer`
      the space remaining in the buffer.
      Specified by:
        `space` in interface `Buffer`
      Overrides:
        `space` in class `AbstractBuffer`
      Returns:
        capacity - putIndex

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.