uk.org.retep.util.io
Class BufferedCharReader

java.lang.Object
  extended by uk.org.retep.util.io.BufferedCharReader

public class BufferedCharReader
extends java.lang.Object

A BufferedCharReader is a reader which ensures that a certain number of characters are in an array, filling the array as required from a Reader. Unlike BufferedReader, the entire buffer is available, and is useable directly by classes like ParserUtils.

Author:
peter

Constructor Summary
BufferedCharReader(java.io.Reader reader)
           
BufferedCharReader(java.io.Reader reader, int limit)
           
 
Method Summary
 int copy(char[] dest, int length)
          Copy from the buffer into a char array
 void ensureCapacity()
          ensure we have length characters in the buffer.
 void ensureCapacity(int length)
          ensure we have length characters in the buffer.
 void fill()
           
 int getAvailable()
           
 char[] getBuffer()
           
 char getCurrent()
          The current character
 int getEnd()
           
 int getLimit()
           
 int getPosition()
           
 boolean isEof()
           
 void moveForward(int p)
           
 void reset()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedCharReader

public BufferedCharReader(java.io.Reader reader)

BufferedCharReader

public BufferedCharReader(java.io.Reader reader,
                          int limit)
Method Detail

getBuffer

public char[] getBuffer()

getPosition

public int getPosition()

getEnd

public int getEnd()

getLimit

public int getLimit()

getAvailable

public int getAvailable()

reset

public void reset()

isEof

public boolean isEof()

fill

public void fill()
          throws java.io.IOException
Throws:
java.io.IOException

ensureCapacity

public void ensureCapacity()
                    throws java.io.IOException
ensure we have length characters in the buffer. The buffer should then contain this number of characters, unless the Reader has been exhausted

Throws:
java.io.IOException

ensureCapacity

public void ensureCapacity(int length)
                    throws java.io.IOException
ensure we have length characters in the buffer. The buffer should then contain this number of characters, unless the Reader has been exhausted

Parameters:
length - The amount to ensure is in the buffer
Throws:
java.io.IOException

getCurrent

public char getCurrent()
                throws java.io.IOException
The current character

Returns:
current character, -1 if not available
Throws:
java.io.IOException

copy

public int copy(char[] dest,
                int length)
         throws java.io.IOException
Copy from the buffer into a char array

Parameters:
dest - Array to write to
length - number of characters to copy
Returns:
number of characters copied, may be less than length if the Reader has been exhausted
Throws:
java.io.IOException

moveForward

public void moveForward(int p)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 1998-2010 Retep Development Group. All Rights Reserved.