org.apache.batik.xml
Class InputBuffer

java.lang.Object
  |
  +--org.apache.batik.xml.InputBuffer

public class InputBuffer
extends java.lang.Object

This class represents a resizable input buffer.


Field Summary
protected  char[] buffer
          The current buffer.
protected static int BUFFER_SIZE
          The buffer size.
protected  int bufferIndex
          The current buffer index.
protected  char[][] buffers
          The buffers.
protected  int column
          The column number.
protected  int count
          The number of bytes in the current buffer.
protected  int current
          The current character.
protected  int line
          The line number.
protected  int mark
          The current mark
protected  boolean markSet
          Whether a mark is set.
protected  int position
          The current position.
protected  java.io.Reader reader
          The reader.
protected  int removedChars
          The number of removed chars.
 
Constructor Summary
InputBuffer(java.io.Reader r)
          Creates a new InputBuffer object.
 
Method Summary
 int contentSize()
          The size of the content of the buffer, ie. from the mark to the current position.
 int current()
          Returns the current character or -1.
 int getColumn()
          Returns the column of the current character.
 int getLine()
          Returns the line of the current character.
 int next()
          Go to the next character.
protected  void next(boolean preserve)
          Go to the next character.
 void readContent(char[] a)
          Returns the content of the buffer from the mark to the current position.
 void resetMark()
          Resets a mark at the current position in the buffer.
 void setMark()
          Sets a mark at the current position in the buffer.
 void unsetMark()
          Unsets the current mark.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

protected static final int BUFFER_SIZE
The buffer size.

reader

protected java.io.Reader reader
The reader.

bufferIndex

protected int bufferIndex
The current buffer index.

buffer

protected char[] buffer
The current buffer.

buffers

protected char[][] buffers
The buffers.

count

protected int count
The number of bytes in the current buffer.

position

protected int position
The current position.

mark

protected int mark
The current mark

markSet

protected boolean markSet
Whether a mark is set.

current

protected int current
The current character.

line

protected int line
The line number.

column

protected int column
The column number.

removedChars

protected int removedChars
The number of removed chars.
Constructor Detail

InputBuffer

public InputBuffer(java.io.Reader r)
            throws java.io.IOException
Creates a new InputBuffer object.
Parameters:
r - The reader used to read the document.
Method Detail

current

public int current()
Returns the current character or -1.

getLine

public int getLine()
Returns the line of the current character.

getColumn

public int getColumn()
Returns the column of the current character.

next

public int next()
         throws java.io.IOException
Go to the next character. A newline is reported with a single '\0xA'.
Returns:
the new current character.

next

protected void next(boolean preserve)
             throws java.io.IOException
Go to the next character.
Parameters:
preserve - true if the buffer must be preserved when a new portion of the stream must be read.
Returns:
the new current character.

setMark

public void setMark()
Sets a mark at the current position in the buffer.
Throws:
java.lang.IllegalStateException - if the mark was already set.

resetMark

public void resetMark()
Resets a mark at the current position in the buffer.

unsetMark

public void unsetMark()
Unsets the current mark.
Throws:
java.lang.IllegalStateException - if the mark was not previously set.

contentSize

public int contentSize()
The size of the content of the buffer, ie. from the mark to the current position.
Throws:
java.lang.IllegalStateException - if the mark was not previously set.

readContent

public void readContent(char[] a)
Returns the content of the buffer from the mark to the current position.
Parameters:
a - The array to fill with the content of the buffer.
Throws:
java.lang.IllegalStateException - if the mark was not previously set.
java.lang.IllegalArgumentException - if the given array is too small.


Copyright © 2001 Apache Software Foundation. All Rights Reserved.