GXPARSE hosted by SourceForge.net Logo

ca.gorman.util.scan.spi
Class AbstractReaderBuffer

java.lang.Object
  extended by ca.gorman.util.scan.spi.AbstractReaderBuffer
All Implemented Interfaces:
Expandable, InputControl, CharSequence

public abstract class AbstractReaderBuffer
extends Object
implements CharSequence, InputControl

Input buffer factory to support a ScanBuffer implementation on a java.io.Reader.

The default implementation is expandable to hold character sequences of arbitrary length, within the limits imposed by the availability of free memory.


Nested Class Summary
 
Nested classes/interfaces inherited from interface ca.gorman.util.scan.InputControl
InputControl.Default
 
Constructor Summary
protected AbstractReaderBuffer(Reader reader)
           
 
Method Summary
 char charAt(int index)
           
 int discard(int index)
           Discard a leading prefix of characters from the buffer.
 boolean expand()
           Increase the amount of data in the buffer, if the buffer supports expansion.
 int fill()
           Make more characters available in a buffer with free space.
 int length()
           
static AbstractReaderBuffer newInstance(Reader reader)
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractReaderBuffer

protected AbstractReaderBuffer(Reader reader)
                        throws IOException
Throws:
IOException
Method Detail

newInstance

public static AbstractReaderBuffer newInstance(Reader reader)
                                        throws IOException
Throws:
IOException

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

length

public int length()
Specified by:
length in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

discard

public int discard(int index)
Description copied from interface: InputControl

Discard a leading prefix of characters from the buffer.

Specified by:
discard in interface InputControl
Parameters:
index - The number of characters to be discarded
Returns:
The number (from zero to the number requested) of characters discarded

fill

public int fill()
         throws IOException
Description copied from interface: InputControl

Make more characters available in a buffer with free space.

Specified by:
fill in interface InputControl
Returns:
the number (possibly zero) of additional characters made available, or a negative number to indicate that additional chaacters will never be available.
Throws:
IOException

expand

public boolean expand()
               throws IOException
Description copied from interface: Expandable

Increase the amount of data in the buffer, if the buffer supports expansion.

Expansion is not guaranteed, because the buffer may not support expansion or because the current state of the buffer (or its data source) may not permit expansion.

A successful expansion of a full buffer will increase the memory used by the buffer. A buffer with free space may simply add more data to the free space instead of acquiring and filling additional memory.

Specified by:
expand in interface Expandable
Returns:
true if more data has been made available in the buffer
Throws:
IOException

GXPARSE download

GXPARSE Generic XML Stream Parser API and supporting tools.   Release $Name: gxparse-sf-alpha-2_0 $
Copyright 2003-2004 Ian E. Gorman
Released under GNU Lesser General Public License