|
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 org.htmlparser.lexer.StringSource
public class StringSource
A source of characters based on a String.
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. |
Fields inherited from class org.htmlparser.lexer.Source |
---|
EOF |
Fields inherited from class java.io.Reader |
---|
lock |
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)
Read characters into an array. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of 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. |
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 |
---|
protected String mString
protected int mOffset
protected String mEncoding
getEncoding()
.
protected int mMark
Constructor Detail |
---|
public StringSource(String string)
string
- The source of characters.public StringSource(String string, String character_set)
getEncoding()
.
string
- The source of characters.character_set
- The encoding to report.Method Detail |
---|
public String getEncoding()
getEncoding
in class Source
public void setEncoding(String character_set) throws ParserException
getEncoding()
.
setEncoding
in class Source
character_set
- The character set to use to convert characters.
ParserException
- Not thrown.public void close() throws IOException
close
in interface Closeable
close
in class Source
IOException
- not useddestroy()
public int read() throws IOException
read
in class Source
EOF
if the source is exhausted.
IOException
- If an I/O error occurs.public int read(char[] cbuf, int off, int len) throws IOException
read
in class Source
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 int read(char[] cbuf) throws IOException
read
in class Source
cbuf
- Destination buffer.
EOF
if the source
is exhausted.
IOException
- If an I/O error occurs.public boolean ready() throws IOException
ready
in class Source
available()
, i.e. there are
still more characters to read.
IOException
- Thrown if the source is closed.public void reset() throws IllegalStateException
reset
in class Source
IllegalStateException
- If the source has been closed.public boolean markSupported()
markSupported
in class Source
true
.public void mark(int readAheadLimit) throws IOException
reset()
will attempt to reposition the source to this point.
mark
in class Source
readAheadLimit
- Not used.
IOException
- Thrown if the source is closed.public long skip(long n) throws IOException, IllegalArgumentException
skip
in class Source
n
- The number of characters to skip.
IllegalArgumentException
- If n
is negative.
IOException
- If the source is closed.public void unread() throws IOException
unread
in class Source
IOException
- If no characters have been read or the source is closed.public char getCharacter(int offset) throws IOException
getCharacter
in class Source
offset
- The offset of the character.
offset
.
IOException
- If the source is closed or an attempt is made to
read beyond offset()
.public void getCharacters(char[] array, int offset, int start, int end) throws IOException
getCharacters
in class Source
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 an attempt is made to
read beyond offset()
.public String getString(int offset, int length) throws IOException
offset()
will throw an exception.
getString
in class Source
offset
- The offset of the first character.length
- The number of characters to retrieve.
length
characters at offset
.
IOException
- If the source is closed or an attempt is made to
read beyond offset()
.public void getCharacters(StringBuffer buffer, int offset, int length) throws IOException
StringBuffer
.
Asking for characters ahead of offset()
will throw an exception.
getCharacters
in class Source
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 an attempt is made to
read beyond offset()
.public 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.
destroy
in class Source
IOException
- Not thrownpublic int offset()
offset
in class Source
EOF
if the source is closed.public int available()
available
in class Source
|
© 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. |