OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

com.ibm.opencard.buffer
Class DataBuffer

java.lang.Object
  |
  +--com.ibm.opencard.buffer.Buffer
        |
        +--com.ibm.opencard.buffer.DataBuffer

public class DataBuffer
extends Buffer

A DataBuffer is supposed to hold arbitrary data without a special structure.
A VariableTLVBuffer object has a certain capacity which is determined by the size of the byte array provided to the constructor. If this capacity is exceeded by adding new entries, the capacity is increased by reallocation of memory. If you want to avoid reallocation of memory for performance reasons, you should provided a byte array of sufficient size to the constructor.

Version:
$Id: DataBuffer.java,v 1.1 1999/12/02 16:06:02 damke Exp $
See Also:
Request, Buffer, TLVBuffer, VariableTLVBuffer

Constructor Summary
DataBuffer(byte[] data, int size)
          This constructor creates a new Buffer from the given values.
 
Method Summary
 DataBuffer append(byte[] b)
          Append the contents of a given byte arras to the contents of this buffer.
protected  Buffer concatenate(Buffer buffer)
          This method concatenates the contents of a given Buffer to the contents of this buffer.
 DataBuffer set(byte[] b)
          Set the contents of this data buffer to a given byte array.
 void setSize(int newSize)
          This method sets the size of the data in the buffer.
 
Methods inherited from class com.ibm.opencard.buffer.Buffer
clear, data, size, toHexString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataBuffer

public DataBuffer(byte[] data,
                  int size)
This constructor creates a new Buffer from the given values.
Parameters:
data - A byte array containing data
size - The size of valid data contained in the data array. If this size is bigger than the actual length of the byte array, it is set to the length of the byte array.
Method Detail

setSize

public void setSize(int newSize)
This method sets the size of the data in the buffer.
Parameters:
newSize - - the new buffer size.
Returns:
This buffer's size.

concatenate

protected Buffer concatenate(Buffer buffer)
This method concatenates the contents of a given Buffer to the contents of this buffer.
Parameters:
buffer - The buffer to be concatenated to the buffer.
Returns:
This Buffer object

set

public DataBuffer set(byte[] b)
Set the contents of this data buffer to a given byte array. All previous data is lost.
Parameters:
b - The byte array to be copied into the buffer.
Returns:
This Buffer object

append

public DataBuffer append(byte[] b)
Append the contents of a given byte arras to the contents of this buffer.
Parameters:
b - The byte array to be appended to the buffer.
Returns:
This Buffer object