クラス HTMLScanner.PlaybackInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.codelibs.nekohtml.HTMLScanner.PlaybackInputStream
-
- すべての実装されたインタフェース:
java.io.Closeable,java.lang.AutoCloseable
- 含まれているクラス:
- HTMLScanner
public static class HTMLScanner.PlaybackInputStream extends java.io.FilterInputStreamA playback input stream. This class has the ability to save the bytes read from the underlying input stream and play the bytes back later. This class is used by the HTML scanner to switch encodings when a <meta> tag is detected that specifies a different encoding.If the encoding is changed, then the scanner calls the
playbackmethod 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
clearmethod. 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.
- 作成者:
- Andy Clark
-
-
フィールドの概要
フィールド 修飾子とタイプ フィールド 説明 protected byte[]fByteBufferByte buffer.protected intfByteLengthLength of bytes read into byte buffer.protected intfByteOffsetOffset into byte buffer during playback.protected booleanfClearedBuffer cleared.protected booleanfDetectedEncoding detected.protected booleanfPlaybackPlayback mode.intfPushbackLengthPushback length.intfPushbackOffsetPushback offset.
-
コンストラクタの概要
コンストラクタ コンストラクタ 説明 PlaybackInputStream(java.io.InputStream in)Constructor.
-
メソッドの概要
すべてのメソッド インスタンス・メソッド concreteメソッド 修飾子とタイプ メソッド 説明 voidclear()Clears the buffer.voiddetectEncoding(java.lang.String[] encodings)Detect encoding.voidplayback()Playback buffer contents.intread()Read a byte.intread(byte[] array)Read an array of bytes.intread(byte[] array, int offset, int length)Read an array of bytes.
-
-
-
フィールドの詳細
-
fPlayback
protected boolean fPlayback
Playback mode.
-
fCleared
protected boolean fCleared
Buffer cleared.
-
fDetected
protected boolean fDetected
Encoding detected.
-
fByteBuffer
protected byte[] fByteBuffer
Byte buffer.
-
fByteOffset
protected int fByteOffset
Offset into byte buffer during playback.
-
fByteLength
protected int fByteLength
Length of bytes read into byte buffer.
-
fPushbackOffset
public int fPushbackOffset
Pushback offset.
-
fPushbackLength
public int fPushbackLength
Pushback length.
-
-
メソッドの詳細
-
detectEncoding
public void detectEncoding(java.lang.String[] encodings) throws java.io.IOExceptionDetect encoding.- 例外:
java.io.IOException
-
playback
public void playback()
Playback buffer contents.
-
clear
public void clear()
Clears the buffer.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.
-
read
public int read() throws java.io.IOExceptionRead a byte.- オーバーライド:
readクラス内java.io.FilterInputStream- 例外:
java.io.IOException
-
read
public int read(byte[] array) throws java.io.IOExceptionRead an array of bytes.- オーバーライド:
readクラス内java.io.FilterInputStream- 例外:
java.io.IOException
-
read
public int read(byte[] array, int offset, int length) throws java.io.IOExceptionRead an array of bytes.- オーバーライド:
readクラス内java.io.FilterInputStream- 例外:
java.io.IOException
-
-