Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboCharBuffer

java.lang.Object
 |
 +--com.sssw.fw.util.EboCharBuffer

public class EboCharBuffer
extends Object

EboCharBuffer is a wrapper class around a char array. A EboCharBuffer API allows reads and writes without worrying about underlying char array. This class is intended to be used as the underlying storage mechanism for pair(s) of Reader/Writer classes that can attach/detach its underlying storage facility. Please note, this class is not synchronized. It is up to the user of this storage facility to handle synchronization.


Constructor Summary
EboCharBuffer()
          Creates a EboCharBuffer with the default byte array size and chunk count
EboCharBuffer(char[] buf)
          Creates a EboCharBuffer from the specified array of chars.
EboCharBuffer(char[] buf, int inuse)
          Creates a EboCharBuffer from the specified array of chars.
EboCharBuffer(int size)
          Creates a EboCharBuffer with the specified byte array size Will also grow by this size.
EboCharBuffer(Reader in)
          Creates a EboCharBuffer from the contents of the specified Reader with the default byte array size
EboCharBuffer(Reader in, int incr)
          Creates a EboCharBuffer from the contents of the specified Reader.
EboCharBuffer(String s)
          Creates a EboCharBuffer from the specified string
 
Method Summary
 int available()
          Get the size of the available buffer space.
 String getEncoding()
          Return a character string representing the encoding of the characters in this buffer.
 int getPosition()
          Returns the current position.
 int read()
          Read the next char from the buffer.
 int read(char[] buf, int offset, int len)
          Read a stream of chars until the specified output array is full.
 void reset()
          Re-set the buffer to the empty state.
 void resetPos()
          Reset the cursor to start of buffer for reading
 boolean seek(int desiredPosition)
          Move the cursor position.
 int size()
          Get the current size of the buffer that is in use.
 long skip(long skipCnt)
          Move the cursor position forward by specified number of chars.
 char[] toCharArray()
          Get a copy of the in use portion of the buffer as a char array
 String toString()
          Get the char array as a String
 void write(char[] chars, int offset, int len)
          Write the specified number of chars to the buffer.
 void write(int b)
          Write the specified char to the buffer.
 void writeTo(Writer out)
          Writes the complete contents of this char buffer to the specified output writer argument.
 int writeTo(Writer out, int len)
          Write up to n characters starting at the current read position to the specified Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EboCharBuffer

public EboCharBuffer()
Creates a EboCharBuffer with the default byte array size and chunk count

EboCharBuffer

public EboCharBuffer(int size)
Creates a EboCharBuffer with the specified byte array size Will also grow by this size.
Parameters:
size - the initial buffer size

EboCharBuffer

public EboCharBuffer(char[] buf)
Creates a EboCharBuffer from the specified array of chars. The specified buffer is not copied, but is used in place!! This constructor also assumes that the char array is fully inuse!!
Parameters:
buf - the input buffer (not copied)

EboCharBuffer

public EboCharBuffer(char[] buf,
                     int inuse)
Creates a EboCharBuffer from the specified array of chars. Allows the buf not to be full size.
Parameters:
buf - the input buffer
inuse - number of chars used in input buffer

EboCharBuffer

public EboCharBuffer(String s)
Creates a EboCharBuffer from the specified string
Parameters:
s - the string value

EboCharBuffer

public EboCharBuffer(Reader in,
                     int incr)
              throws com.sssw.fw.util.IOException
Creates a EboCharBuffer from the contents of the specified Reader.
Parameters:
in - The Reader used to initialize the EboCharBuffer
incr - An int increment size to grow buffer when needed

EboCharBuffer

public EboCharBuffer(Reader in)
              throws com.sssw.fw.util.IOException
Creates a EboCharBuffer from the contents of the specified Reader with the default byte array size
Parameters:
in - The Reader used to initialize the EboCharBuffer
Method Detail

resetPos

public void resetPos()
Reset the cursor to start of buffer for reading

toCharArray

public char[] toCharArray()
Get a copy of the in use portion of the buffer as a char array
Returns:
char array containing a copy of the buffer

toString

public String toString()
Get the char array as a String
Overrides:
toString in class Object
Returns:
String value of char array

available

public int available()
Get the size of the available buffer space.
Returns:
the number of chars that can be read without blocking

size

public int size()
Get the current size of the buffer that is in use.
Returns:
the size of the buffer currently in use

reset

public void reset()
Re-set the buffer to the empty state.

getEncoding

public String getEncoding()
Return a character string representing the encoding of the characters in this buffer. As a performance optimization for sending EboCharBuffers across the wire, we check to see whether the entire buffer is Latin-1 (ISO-8859-1), and if so, return that. Otherwise, we return "unicode", since that's what we are.

read

public int read()
Read the next char from the buffer.
Returns:
next char value or -1 if at end of buffer

read

public int read(char[] buf,
                int offset,
                int len)
Read a stream of chars until the specified output array is full.
Parameters:
buf - output char array
offset - starting index to use in the output array
len - the number of chars to read
Returns:
number of chars actually read or -1 if end of buffer is reached.

skip

public long skip(long skipCnt)
Move the cursor position forward by specified number of chars.
Parameters:
skipCnt - requested number of chars to skip
Returns:
actual number of chars skipped

seek

public final boolean seek(int desiredPosition)
Move the cursor position.
Parameters:
desiredPosition - requested position.
Returns:
true if position valid and false if out of range.

getPosition

public final int getPosition()
Returns the current position.
Returns:
current position.

write

public void write(int b)
Write the specified char to the buffer.
Parameters:
b - the char to write to buffer

write

public void write(char[] chars,
                  int offset,
                  int len)
Write the specified number of chars to the buffer.
Parameters:
b - char array containing chars to be written to buffer
offset - starting offset in the input char array to use
len - number of chars to be written

writeTo

public void writeTo(Writer out)
             throws com.sssw.fw.util.IOException
Writes the complete contents of this char buffer to the specified output writer argument.
Parameters:
out - the writer to write to.

writeTo

public int writeTo(Writer out,
                   int len)
            throws com.sssw.fw.util.IOException
Write up to n characters starting at the current read position to the specified Writer. Return the number of characters actually written.
Parameters:
out - the writer to write to.
len - the number of characters to write
Returns:
The number of characters written, or -1 if end of buffer

Novell exteNd
Director 5.2 API