uk.org.ogsadai.common
Class SimpleBlockBuffer

java.lang.Object
  |
  +--uk.org.ogsadai.common.SimpleBlockBuffer
All Implemented Interfaces:
BlockBuffer

public class SimpleBlockBuffer
extends java.lang.Object
implements BlockBuffer

A simple BlockBuffer for appending sequences of java.lang.String, byte[] or org.w3c.dom.Node objects.

The aggregated block returned by the toBlock method will be either a String containing all the string and node data, or a byte[] containing all the binary data.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private static DAILogger LOG
           
private  java.io.ByteArrayOutputStream mBinaryData
           
private  int mSize
           
private  java.lang.StringBuffer mStringData
           
 
Constructor Summary
SimpleBlockBuffer()
           
 
Method Summary
 void appendBlock(java.lang.Object block)
          Appends the specified block to the buffer.
private  void appendByteArray(byte[] block)
          Append a byte array to the buffer.
private  void appendNode(java.lang.Object block)
          Append an org.w3c.dom.Node to the buffer.
 int size()
          Returns a count of the number of blocks that have been appended to the buffer.
 java.lang.Object toBlock()
          Returns a single block containing all the data appended to the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

LOG

private static final DAILogger LOG

mStringData

private final java.lang.StringBuffer mStringData

mBinaryData

private final java.io.ByteArrayOutputStream mBinaryData

mSize

private int mSize
Constructor Detail

SimpleBlockBuffer

public SimpleBlockBuffer()
Method Detail

appendBlock

public void appendBlock(java.lang.Object block)
                 throws OutOfMemoryException
Description copied from interface: BlockBuffer
Appends the specified block to the buffer.

Specified by:
appendBlock in interface BlockBuffer
Parameters:
block - The block to append.
Throws:
OutOfMemoryException - if there is not enough memory to retrieve the block.

toBlock

public java.lang.Object toBlock()
                         throws OutOfMemoryException
Description copied from interface: BlockBuffer
Returns a single block containing all the data appended to the buffer. If not data has been appended then null is returned.

Specified by:
toBlock in interface BlockBuffer
Returns:
the data.
Throws:
OutOfMemoryException - if there is not enough memory to retrieve the block.

appendByteArray

private void appendByteArray(byte[] block)
                      throws OutOfMemoryException
Append a byte array to the buffer.

Parameters:
block - Byte array.
Throws:
OutOfMemoryException - if there is no memory available to append the block.

appendNode

private void appendNode(java.lang.Object block)
                 throws OutOfMemoryException
Append an org.w3c.dom.Node to the buffer.

Parameters:
block - Node object.
Throws:
OutOfMemoryException - if there is no memory available to append the block.

size

public int size()
Description copied from interface: BlockBuffer
Returns a count of the number of blocks that have been appended to the buffer.

Specified by:
size in interface BlockBuffer
Returns:
the count.