|
HTML Parser Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Reader org.htmlparser.lexer.Source
public abstract class Source
A buffered source of characters. A Source is very similar to a Reader, like:
new InputStreamReader (connection.getInputStream (), charset)It differs from the above, in three ways:
Field Summary | |
---|---|
static int |
EOF
Return value when the source is exhausted. |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
Source()
|
Method Summary | |
---|---|
abstract int |
available()
Get the number of available characters. |
abstract void |
close()
Does nothing. |
abstract void |
destroy()
Close the source. |
abstract char |
getCharacter(int offset)
Retrieve a character again. |
abstract void |
getCharacters(char[] array,
int offset,
int start,
int end)
Retrieve characters again. |
abstract void |
getCharacters(StringBuffer buffer,
int offset,
int length)
Append characters already read into a StringBuffer . |
abstract String |
getEncoding()
Get the encoding being used to convert characters. |
abstract String |
getString(int offset,
int length)
Retrieve a string comprised of characters already read. |
abstract void |
mark(int readAheadLimit)
Mark the present position. |
abstract boolean |
markSupported()
Tell whether this source supports the mark() operation. |
abstract int |
offset()
Get the position (in characters). |
abstract int |
read()
Read a single character. |
abstract int |
read(char[] cbuf)
Read characters into an array. |
abstract int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
abstract boolean |
ready()
Tell whether this source is ready to be read. |
abstract void |
reset()
Reset the source. |
abstract void |
setEncoding(String character_set)
Set the encoding to the given character set. |
abstract long |
skip(long n)
Skip characters. |
abstract void |
unread()
Undo the read of a single character. |
Methods inherited from class java.io.Reader |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EOF
Constructor Detail |
---|
public Source()
Method Detail |
---|
public abstract String getEncoding()
public abstract void setEncoding(String character_set) throws ParserException
If characters have already been consumed from this source, it is expected that an exception will be thrown if the characters read so far would be different if the encoding being set was used from the start.
character_set
- The character set to use to convert characters.
ParserException
- If a character mismatch occurs between
characters already provided and those that would have been returned
had the new character set been in effect from the beginning. An
exception is also thrown if the character set is not recognized.public abstract void close() throws IOException
destroy()
instead.
close
in interface Closeable
close
in class Reader
IOException
- not useddestroy()
public abstract int read() throws IOException
read
in class Reader
EOF
if the source is exhausted.
IOException
- If an I/O error occurs.public abstract int read(char[] cbuf, int off, int len) throws IOException
read
in class Reader
cbuf
- Destination bufferoff
- Offset at which to start storing characterslen
- Maximum number of characters to read
EOF
if the source is
exhausted.
IOException
- If an I/O error occurs.public abstract int read(char[] cbuf) throws IOException
read
in class Reader
cbuf
- Destination buffer.
EOF
if the source is
exhausted.
IOException
- If an I/O error occurs.public abstract boolean ready() throws IOException
ready
in class Reader
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.
IOException
- If an I/O error occurs.public abstract void reset()
reset
in class Reader
public abstract boolean markSupported()
markSupported
in class Reader
true
if and only if this source supports the mark
operation.public abstract void mark(int readAheadLimit) throws IOException
reset()
will attempt to reposition the source to this point. Not all
sources support the mark() operation.
mark
in class Reader
readAheadLimit
- The minimum number of characters that can be read
before this mark becomes invalid.
IOException
- If an I/O error occurs.public abstract long skip(long n) throws IOException
skip
in class Reader
n
- The number of characters to skip.
IOException
- If an I/O error occurs.public abstract void unread() throws IOException
IOException
- If the source is closed or no characters have
been read.public abstract char getCharacter(int offset) throws IOException
offset
- The offset of the character.
offset
.
IOException
- If the source is closed or the offset is beyond
offset()
.public abstract void getCharacters(char[] array, int offset, int start, int end) throws IOException
array
- The array of characters.offset
- The starting position in the array where characters are to be placed.start
- The starting position, zero based.end
- The ending position
(exclusive, i.e. the character at the ending position is not included),
zero based.
IOException
- If the source is closed or the start or end is
beyond offset()
.public abstract String getString(int offset, int length) throws IOException
offset
- The offset of the first character.length
- The number of characters to retrieve.
length
characters at offset
.
IOException
- If the source is closed.public abstract void getCharacters(StringBuffer buffer, int offset, int length) throws IOException
StringBuffer
.
buffer
- The buffer to append to.offset
- The offset of the first character.length
- The number of characters to retrieve.
IOException
- If the source is closed or the offset or
(offset + length) is beyond offset()
.public abstract void destroy() throws IOException
read
,
ready
, mark
, reset
,
skip
, unread
,
getCharacter
or getString
invocations will throw an IOException.
Closing a previously-closed source, however, has no effect.
IOException
- If an I/O error occurs.public abstract int offset()
EOF
if the source is closed.public abstract int available()
|
© 2006 Derrick Oswald Sep 17, 2006
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
HTML Parser is an open source library released under Common Public License. |