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 ByteBufferprivate intprivate booleanprivate intprivate CharsetDecoderprivate final Driverprivate booleanprivate final ErrorHandlerprivate booleanprivate booleanprivate final InputStreamprivate intprivate intprivate intprivate booleanprivate booleanprivate intprivate booleanprivate booleanprivate booleanprivate static final intprivate 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 voidcalculateLineAndCol(CharBuffer charBuffer) voidclose()private voidintintprivate voidstatic voidintread()intread(char[] charArray) intread(char[] cbuf, int off, int len) intread(CharBuffer target) intreadByte()Returns the value of the next byte as an integer from 0 to 0xFF or -1 if the stream has ended.voidswitchEncoding(Encoding newEnc) Methods inherited from class Reader
mark, markSupported, nullReader, of, readAllAsString, readAllLines, 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:
IOExceptionSAXException
-
HtmlInputStreamReader
public HtmlInputStreamReader(InputStream inputStream, ErrorHandler errorHandler, Tokenizer tokenizer, Driver driver, Encoding encoding) throws SAXException, IOException - Throws:
SAXExceptionIOException
-
-
Method Details
-
initDecoder
private void initDecoder() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
calculateLineAndCol
-
readByte
Description copied from interface:ByteReadableReturns the value of the next byte as an integer from 0 to 0xFF or -1 if the stream has ended.- Specified by:
readBytein interfaceByteReadable- Returns:
- integer from 0 to 0xFF or -1 on EOF
- Throws:
IOException
-
main
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumberin interfaceLocator
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceLocator
-
getPublicId
- Specified by:
getPublicIdin interfaceLocator
-
getSystemId
- Specified by:
getSystemIdin interfaceLocator
-
err
- Parameters:
string-- Throws:
SAXExceptionIOException
-
getCharset
-
read
- Overrides:
readin classReader- Throws:
IOException- See Also:
-
read
- Specified by:
readin classReader- Throws:
IOException- See Also:
-
read
- Specified by:
readin interfaceReadable- Overrides:
readin classReader- Throws:
IOException- See Also:
-
switchEncoding
-