public static class HTMLScanner.PlaybackInputStream
extends java.io.FilterInputStream
If the encoding is changed, then the scanner calls the
playback
method and re-scans the beginning of the HTML
document again. This should not be too much of a performance problem
because the <meta> tag appears at the beginning of the document.
If the <body> tag is reached without playing back the bytes,
then the buffer can be cleared by calling the clear
method. This stops the buffering of bytes and allows the memory used
by the buffer to be reclaimed.
Note: If the buffer is never played back or cleared, this input stream will continue to buffer the entire stream. Therefore, it is very important to use this stream correctly.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
fByteBuffer
Byte buffer.
|
protected int |
fByteLength
Length of bytes read into byte buffer.
|
protected int |
fByteOffset
Offset into byte buffer during playback.
|
protected boolean |
fCleared
Buffer cleared.
|
protected boolean |
fDetected
Encoding detected.
|
protected boolean |
fPlayback
Playback mode.
|
int |
fPushbackLength
Pushback length.
|
int |
fPushbackOffset
Pushback offset.
|
Constructor and Description |
---|
HTMLScanner.PlaybackInputStream(java.io.InputStream in)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the buffer.
|
void |
detectEncoding(java.lang.String[] encodings)
Detect encoding.
|
void |
playback()
Playback buffer contents.
|
int |
read()
Read a byte.
|
int |
read(byte[] array)
Read an array of bytes.
|
int |
read(byte[] array,
int offset,
int length)
Read an array of bytes.
|
protected boolean fPlayback
protected boolean fCleared
protected boolean fDetected
protected byte[] fByteBuffer
protected int fByteOffset
protected int fByteLength
public int fPushbackOffset
public int fPushbackLength
public HTMLScanner.PlaybackInputStream(java.io.InputStream in)
public void detectEncoding(java.lang.String[] encodings) throws java.io.IOException
java.io.IOException
public void playback()
public void clear()
Note: The buffer cannot be cleared during playback. Therefore, calling this method during playback will not do anything. However, the buffer will be cleared automatically at the end of playback.
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] array) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] array, int offset, int length) throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
(C) Copyright 2002-2014, Andy Clark, Marc Guillemot. All rights reserved.