com.caucho.util
Class ByteBuffer

java.lang.Object
  |
  +--com.caucho.util.ByteBuffer

public final class ByteBuffer
extends java.lang.Object

A variable-length byte buffer, similar to a character buffer.

The byte buffer is unsynchronized.


Constructor Summary
ByteBuffer()
           
ByteBuffer(int minimumCapacity)
           
 
Method Summary
 void add(byte[] buffer, int offset, int length)
           
 void add(char[] s, int offset, int len)
           
 void add(CharBuffer cb)
           
 void add(int data)
           
 void add(int i, byte[] buffer, int offset, int length)
          Inserts a byte array
 void add(int i, int data)
          Inserts a byte array
 void add(java.lang.String s)
           
 void addDouble(double v)
           
 void addInt(int s)
           
 void addInt(int i, int s)
           
 void addShort(int s)
           
 void addShort(int i, int s)
           
 void addString(java.lang.String s)
           
 void append(byte[] buffer, int offset, int length)
          Inserts a byte array
 void append(int b)
          Add a byte to the buffer.
 void append(java.lang.String string)
          Appends an int (little endian) in the buffer
 void appendInt(int v)
          Appends an int (little endian) in the buffer
 void appendShort(int s)
          Appends a short (little endian) in the buffer
 byte byteAt(int i)
          Returns the byte at the specified offset.
 int capacity()
          Returns the actual capacity of the buffer, i.e.
 void clear()
           
 java.lang.Object clone()
          Clones the buffer
 java.io.InputStream createInputStream()
           
 java.io.OutputStream createOutputStream()
           
 ReadStream createReadStream()
           
 void ensureCapacity(int minimumCapacity)
          Ensure the buffer can hold at least 'minimumCapacity' bytes.
 boolean equals(java.lang.Object b)
           
 byte get(int i)
           
 byte[] getBuffer()
          Returns the byte array for the buffer.
 int getInt(int i)
           
 int getLength()
          Returns the buffer length
 short getShort(int i)
           
 int hashCode()
           
 void insert(int i, byte[] buffer, int offset, int length)
           
 int length()
          Returns the buffer length
 void print(int i)
           
 void remove(int begin, int length)
           
 void replace(int i, byte[] buffer, int offset, int length)
          Inserts a byte array
 void replaceInt(int i, int v)
          Inserts a int (little endian) into the buffer
 void replaceShort(int i, int s)
          Inserts a short into the buffer
 void set(int i, byte[] buffer, int offset, int length)
           
 void set(int i, int data)
           
 void setByteAt(int i, int b)
          Returns the byte at the specified offset.
 void setInt(int i, int v)
           
 void setLength(int len)
          Set the buffer.
 void setShort(int i, int s)
           
 int size()
           
 java.lang.String toString()
          String representation of the buffer.
 java.lang.String toString(java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteBuffer

public ByteBuffer(int minimumCapacity)

ByteBuffer

public ByteBuffer()
Method Detail

capacity

public int capacity()
Returns the actual capacity of the buffer, i.e. how many bytes it can hold.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

ensureCapacity

public void ensureCapacity(int minimumCapacity)
Ensure the buffer can hold at least 'minimumCapacity' bytes.

length

public int length()
Returns the buffer length

size

public int size()

getLength

public int getLength()
Returns the buffer length

setLength

public void setLength(int len)
Set the buffer.

clear

public void clear()

getBuffer

public byte[] getBuffer()
Returns the byte array for the buffer.

append

public void append(int b)
Add a byte to the buffer.

add

public void add(int i,
                byte[] buffer,
                int offset,
                int length)
Inserts a byte array

add

public void add(byte[] buffer,
                int offset,
                int length)

add

public void add(int i,
                int data)
Inserts a byte array

add

public void add(int data)

set

public void set(int i,
                byte[] buffer,
                int offset,
                int length)

set

public void set(int i,
                int data)

insert

public void insert(int i,
                   byte[] buffer,
                   int offset,
                   int length)

replace

public void replace(int i,
                    byte[] buffer,
                    int offset,
                    int length)
Inserts a byte array

append

public void append(byte[] buffer,
                   int offset,
                   int length)
Inserts a byte array

replaceShort

public void replaceShort(int i,
                         int s)
Inserts a short into the buffer

appendShort

public void appendShort(int s)
Appends a short (little endian) in the buffer

addShort

public void addShort(int s)

addShort

public void addShort(int i,
                     int s)

setShort

public void setShort(int i,
                     int s)

replaceInt

public void replaceInt(int i,
                       int v)
Inserts a int (little endian) into the buffer

appendInt

public void appendInt(int v)
Appends an int (little endian) in the buffer

addInt

public void addInt(int s)

addInt

public void addInt(int i,
                   int s)

setInt

public void setInt(int i,
                   int v)

addDouble

public void addDouble(double v)

addString

public void addString(java.lang.String s)

add

public void add(java.lang.String s)

add

public void add(char[] s,
                int offset,
                int len)

add

public void add(CharBuffer cb)

remove

public void remove(int begin,
                   int length)

append

public void append(java.lang.String string)
Appends an int (little endian) in the buffer

byteAt

public byte byteAt(int i)
Returns the byte at the specified offset.

setByteAt

public void setByteAt(int i,
                      int b)
Returns the byte at the specified offset.

get

public byte get(int i)

getShort

public short getShort(int i)

getInt

public int getInt(int i)

print

public void print(int i)

clone

public java.lang.Object clone()
Clones the buffer
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object b)
Overrides:
equals in class java.lang.Object

createInputStream

public java.io.InputStream createInputStream()

createOutputStream

public java.io.OutputStream createOutputStream()

createReadStream

public ReadStream createReadStream()

toString

public java.lang.String toString()
String representation of the buffer.
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String encoding)