|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.corpus.Parser<H>
H - the type of handler which receives events from this parserpublic 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. |
void |
parse(File file,
String charEncoding)
Parse the specified file using the specified character encoding, passing 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, usually a URL name, passing extracted events to the handler. |
void |
parse(String sysId,
String charEncoding)
Parse the specified system identifier, usually a URL name, using the specified character encoding, 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).
Warning: This method does not specify a character
encoding. Behavior will depend on the implementation.
See parse(String,String) to set the encoding.
sysId - System ID from which to read.
IOException - If there is an exception reading
from the specified source.
public void parse(String sysId,
String charEncoding)
throws IOException
Warning: The character encoding is set on the constructed input source, but this may be ignored by the parser.
sysId - System identifier for data, typically a URL name.charEncoding - Character encoding to use for the data.
IOException
public void parse(File file)
throws IOException
The file is converted to a URL name using
File.toURI().toURL().toString(). It is then used
to construct an input source which is parsed using
the #parse(InputSource) method.
Warning: This method does not specify a character
encoding on the constructed input source. Behavior will depend
on the implementation. See parse(File,String) to set
the character encoding.
file - File to parse.
IOException - If there is an exception reading
from the specified file or it does not exist.
public void parse(File file,
String charEncoding)
throws IOException
The file is converted to a URL name using
File.toURI().toURL().toString().
Warning: The character encoding will be set on the input source for parsing, but parser implementations may choose to ignore it.
file - File from which to read.charEncoding - Characte encoding for text.
IOException - If there is an exception reading
from the specified source.
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 | ||||||||