jodd.util.buffer
Class FastByteBuffer

java.lang.Object
  extended by jodd.util.buffer.FastByteBuffer

public class FastByteBuffer
extends java.lang.Object

Fast, fast byte buffer.


Constructor Summary
FastByteBuffer()
          Creates a new byte buffer.
FastByteBuffer(int size)
          Creates a new byte buffer, with a buffer capacity of the specified size, in bytes.
 
Method Summary
 FastByteBuffer append(byte element)
          Appends single byte to buffer.
 FastByteBuffer append(byte[] array)
          Appends byte array to buffer.
 FastByteBuffer append(byte[] array, int off, int len)
          Appends byte array to buffer.
 FastByteBuffer append(FastByteBuffer buff)
          Appends another fast buffer to this one.
 byte[] array(int index)
          Returns byte inner array chunk at given index.
 void clear()
          Resets the buffer content.
 byte get(int index)
          Returns byte element at given index.
 int index()
          Returns current index of inner byte array chunk.
 boolean isEmpty()
          Tests if this buffer has no elements.
 int offset()
          Returns the offset of last used element in current inner array chunk.
 int size()
          Returns buffer size.
 byte[] toArray()
          Creates byte array from buffered content.
 byte[] toArray(int start, int len)
          Creates byte subarray from buffered content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastByteBuffer

public FastByteBuffer()
Creates a new byte buffer. The buffer capacity is initially 1024 bytes, though its size increases if necessary.


FastByteBuffer

public FastByteBuffer(int size)
Creates a new byte buffer, with a buffer capacity of the specified size, in bytes.

Parameters:
size - the initial size.
Throws:
java.lang.IllegalArgumentException - if size is negative.
Method Detail

append

public FastByteBuffer append(byte[] array,
                             int off,
                             int len)
Appends byte array to buffer.


append

public FastByteBuffer append(byte[] array)
Appends byte array to buffer.


append

public FastByteBuffer append(byte element)
Appends single byte to buffer.


append

public FastByteBuffer append(FastByteBuffer buff)
Appends another fast buffer to this one.


size

public int size()
Returns buffer size.


isEmpty

public boolean isEmpty()
Tests if this buffer has no elements.


index

public int index()
Returns current index of inner byte array chunk. Represents the index of last used inner array chunk.


offset

public int offset()
Returns the offset of last used element in current inner array chunk.


array

public byte[] array(int index)
Returns byte inner array chunk at given index. May be used for iterating inner chunks in fast manner.


clear

public void clear()
Resets the buffer content.


toArray

public byte[] toArray()
Creates byte array from buffered content.


toArray

public byte[] toArray(int start,
                      int len)
Creates byte subarray from buffered content.


get

public byte get(int index)
Returns byte element at given index.



Copyright © 2003-2012 Jodd Team