public abstract class StreamingParser extends Object
There are no public constructors for this class. New instances are
created by first creating and configuring, if necessary, an instance of the
StreamingParserFactory class.
After each invocation of the parse method an instance of
this class will be in one of the following states. In each state the name, value, and uriString
methods may be invoked to return the data specified in the following table.
If no data is specified for a given method and state then invoking that
method in that state will cause an IllegalStateException to be thrown.
If a start tag has any attributes then the
state description name()value()uriString()START Start tag Element name Element namespace END End tag Element name Element namespace ATTR Attribute Name Value Attribute namespace CHARS Character data Data IWS Ignorable whitespace Whitespace PI Processing instruction Target name Content
START state for that tag
will immediately be followed by a sequence of ATTR states, one per
attribute. The attributes are parsed in the order in which they appear in
the document.
An empty tag, that is, a tag of the form <foo/>, will
yield a START state and then an END state, possibly with
some ATTR states in between.
If the parser is namespace-aware then the uriString
method may be invoked in the START, END, and ATTR
states to return the namespace in which the element or attribute is defined.
Otherwise, the uriString method just returns
null at those states.
Note that because detecting ignorable whitespace requires a DTD, the
IWS state will be entered only when validation is being performed.
There is otherwise no restriction on the allowable state transitions other than those induced by the structure of the XML document being parsed.
| Modifier and Type | Field and Description |
|---|---|
static int |
ATTR
State value indicating that an attribute has been parsed.
|
static int |
CHARS
State value indicating that character data has been parsed.
|
static int |
END
State value indicating that an end tag has been parsed.
|
static int |
IWS
State value indicating that ignorable whitespace has been parsed.
|
static int |
PI
State value indicating that a processing instruction has been parsed.
|
static int |
START
State value indicating that a start tag has been parsed.
|
| Modifier | Constructor and Description |
|---|---|
protected |
StreamingParser()
Construct a new StreamingParser.
|
| Modifier and Type | Method and Description |
|---|---|
abstract int |
column()
Returns the column number of the current component,
or -1 if the column number is not known.
|
abstract String |
describe(boolean articleNeeded)
Constructs a string describing the current state of this parser,
suitable for use in an error message or an exception detail string.
|
static String |
describe(int state,
String name,
String value,
boolean articleNeeded)
Constructs a string describing the given parser state, suitable for use
in an error message or an exception detail string.
|
abstract boolean |
isCoalescing()
Returns the coalescing property of this parser.
|
abstract boolean |
isNamespaceAware()
Returns the namespaceAware property of this parser.
|
abstract boolean |
isValidating()
Returns the validating property of this parser.
|
abstract int |
line()
Returns the line number of the current component,
or -1 if the line number is not known.
|
abstract String |
name()
Returns a name string whose meaning depends upon the current state.
|
abstract int |
parse()
Parses the next component of the document being parsed.
|
abstract String |
publicId()
Returns the public identifer of the document being parsed,
or null if it has none.
|
abstract int |
state()
Returns the current state of the parser.
|
abstract String |
systemId()
Returns the system identifer of the document being parsed,
or null if it has none.
|
String |
toString() |
abstract String |
uriString()
Returns the URI string of the current component.
|
abstract String |
value()
Returns a value string whose meaning depends upon the current state.
|
public static final int START
name() method will return the name of the element just
started.public static final int END
name() method will return the name of the element just
ended.public static final int ATTR
name() method will return the name of the attribute,
while the value() method will return its value.public static final int CHARS
value() method will return the parsed characters.public static final int IWS
value() method will return the whitespace.public static final int PI
name() method will return the target of the instruction,
while the value() method will return its content.public abstract int parse()
throws ParseException,
IOException
START,
END, ATTR, CHARS, IWS,
or PI, or -1 if the end of the document has
been reachedParseException - If an XML parsing error occursIOException - If an I/O error occurspublic abstract int state()
public abstract String name()
IllegalStateException - If there is no name data for the current parser statepublic abstract String value()
IllegalStateException - If there is no value data for the current parser statepublic abstract String uriString()
IllegalStateException - If there is no URI for the current componentpublic abstract int line()
public abstract int column()
public abstract String publicId()
public abstract String systemId()
public abstract boolean isValidating()
public abstract boolean isCoalescing()
public abstract boolean isNamespaceAware()
public static String describe(int state, String name, String value, boolean articleNeeded)
state - A parser state, one of START, END, ATTR, CHARS, IWS, or PI, or
-1 if the end of the document has been reachedname - The name data for the parser state, or null if there
is nonevalue - The value data for the parser state, or null if there
is nonearticleNeeded - Whether an appropriate article ("a", "an", "some", or "the") is
to be prepended to the description stringpublic abstract String describe(boolean articleNeeded)
articleNeeded - Whether an appropriate article ("a", "an", "some", or "the") is
to be prepended to the description stringCopyright © 2017–2019 Eclipse Foundation. All rights reserved.