org.jasn.util
Class DynamicBuffer

java.lang.Object
  extended byorg.jasn.util.DynamicBuffer

public class DynamicBuffer
extends Object

This class implements a buffer of bytes that grows as needed.


Constructor Summary
DynamicBuffer(int capacity)
          Creates a byte buffer with the specified initial capacity.
 
Method Summary
 int getPosition()
          Returns this buffer's position.
 void put(byte b)
          Writes the given byte into this buffer at the current position, and then increments the position.
 void put(byte[] b, int off, int len)
           
 void rewind()
           
 void setPosition(int position)
          Sets this buffer's position.
 void writeTo(OutputStream out)
          Writes the bytes contained in this buffer into the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicBuffer

public DynamicBuffer(int capacity)
Creates a byte buffer with the specified initial capacity.

Parameters:
capacity - the initial capacity of the buffer. throws IllegalArgumentException if the specified initial capacity is negative.
Method Detail

put

public void put(byte b)
Writes the given byte into this buffer at the current position, and then increments the position.

Parameters:
b - the byte to be written.

put

public void put(byte[] b,
                int off,
                int len)

getPosition

public int getPosition()
Returns this buffer's position.

Returns:
the position of this buffer.

setPosition

public void setPosition(int position)
Sets this buffer's position.

Parameters:
position - the new position value; must be non-negative and no larger than the current limit

writeTo

public void writeTo(OutputStream out)
             throws IOException
Writes the bytes contained in this buffer into the specified output stream.

Throws:
IOException - if an I/O error occured.

rewind

public void rewind()


Copyright © 2004 Nicolas Vraux. All Rights Reserved.