public abstract class AbstractXMLEventParser extends Object implements XMLEventParser
allocate(XMLEventParserContext, javax.xml.stream.events.XMLEvent)
method in the parser typically creates a default
parser prior to consulting the XMLEventParserContext
, which returns a new parser whose type is determined by
consulting a table of event types. The default parser is returned if the table contains no entry for the event type.
A parser can be associated with a specific namespace. The namespace is used to qualify the parser's association with
event types.Modifier and Type | Field and Description |
---|---|
protected static String |
CHARACTERS_CONTENT |
protected AVList |
fields |
protected String |
namespaceURI |
protected XMLEventParser |
parent |
Constructor and Description |
---|
AbstractXMLEventParser()
Construct a parser with no qualifying namespace.
|
AbstractXMLEventParser(String namespaceURI)
Constructs a parser and qualifies it for a specified namespace.
|
Modifier and Type | Method and Description |
---|---|
XMLEventParser |
allocate(XMLEventParserContext ctx,
XMLEvent event)
Create a parser for a specified event.
|
protected void |
doAddCharacters(XMLEventParserContext ctx,
XMLEvent event,
Object... args) |
protected void |
doAddEventAttribute(Attribute attr,
XMLEventParserContext ctx,
XMLEvent event,
Object... args) |
protected void |
doAddEventContent(Object o,
XMLEventParserContext ctx,
XMLEvent event,
Object... args) |
protected void |
doParseEventAttributes(XMLEventParserContext ctx,
XMLEvent event,
Object... args)
Parse an event's attributes.
|
protected void |
doParseEventContent(XMLEventParserContext ctx,
XMLEvent event,
Object... args)
Parse an event's sub-elements.
|
void |
freeResources()
Release large resources used by the parser, but does not dispose of the parser itself.
|
protected Constructor<? extends AbstractXMLEventParser> |
getAConstructor(Class... parameterTypes) |
String |
getCharacters() |
Object |
getField(QName keyName) |
Object |
getField(String keyName) |
AVList |
getFields() |
String |
getNamespaceURI()
Returns the qualifying namespace URI specified at construction.
|
XMLEventParser |
getParent()
Returns this parser's parent parser.
|
XMLEventParser |
getRoot() |
boolean |
hasField(QName keyName) |
boolean |
hasField(String keyName) |
boolean |
hasFields() |
protected AbstractXMLEventParser |
mergeFields(AbstractXMLEventParser s1,
AbstractXMLEventParser s2) |
XMLEventParser |
newInstance()
Creates a new empty parser instance of the same type.
|
protected AbstractXMLEventParser |
overrideFields(AbstractXMLEventParser s1,
AbstractXMLEventParser s2) |
Object |
parse(XMLEventParserContext ctx,
XMLEvent inputEvent,
Object... args)
Parse the event and initialize the parser's values to those found in the event.
|
protected String |
parseCharacterContent(XMLEventParserContext ctx,
XMLEvent stringEvent,
Object... args) |
void |
removeField(String keyName) |
void |
setField(QName keyName,
Object value) |
void |
setField(String keyName,
Object value) |
void |
setFields(Map<String,Object> newFields) |
protected void |
setNamespaceURI(String namespaceURI) |
void |
setParent(XMLEventParser parent)
Specifies the parent parser of this parser.
|
protected static final String CHARACTERS_CONTENT
protected AVList fields
protected String namespaceURI
protected XMLEventParser parent
public AbstractXMLEventParser()
public AbstractXMLEventParser(String namespaceURI)
namespaceURI
- the qualifying namespace URI. May be null to indicate no namespace qualification.public XMLEventParser allocate(XMLEventParserContext ctx, XMLEvent event)
ctx
- the current parser context.event
- the event for which the parser is created. Only the event type is used; the new parser can operate
on any event of that type.protected void doAddCharacters(XMLEventParserContext ctx, XMLEvent event, Object... args)
protected void doAddEventAttribute(Attribute attr, XMLEventParserContext ctx, XMLEvent event, Object... args) throws XMLStreamException
XMLStreamException
protected void doAddEventContent(Object o, XMLEventParserContext ctx, XMLEvent event, Object... args) throws XMLStreamException
XMLStreamException
protected void doParseEventAttributes(XMLEventParserContext ctx, XMLEvent event, Object... args) throws XMLStreamException
ctx
- a current parser context.event
- the event to parse.args
- an optional list of arguments that may by used by subclasses.XMLStreamException
- if an exception occurs during event-stream reading.protected void doParseEventContent(XMLEventParserContext ctx, XMLEvent event, Object... args) throws XMLStreamException
ctx
- a current parser context.event
- the event to parse.args
- an optional list of arguments that may by used by subclasses.XMLStreamException
- if an exception occurs during event-stream reading.public void freeResources()
XMLEventParser
freeResources
in interface XMLEventParser
protected Constructor<? extends AbstractXMLEventParser> getAConstructor(Class... parameterTypes)
public String getCharacters()
public AVList getFields()
public String getNamespaceURI()
public XMLEventParser getParent()
XMLEventParser
getParent
in interface XMLEventParser
public XMLEventParser getRoot()
public boolean hasField(QName keyName)
public boolean hasField(String keyName)
public boolean hasFields()
protected AbstractXMLEventParser mergeFields(AbstractXMLEventParser s1, AbstractXMLEventParser s2)
public XMLEventParser newInstance() throws Exception
XMLEventParser
XMLEventParserContext
when creating parsers associated with specific event types.
The returned parser has the same namespace as the instance creating it, but has empty fields for all other
values.newInstance
in interface XMLEventParser
Exception
- if an error or exception occurs while attempting to create the parser.protected AbstractXMLEventParser overrideFields(AbstractXMLEventParser s1, AbstractXMLEventParser s2)
public Object parse(XMLEventParserContext ctx, XMLEvent inputEvent, Object... args) throws XMLStreamException
parse
in interface XMLEventParser
ctx
- a current parser context.inputEvent
- the event to parse.args
- an optional list of arguments that may by used by subclasses.this
, otherwise returns null.XMLStreamException
- if an exception occurs during event-stream reading.protected String parseCharacterContent(XMLEventParserContext ctx, XMLEvent stringEvent, Object... args) throws XMLStreamException
XMLStreamException
public void removeField(String keyName)
protected void setNamespaceURI(String namespaceURI)
public void setParent(XMLEventParser parent)
XMLEventParser
setParent
in interface XMLEventParser
parent
- this parser's parent parser.