FIM.Util.WWW
Class CanonicalHTMLFilterReader
java.lang.Object
|
+--java.io.Reader
|
+--java.io.FilterReader
|
+--FIM.Util.WWW.CanonicalHTMLFilterReader
- public class CanonicalHTMLFilterReader
- extends FilterReader
Removes all line breaks and multiple space characters within a tag.
Removes all spaces after the starting "<" of a tag.
E. g. "<\n / p> will be changed to "</p>".
- Version:
- 1.0, 1.7.2000
- Author:
- Michael Sonntag
Field Summary |
protected String |
buffer
The buffer of characters already read from the input stream but not yet returned. |
protected char |
inQuotes
Single or double quote if we are currently within quotation marks within a tag, space otherwise. |
protected boolean |
inTag
true if we are currently within a tag. |
protected int |
lastChar
The last character returned |
Method Summary |
boolean |
markSupported()
Tell whether this stream supports the mark() operation (this stream does not). |
int |
read()
Read a single character. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into an array. |
boolean |
ready()
Tell whether this stream is ready to be read. |
long |
skip(long n)
Skip characters. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
inTag
protected boolean inTag
true
if we are currently within a tag.
inQuotes
protected char inQuotes
- Single or double quote if we are currently within quotation marks within a tag, space otherwise.
buffer
protected String buffer
- The buffer of characters already read from the input stream but not yet returned.
lastChar
protected int lastChar
- The last character returned
CanonicalHTMLFilterReader
public CanonicalHTMLFilterReader(Reader in)
- Creates a new reader.
- Parameters:
in
- the reader to read from
markSupported
public boolean markSupported()
- Tell whether this stream supports the mark() operation (this stream does not).
- Overrides:
markSupported
in class FilterReader
- Returns:
- always
false
read
public int read(char[] cbuf,
int off,
int len)
throws IOException
- Read characters into an array. This method will block until some input is available,
an I/O error occurs, or the end of the stream is reached.
- Overrides:
read
in class FilterReader
- Parameters:
cbuf
- destination bufferoff
- the offset in the buffer the first character will be written tolen
- the number of characters to read- Returns:
- the number of bytes read, or -1 if the end of the stream has been reached
- Throws:
IOException
- if an I/O error occurs
read
public int read()
throws IOException
- Read a single character. This method will block until a character is available,
an I/O error occurs, or the end of the stream is reached.
- Overrides:
read
in class FilterReader
- Returns:
- the character read, as an integer in the range 0 to 16383 (0x00-0xffff), or -1 if the end of the stream has been reached
- Throws:
IOException
- if an I/O error occurs
ready
public boolean ready()
throws IOException
- Tell whether this stream is ready to be read.
- Overrides:
ready
in class FilterReader
- Returns:
true
if the next read()
is guaranteed not to block for input,
false
otherwise. Note that returning false
does not guarantee
that the next read will block.- Throws:
IOException
- if an I/O error occurs
skip
public long skip(long n)
throws IOException
- Skip characters. This method will block until some characters are available,
an I/O error occurs, or the end of the stream is reached.
- Overrides:
skip
in class FilterReader
- Parameters:
n
- the number of characters to skip- Returns:
- the number of characters actually skipped
- Throws:
IOException
- if an I/O error occurs
Submit a bug
Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.