nu.validator.htmlparser.impl
Class HtmlInputStreamReader

java.lang.Object
  extended by java.io.Reader
      extended by nu.validator.htmlparser.impl.HtmlInputStreamReader
All Implemented Interfaces:
Closeable, Readable, ByteReadable, Locator

public final class HtmlInputStreamReader
extends Reader
implements ByteReadable, Locator

Be very careful with this class. It is not a general-purpose subclass of of Reader. Instead, it is the minimal implementation that does what Tokenizer needs while being an instance of Reader. The only reason why this is a public class is that it needs to be visible to test code in another package.

Version:
$Id: HtmlInputStreamReader.java 150 2007-08-16 19:21:25Z hsivonen $
Author:
hsivonen

Field Summary
private  byte[] byteArray
           
private  ByteBuffer byteBuffer
           
private  int bytesRead
           
private  boolean charsetBoundaryPassed
           
private  int col
           
private  CharsetDecoder decoder
           
private  boolean eofSeen
           
private  ErrorHandler errorHandler
           
private  boolean flushing
           
private  InputStream inputStream
           
private  int limit
           
private  int line
           
private  int lineColPos
           
private  Locator locator
           
private  boolean needToNotifyTokenizer
           
private  int position
           
private  boolean shouldReadBytes
           
private  boolean sniffing
           
private static int SNIFFING_LIMIT
           
private  Tokenizer tokenizer
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
HtmlInputStreamReader(InputStream inputStream, ErrorHandler errorHandler, Locator locator, Tokenizer tokenizer)
           
HtmlInputStreamReader(InputStream inputStream, ErrorHandler errorHandler, Locator locator, Tokenizer tokenizer, CharsetDecoder decoder)
           
 
Method Summary
private  void calculateLineAndCol(CharBuffer charBuffer)
           
 void close()
           
private  void err(String message)
           
 Charset getCharset()
           
 int getColumnNumber()
           
 int getLineNumber()
           
 String getPublicId()
           
 String getSystemId()
           
private  void initDecoder()
           
static void main(String[] args)
           
 int read()
           
 int read(char[] charArray)
           
 int read(char[] cbuf, int off, int len)
           
 int read(CharBuffer target)
           
 int readByte()
           
private  void warn(String message)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNIFFING_LIMIT

private static final int SNIFFING_LIMIT
See Also:
Constant Field Values

inputStream

private final InputStream inputStream

errorHandler

private final ErrorHandler errorHandler

locator

private final Locator locator

tokenizer

private final Tokenizer tokenizer

decoder

private CharsetDecoder decoder

sniffing

private boolean sniffing

limit

private int limit

position

private int position

bytesRead

private int bytesRead

eofSeen

private boolean eofSeen

shouldReadBytes

private boolean shouldReadBytes

charsetBoundaryPassed

private boolean charsetBoundaryPassed

byteArray

private final byte[] byteArray

byteBuffer

private final ByteBuffer byteBuffer

needToNotifyTokenizer

private boolean needToNotifyTokenizer

flushing

private boolean flushing

line

private int line

col

private int col

lineColPos

private int lineColPos
Constructor Detail

HtmlInputStreamReader

public HtmlInputStreamReader(InputStream inputStream,
                             ErrorHandler errorHandler,
                             Locator locator,
                             Tokenizer tokenizer)
                      throws SAXException,
                             IOException
Parameters:
inputStream -
errorHandler -
locator -
Throws:
IOException
SAXException

HtmlInputStreamReader

public HtmlInputStreamReader(InputStream inputStream,
                             ErrorHandler errorHandler,
                             Locator locator,
                             Tokenizer tokenizer,
                             CharsetDecoder decoder)
                      throws SAXException,
                             IOException
Throws:
SAXException
IOException
Method Detail

initDecoder

private void initDecoder()

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException

read

public int read(char[] charArray)
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

calculateLineAndCol

private void calculateLineAndCol(CharBuffer charBuffer)

readByte

public int readByte()
             throws IOException
Specified by:
readByte in interface ByteReadable
Throws:
IOException

main

public static void main(String[] args)

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface Locator

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface Locator

getPublicId

public String getPublicId()
Specified by:
getPublicId in interface Locator

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface Locator

err

private void err(String message)
          throws IOException
Parameters:
string -
Throws:
SAXException
IOException

warn

private void warn(String message)
           throws IOException
Parameters:
string -
Throws:
SAXException
IOException

getCharset

public Charset getCharset()

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException
See Also:
Reader.read()

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException
See Also:
Reader.read(char[], int, int)

read

public int read(CharBuffer target)
         throws IOException
Specified by:
read in interface Readable
Overrides:
read in class Reader
Throws:
IOException
See Also:
Reader.read(java.nio.CharBuffer)