Package nu.validator.htmlparser.io
Class HtmlInputStreamReader
java.lang.Object
java.io.Reader
nu.validator.htmlparser.io.HtmlInputStreamReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
,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$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private final ByteBuffer
private int
private boolean
private int
private CharsetDecoder
private final Driver
private boolean
private final ErrorHandler
private boolean
private boolean
private final InputStream
private int
private int
private int
private boolean
private boolean
private int
private boolean
private boolean
private boolean
private static final int
private final Tokenizer
-
Constructor Summary
ConstructorsConstructorDescriptionHtmlInputStreamReader
(InputStream inputStream, ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Heuristics heuristics) HtmlInputStreamReader
(InputStream inputStream, ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Encoding encoding) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
calculateLineAndCol
(CharBuffer charBuffer) void
close()
private void
int
int
private void
static void
int
read()
int
read
(char[] charArray) int
read
(char[] cbuf, int off, int len) int
read
(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) Methods inherited from class java.io.Reader
mark, markSupported, nullReader, ready, reset, skip, transferTo
-
Field Details
-
SNIFFING_LIMIT
private static final int SNIFFING_LIMIT- See Also:
-
inputStream
-
errorHandler
-
tokenizer
-
driver
-
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
-
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 Details
-
HtmlInputStreamReader
public HtmlInputStreamReader(InputStream inputStream, ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Heuristics heuristics) throws SAXException, IOException - Parameters:
inputStream
-errorHandler
-locator
-- Throws:
IOException
SAXException
-
HtmlInputStreamReader
public HtmlInputStreamReader(InputStream inputStream, ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Encoding encoding) throws SAXException, IOException - Throws:
SAXException
IOException
-
-
Method Details
-
initDecoder
private void initDecoder() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
read
- Overrides:
read
in classReader
- Throws:
IOException
-
calculateLineAndCol
-
readByte
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:
IOException
-
main
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumber
in interfaceLocator
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumber
in interfaceLocator
-
getPublicId
- Specified by:
getPublicId
in interfaceLocator
-
getSystemId
- Specified by:
getSystemId
in interfaceLocator
-
err
- Parameters:
string
-- Throws:
SAXException
IOException
-
getCharset
-
read
- Overrides:
read
in classReader
- Throws:
IOException
- See Also:
-
read
- Specified by:
read
in classReader
- Throws:
IOException
- See Also:
-
read
- Specified by:
read
in interfaceReadable
- Overrides:
read
in classReader
- Throws:
IOException
- See Also:
-
switchEncoding
-