|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.corpus.Parser<H>
public abstract class Parser<H extends Handler>
The Parser abstract class provides methods for parsing
content from an input source or character sequence and passing
extracted events to a content handler. Concrete implementations will
typically make assumptions about the type of the handler.
Concrete subclasses must implement both parse(InputSource) and parseString(char[],int,int). Two
subclasses of this class, InputSourceParser and StringParser may be extended by implementing only one of the
above methods.
| Constructor Summary | |
|---|---|
Parser()
Construct a parser with a null handler. |
|
Parser(H handler)
Construct a parser with the specified handler. |
|
| Method Summary | |
|---|---|
H |
getHandler()
Returns the current content handler. |
void |
parse(File file)
Parse the specified file, passing extracted events to the handler. |
abstract void |
parse(InputSource in)
Parse the specified input source, passing extracted events to the handler. |
void |
parse(String sysId)
Parse the specified system identifier, passing extracted events to the handler. |
abstract void |
parseString(char[] cs,
int start,
int end)
Parse the specified character slice as a string input. |
void |
parseString(CharSequence cSeq)
Parse the specified character sequence. |
void |
setHandler(H handler)
Sets the content handler to the specified value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Parser()
null handler.
public Parser(H handler)
handler - Current handler.| Method Detail |
|---|
public void setHandler(H handler)
handler - Handler to use for content extracted from parsed
content.public H getHandler()
public void parse(String sysId)
throws IOException
The implementation provided by this abstract class
constructs an input source from the system identifier
and passes it to parse(InputSource).
sysId - System ID from which to read.
IOException - If there is an exception reading
from the specified source.
public void parse(File file)
throws IOException
The implementation provided by this abstract class
constructs a string-based URL name from the specified
file and passes it to parse(String).
file - File to parse.
IOException - If there is an exception reading
from the specified file or it does not exist.
public void parseString(CharSequence cSeq)
throws IOException
The character sequence is converted to a character array
using Strings.toCharArray(CharSequence) and then
passed as a slice to to parseString(char[],int,int).
cSeq - Character sequence to parse.
IOException - If there is an exception reading the
characters.
public abstract void parse(InputSource in)
throws IOException
in - Input source from which to read.
IOException - If there is an exception reading from the
specified stream.
public abstract void parseString(char[] cs,
int start,
int end)
throws IOException
cs - Characters underlying slice.start - Index of first character in slice.end - One past the index of the last character in slice.
IOException - If there is an exception reading the
characters.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||