org.htmlparser.lexer
public class StringSource extends Source
Field Summary | |
---|---|
protected String | mEncoding
The encoding to report.
|
protected int | mMark
The bookmark. |
protected int | mOffset
The current offset into the string. |
protected String | mString
The source of characters. |
Constructor Summary | |
---|---|
StringSource(String string)
Construct a source using the provided string.
| |
StringSource(String string, String character_set)
Construct a source using the provided string and encoding.
|
Method Summary | |
---|---|
int | available()
Get the number of available characters. |
void | close()
Does nothing.
|
void | destroy()
Close the source.
|
char | getCharacter(int offset)
Retrieve a character again. |
void | getCharacters(char[] array, int offset, int start, int end)
Retrieve characters again. |
void | getCharacters(StringBuffer buffer, int offset, int length)
Append characters already read into a StringBuffer .
|
String | getEncoding()
Get the encoding being used to convert characters. |
String | getString(int offset, int length)
Retrieve a string comprised of characters already read.
|
void | mark(int readAheadLimit)
Mark the present position in the source.
|
boolean | markSupported()
Tell whether this source supports the mark() operation. |
int | offset()
Get the position (in characters). |
int | read()
Read a single character. |
int | read(char[] cbuf, int off, int len)
Read characters into a portion of an array. |
int | read(char[] cbuf)
Read characters into an array. |
boolean | ready()
Tell whether this source is ready to be read. |
void | reset()
Reset the source.
|
void | setEncoding(String character_set)
Set the encoding to the given character set.
|
long | skip(long n)
Skip characters.
|
void | unread()
Undo the read of a single character. |
Parameters: string The source of characters.
Parameters: string The source of characters. character_set The encoding to report.
Returns: The number of characters that can be read or zero if the source is closed.
Throws: IOException not used
See Also: StringSource
Throws: IOException Not thrown
Parameters: offset The offset of the character.
Returns: The character at offset
.
Throws: IOException If the source is closed or an attempt is made to read beyond {@link #offset()}.
Parameters: 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.
Throws: IOException If the source is closed or an attempt is made to read beyond {@link #offset()}.
StringBuffer
.
Asking for characters ahead of {@link #offset()} will throw an exception.Parameters: buffer The buffer to append to. offset The offset of the first character. length The number of characters to retrieve.
Throws: IOException If the source is closed or an attempt is made to read beyond {@link #offset()}.
Returns: The current encoding.
Parameters: offset The offset of the first character. length The number of characters to retrieve.
Returns: A string containing the length
characters at offset
.
Throws: IOException If the source is closed or an attempt is made to read beyond {@link #offset()}.
Parameters: readAheadLimit Not used.
Throws: IOException Thrown if the source is closed.
Returns: true
.
Returns: The number of characters that have already been read, or {@link #EOF EOF} if the source is closed.
Returns: The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or {@link #EOF EOF} if the source is exhausted.
Throws: IOException If an I/O error occurs.
Parameters: cbuf Destination buffer off Offset at which to start storing characters len Maximum number of characters to read
Returns: The number of characters read, or {@link #EOF EOF} if the source is exhausted.
Throws: IOException If an I/O error occurs.
Parameters: cbuf Destination buffer.
Returns: The number of characters read, or {@link #EOF EOF} if the source is exhausted.
Throws: IOException If an I/O error occurs.
Returns: Equivalent to a non-zero {@link #available()}, i.e. there are still more characters to read.
Throws: IOException Thrown if the source is closed.
Throws: IllegalStateException If the source has been closed.
Parameters: character_set The character set to use to convert characters.
Throws: ParserException Not thrown.
Parameters: n The number of characters to skip.
Returns: The number of characters actually skipped
Throws: IllegalArgumentException If n
is negative. IOException If the source is closed.
Throws: IOException If no characters have been read or the source is closed.
HTML Parser is an open source library released under LGPL. | |