Package nu.validator.htmlparser.io
Class HtmlInputStreamReader
- java.lang.Object
-
- java.io.Reader
-
- nu.validator.htmlparser.io.HtmlInputStreamReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
,ByteReadable
,org.xml.sax.Locator
public final class HtmlInputStreamReader extends java.io.Reader implements ByteReadable, org.xml.sax.Locator
Be very careful with this class. It is not a general-purpose subclass of ofReader
. Instead, it is the minimal implementation that does whatTokenizer
needs while being an instance ofReader
. The only reason why this is a public class is that it needs to be visible to test code in another package.- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
byteArray
private java.nio.ByteBuffer
byteBuffer
private int
bytesRead
private boolean
charsetBoundaryPassed
private int
col
private java.nio.charset.CharsetDecoder
decoder
private Driver
driver
private boolean
eofSeen
private org.xml.sax.ErrorHandler
errorHandler
private boolean
flushing
private boolean
hasPendingReplacementCharacter
private java.io.InputStream
inputStream
private int
limit
private int
line
private int
lineColPos
private boolean
needToNotifyTokenizer
private boolean
nextCharOnNewLine
private int
position
private boolean
prevWasCR
private boolean
shouldReadBytes
private boolean
sniffing
private static int
SNIFFING_LIMIT
private Tokenizer
tokenizer
-
Constructor Summary
Constructors Constructor Description HtmlInputStreamReader(java.io.InputStream inputStream, org.xml.sax.ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Heuristics heuristics)
HtmlInputStreamReader(java.io.InputStream inputStream, org.xml.sax.ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Encoding encoding)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
calculateLineAndCol(java.nio.CharBuffer charBuffer)
void
close()
private void
err(java.lang.String message)
java.nio.charset.Charset
getCharset()
int
getColumnNumber()
int
getLineNumber()
java.lang.String
getPublicId()
java.lang.String
getSystemId()
private void
initDecoder()
static void
main(java.lang.String[] args)
int
read()
int
read(char[] charArray)
int
read(char[] cbuf, int off, int len)
int
read(java.nio.CharBuffer target)
int
readByte()
Returns the value of the next byte as an integer from 0 to 0xFF or -1 if the stream has ended.void
switchEncoding(Encoding newEnc)
-
-
-
Field Detail
-
SNIFFING_LIMIT
private static final int SNIFFING_LIMIT
- See Also:
- Constant Field Values
-
inputStream
private final java.io.InputStream inputStream
-
errorHandler
private final org.xml.sax.ErrorHandler errorHandler
-
tokenizer
private final Tokenizer tokenizer
-
driver
private final Driver driver
-
decoder
private java.nio.charset.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 java.nio.ByteBuffer byteBuffer
-
needToNotifyTokenizer
private boolean needToNotifyTokenizer
-
flushing
private boolean flushing
-
line
private int line
-
col
private int col
-
lineColPos
private int lineColPos
-
hasPendingReplacementCharacter
private boolean hasPendingReplacementCharacter
-
nextCharOnNewLine
private boolean nextCharOnNewLine
-
prevWasCR
private boolean prevWasCR
-
-
Constructor Detail
-
HtmlInputStreamReader
public HtmlInputStreamReader(java.io.InputStream inputStream, org.xml.sax.ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Heuristics heuristics) throws org.xml.sax.SAXException, java.io.IOException
- Parameters:
inputStream
-errorHandler
-locator
-- Throws:
java.io.IOException
org.xml.sax.SAXException
-
-
Method Detail
-
initDecoder
private void initDecoder()
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
read
public int read(char[] charArray) throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
calculateLineAndCol
private void calculateLineAndCol(java.nio.CharBuffer charBuffer)
-
readByte
public int readByte() throws java.io.IOException
Description copied from interface:ByteReadable
Returns the value of the next byte as an integer from 0 to 0xFF or -1 if the stream has ended.- Specified by:
readByte
in interfaceByteReadable
- Returns:
- integer from 0 to 0xFF or -1 on EOF
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args)
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumber
in interfaceorg.xml.sax.Locator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumber
in interfaceorg.xml.sax.Locator
-
getPublicId
public java.lang.String getPublicId()
- Specified by:
getPublicId
in interfaceorg.xml.sax.Locator
-
getSystemId
public java.lang.String getSystemId()
- Specified by:
getSystemId
in interfaceorg.xml.sax.Locator
-
err
private void err(java.lang.String message) throws java.io.IOException
- Parameters:
string
-- Throws:
org.xml.sax.SAXException
java.io.IOException
-
getCharset
public java.nio.charset.Charset getCharset()
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read()
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read(char[], int, int)
-
read
public int read(java.nio.CharBuffer target) throws java.io.IOException
- Specified by:
read
in interfacejava.lang.Readable
- Overrides:
read
in classjava.io.Reader
- Throws:
java.io.IOException
- See Also:
Reader.read(java.nio.CharBuffer)
-
switchEncoding
public void switchEncoding(Encoding newEnc)
-
-