com.inet.html.parser
Class PushReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.BufferedReader
          extended by com.inet.html.parser.PushReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class PushReader
extends java.io.BufferedReader


Constructor Summary
PushReader(java.io.Reader in)
          Creates the reader for an input stream
 
Method Summary
 void checkForUtf8Prefix()
          Check if the document start with an UTF8 prefix.
 void commit()
          Resets the rollback buffer and deactivates the transaction mode
 void push(char ch)
          Return a character to the stream.
 int read()
          
 char readQuotedChar()
          Read a html encoded character
 void rollBack()
          Does a rollback for all characters fetched since the transaction was started.
 void shutDown()
          Shuts down the stream.
 void startTransaction()
          Activates the transaction mode, which will buffer all characters read.
 
Methods inherited from class java.io.BufferedReader
close, mark, markSupported, read, readLine, ready, reset, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushReader

public PushReader(java.io.Reader in)
Creates the reader for an input stream

Parameters:
in - the input stream to read from, must not be null
Method Detail

read

public int read()
         throws java.io.IOException

Overrides:
read in class java.io.BufferedReader
Throws:
java.io.IOException

push

public void push(char ch)
Return a character to the stream.

Parameters:
ch - the character

readQuotedChar

public char readQuotedChar()
Read a html encoded character

Returns:
the char or & if it is not a valid encoding

checkForUtf8Prefix

public void checkForUtf8Prefix()
                        throws java.io.IOException,
                               javax.swing.text.ChangedCharSetException
Check if the document start with an UTF8 prefix. This are 3 Bytes with an ASCII code page. With UTF8 this are a single character 0xFEFF.

Throws:
java.io.IOException - If an I/O error occurs
javax.swing.text.ChangedCharSetException - if the prefix was find and the document is not allready UTF8 encoded

startTransaction

public void startTransaction()
Activates the transaction mode, which will buffer all characters read. These chars can be re-enqueued to the reader if the transaction fails.


rollBack

public void rollBack()
Does a rollback for all characters fetched since the transaction was started.


commit

public void commit()
Resets the rollback buffer and deactivates the transaction mode


shutDown

public void shutDown()
              throws java.io.IOException
Shuts down the stream. This causes a close on the underlying stream. The Reader will return -1 on read from now on without throwing an IO-Exception.

Throws:
java.io.IOException - thrown, if the close fails