org.indy.util
Class IndyBuffer

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.ByteArrayOutputStream
              |
              +--org.indy.util.IndyBuffer

public class IndyBuffer
extends java.io.ByteArrayOutputStream

A light weight read-write buffer used by Indy. NOTE: This class is not thread-safe; if you wish to use this IdBuffer in a multi-threaded environment you must provide your own synchronization.

Version:
1.0
Author:
OTG

Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
IndyBuffer()
           
 
Method Summary
 void clear()
          Clears the buffer
 void peek(byte[] b, int off, int len)
          Returns some data from the buffer non-destructively (i.e.
 void read(byte[] b, int off, int len)
          Reads some bytes from the buffer.
protected  void readerIsDirty()
          Checks whether reader's buffer is in sync with writer's, and refreshes if neccessary.
 java.lang.String readLine()
          Attempts to read a line of text from the buffer.
 int size()
          Returns the current number of bytes in the buffer.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndyBuffer

public IndyBuffer()
Method Detail

readerIsDirty

protected void readerIsDirty()
Checks whether reader's buffer is in sync with writer's, and refreshes if neccessary.

clear

public void clear()
Clears the buffer

peek

public void peek(byte[] b,
                 int off,
                 int len)
Returns some data from the buffer non-destructively (i.e. doesn't remove it).
Parameters:
b - An array of bytes to read into
off - The offset to start filling b at
len - The number of bytes to read
Throws:
java.lang.IndexOutOfBoundsException - If off or len are invalid
See Also:
read(byte[],int,int)

read

public void read(byte[] b,
                 int off,
                 int len)
Reads some bytes from the buffer.
Parameters:
b - An array of bytes to read into.
off - The offset to start filling b at
len - The number of bytes to read
See Also:
peek(byte[],int,int)

readLine

public java.lang.String readLine()
                          throws java.io.IOException
Attempts to read a line of text from the buffer. See the general contract of OpenByteArryInputStream#readLine().
Returns:
A line of text from the buffer, or null if no line is found.
Throws:
java.io.IOException - If an IO error occurrs.

size

public int size()
Returns the current number of bytes in the buffer.
Overrides:
size in class java.io.ByteArrayOutputStream
Returns:
The current size of the buffer in bytes.


Copyright © 2002-2002 IndyJ. All Rights Reserved.