public class BasicXMLEventParserContext extends AVListImpl implements XMLEventParserContext
XMLEventParserContext
. This class is meant to be
the base class for schema-specific parsers.Modifier and Type | Field and Description |
---|---|
static javax.xml.namespace.QName |
BOOLEAN
The parser name of the default boolean parser.
|
static javax.xml.namespace.QName |
BOOLEAN_INTEGER
The parser name of the default boolean integer parser.
|
protected BooleanIntegerXMLEventParser |
booleanIntegerParser |
protected BooleanXMLEventParser |
booleanParser |
protected java.lang.String |
defaultNamespaceURI |
static javax.xml.namespace.QName |
DOUBLE
The parser name of the default double parser.
|
protected DoubleXMLEventParser |
doubleParser |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> |
idTable |
static javax.xml.namespace.QName |
INTEGER
The parser name of the default integer parser.
|
protected IntegerXMLEventParser |
integerParser |
protected XMLParserNotificationListener |
notificationListener |
protected java.util.concurrent.ConcurrentHashMap<javax.xml.namespace.QName,XMLEventParser> |
parsers |
protected javax.xml.stream.XMLEventReader |
reader |
static javax.xml.namespace.QName |
STRING
The parser name of the default string parser.
|
protected StringXMLEventParser |
stringParser |
static javax.xml.namespace.QName |
UNRECOGNIZED
The parser name of the unrecognized-element parser.
|
UNRECOGNIZED_ELEMENT_PARSER
Constructor and Description |
---|
BasicXMLEventParserContext()
Construct an instance.
|
BasicXMLEventParserContext(BasicXMLEventParserContext ctx) |
BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader)
Construct an instance for a specified event reader.
|
BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader,
java.lang.String defaultNamespace)
Construct an instance for a specified event reader and default namespace.
|
Modifier and Type | Method and Description |
---|---|
void |
addBooleanIntegerParsers(java.lang.String namespace,
java.lang.String[] booleanIntegerFields)
Add boolean integer parsers for a list of element types and qualified for a specified namespace.
|
void |
addBooleanParsers(java.lang.String namespace,
java.lang.String[] booleanFields)
Add boolean parsers for a list of element types and qualified for a specified namespace.
|
void |
addDoubleParsers(java.lang.String namespace,
java.lang.String[] doubleFields)
Add double parsers for a list of element types and qualified for a specified namespace.
|
void |
addId(java.lang.String id,
java.lang.Object o)
Adds a mapping of an id attribute to its associated KML object.
|
void |
addIntegerParsers(java.lang.String namespace,
java.lang.String[] integerFields)
Add integer parsers for a list of element types and qualified for a specified namespace.
|
void |
addStringParsers(java.lang.String namespace,
java.lang.String[] stringFields)
Add string list parsers for a list of element types and qualified for a specified namespace.
|
XMLEventParser |
allocate(javax.xml.stream.events.XMLEvent event)
Create a parser for a specified event's element name, if a parser for that name is registered with the context.
|
XMLEventParser |
allocate(javax.xml.stream.events.XMLEvent event,
XMLEventParser defaultParser)
Create a parser for a specified event's element name, if a parser for that name is registered with the context.
|
BooleanIntegerXMLEventParser |
getBooleanIntegerParser()
Returns the default parser for a simple boolean integer (0 or 1).
|
BooleanXMLEventParser |
getBooleanParser()
Returns the default parser for a simple boolean.
|
java.lang.String |
getCharacters(javax.xml.stream.events.XMLEvent event)
Returns the text associated with the event.
|
java.lang.String |
getDefaultNamespaceURI()
Returns the context's default namespace URI.
|
DoubleXMLEventParser |
getDoubleParser()
Returns a parser for a simple double.
|
javax.xml.stream.XMLEventReader |
getEventReader()
Returns the event reader used by this instance.
|
java.util.Map<java.lang.String,java.lang.Object> |
getIdTable()
Returns the table associating objects with their id attribute as specified in the object's KML file.
|
IntegerXMLEventParser |
getIntegerParser()
Returns the default parser for a simple integer.
|
XMLEventParser |
getParser(javax.xml.namespace.QName name)
Returns a new parser for a specified element name.
|
XMLEventParser |
getParser(javax.xml.stream.events.XMLEvent event)
Returns a new parser for a specified event.
|
protected XMLEventParser |
getParser(javax.xml.stream.events.XMLEvent event,
XMLEventParser defaultParser) |
StringXMLEventParser |
getStringParser()
Returns the default parser for a simple string.
|
XMLEventParser |
getUnrecognizedElementParser()
Returns a parser to handle unrecognized elements.
|
boolean |
hasNext()
Indicates whether the event stream associated with this context contains another event.
|
protected void |
initialize() |
protected void |
initializeDefaultNotificationListener() |
protected void |
initializeParsers()
Initializes the parser table with the default parsers for the strings, integers, etc., qualified for the default
namespace.
|
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
Indicates whether the specified namespace URI is the default namespace URI used by this parser context.
|
boolean |
isEndElement(javax.xml.stream.events.XMLEvent event,
javax.xml.stream.events.XMLEvent startElement)
Determines whether an event is the corresponding end element for a specified start event.
|
static boolean |
isEndElementEvent(javax.xml.stream.events.XMLEvent event,
javax.xml.stream.events.XMLEvent startElement) |
protected static boolean |
isNullNamespace(java.lang.String namespaceURI) |
boolean |
isSameAttributeName(javax.xml.namespace.QName qa,
javax.xml.namespace.QName qb)
Determines whether two fully qualified attribute names are the same.
|
boolean |
isSameName(javax.xml.namespace.QName qa,
javax.xml.namespace.QName qb)
Determines whether two element names are the same.
|
boolean |
isStartElement(javax.xml.stream.events.XMLEvent event,
javax.xml.namespace.QName elementName)
Determines whether an event is a start event for a specific event type.
|
boolean |
isStartElement(javax.xml.stream.events.XMLEvent event,
java.lang.String elementName)
Determines whether an event is a start event for a specific event type indicated by its local name.
|
javax.xml.stream.events.XMLEvent |
nextEvent()
Returns the next event in the event stream associated with this context.
|
void |
registerParser(javax.xml.namespace.QName elementName,
XMLEventParser parser)
Registers a parser for a specified element name.
|
void |
resolveInternalReferences(java.lang.String referenceName,
java.lang.String fieldName,
AbstractXMLEventParser parser)
Deprecated.
|
void |
setDefaultNamespaceURI(java.lang.String defaultNamespaceURI)
Specifies the context's default namespace URI.
|
void |
setEventReader(javax.xml.stream.XMLEventReader reader)
Specify the event reader for the parser context to use to parse XML.
|
void |
setNotificationListener(XMLParserNotificationListener listener)
Specify the object to receive notifications, which are sent when exceptions occur during parsing and when
unrecognized element types are encountered.
|
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
public static javax.xml.namespace.QName BOOLEAN
public static javax.xml.namespace.QName BOOLEAN_INTEGER
protected BooleanIntegerXMLEventParser booleanIntegerParser
protected BooleanXMLEventParser booleanParser
protected java.lang.String defaultNamespaceURI
public static javax.xml.namespace.QName DOUBLE
protected DoubleXMLEventParser doubleParser
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> idTable
public static javax.xml.namespace.QName INTEGER
protected IntegerXMLEventParser integerParser
protected XMLParserNotificationListener notificationListener
protected java.util.concurrent.ConcurrentHashMap<javax.xml.namespace.QName,XMLEventParser> parsers
protected javax.xml.stream.XMLEventReader reader
public static javax.xml.namespace.QName STRING
protected StringXMLEventParser stringParser
public static javax.xml.namespace.QName UNRECOGNIZED
public BasicXMLEventParserContext()
initializeParsers()
and initialize()
.public BasicXMLEventParserContext(BasicXMLEventParserContext ctx)
public BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader)
initializeParsers()
and initialize()
.eventReader
- the event reader to use for XML parsing.public BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader, java.lang.String defaultNamespace)
initializeParsers()
and initialize()
.eventReader
- the event reader to use for XML parsing.defaultNamespace
- the namespace URI of the default namespace.public void addBooleanIntegerParsers(java.lang.String namespace, java.lang.String[] booleanIntegerFields)
XMLEventParserContext
addBooleanIntegerParsers
in interface XMLEventParserContext
namespace
- the namespace URI.booleanIntegerFields
- the string parser.public void addBooleanParsers(java.lang.String namespace, java.lang.String[] booleanFields)
XMLEventParserContext
addBooleanParsers
in interface XMLEventParserContext
namespace
- the namespace URI.booleanFields
- the string parsers.public void addDoubleParsers(java.lang.String namespace, java.lang.String[] doubleFields)
XMLEventParserContext
addDoubleParsers
in interface XMLEventParserContext
namespace
- the namespace URI.doubleFields
- the string parsers.public void addId(java.lang.String id, java.lang.Object o)
XMLEventParserContext
addId
in interface XMLEventParserContext
id
- the object id. If null, this method returns without creating a mapping.o
- the object to associate with the id.public void addIntegerParsers(java.lang.String namespace, java.lang.String[] integerFields)
XMLEventParserContext
addIntegerParsers
in interface XMLEventParserContext
namespace
- the namespace URI.integerFields
- the string parsers.public void addStringParsers(java.lang.String namespace, java.lang.String[] stringFields)
XMLEventParserContext
addStringParsers
in interface XMLEventParserContext
namespace
- the namespace URI.stringFields
- the string list parser names.public XMLEventParser allocate(javax.xml.stream.events.XMLEvent event)
XMLEventParserContext
allocate
in interface XMLEventParserContext
event
- the event whose element name identifies the parser to create.public XMLEventParser allocate(javax.xml.stream.events.XMLEvent event, XMLEventParser defaultParser)
XMLEventParserContext
allocate
in interface XMLEventParserContext
event
- the event whose element name identifies the parser to create.defaultParser
- a parser to return if no parser is registered for the specified name. May be null.public BooleanIntegerXMLEventParser getBooleanIntegerParser()
XMLEventParserContext
getBooleanIntegerParser
in interface XMLEventParserContext
public BooleanXMLEventParser getBooleanParser()
XMLEventParserContext
getBooleanParser
in interface XMLEventParserContext
public java.lang.String getCharacters(javax.xml.stream.events.XMLEvent event)
XMLEventParserContext
getCharacters
in interface XMLEventParserContext
event
- the event of interest.public java.lang.String getDefaultNamespaceURI()
XMLEventParserContext
getDefaultNamespaceURI
in interface XMLEventParserContext
XMLEventParserContext.setDefaultNamespaceURI(String)
public DoubleXMLEventParser getDoubleParser()
XMLEventParserContext
getDoubleParser
in interface XMLEventParserContext
public javax.xml.stream.XMLEventReader getEventReader()
getEventReader
in interface XMLEventParserContext
public java.util.Map<java.lang.String,java.lang.Object> getIdTable()
XMLEventParserContext
getIdTable
in interface XMLEventParserContext
public IntegerXMLEventParser getIntegerParser()
XMLEventParserContext
getIntegerParser
in interface XMLEventParserContext
public XMLEventParser getParser(javax.xml.namespace.QName name)
XMLEventParserContext
getParser
in interface XMLEventParserContext
name
- indicates the element name for which a parser is created.public XMLEventParser getParser(javax.xml.stream.events.XMLEvent event)
XMLEventParserContext
getParser
in interface XMLEventParserContext
event
- indicates the element name for which a parser is created.protected XMLEventParser getParser(javax.xml.stream.events.XMLEvent event, XMLEventParser defaultParser)
public StringXMLEventParser getStringParser()
XMLEventParserContext
getStringParser
in interface XMLEventParserContext
public XMLEventParser getUnrecognizedElementParser()
UnrecognizedXMLEventParser
, and may be replaced by calling registerParser(javax.xml.namespace.QName, XMLEventParser)
and specifying UNRECOGNIZED
as the parser
name.getUnrecognizedElementParser
in interface XMLEventParserContext
public boolean hasNext()
XMLEventParserContext
hasNext
in interface XMLEventParserContext
XMLEventReader.hasNext()
protected void initialize()
protected void initializeDefaultNotificationListener()
protected void initializeParsers()
public boolean isDefaultNamespace(java.lang.String namespaceURI)
XMLEventParserContext
isDefaultNamespace
in interface XMLEventParserContext
namespaceURI
- the namespace URI to check.public boolean isEndElement(javax.xml.stream.events.XMLEvent event, javax.xml.stream.events.XMLEvent startElement)
XMLEventParserContext
Note: Only the event's element name and type are compared. The method returns true if the start and end events are the corresponding event types for an element of the same name.
isEndElement
in interface XMLEventParserContext
event
- the event of interest.startElement
- the start event associated with the potential end event.public static boolean isEndElementEvent(javax.xml.stream.events.XMLEvent event, javax.xml.stream.events.XMLEvent startElement)
protected static boolean isNullNamespace(java.lang.String namespaceURI)
public boolean isSameAttributeName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)
XMLEventParserContext
isSameAttributeName
in interface XMLEventParserContext
qa
- the first attribute name.qb
- the second attribute name.public boolean isSameName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)
XMLEventParserContext
isSameName
in interface XMLEventParserContext
qa
- first element nameqb
- second element namepublic boolean isStartElement(javax.xml.stream.events.XMLEvent event, javax.xml.namespace.QName elementName)
XMLEventParserContext
isStartElement
in interface XMLEventParserContext
event
- an event identifying the event type of interest.elementName
- the event name.public boolean isStartElement(javax.xml.stream.events.XMLEvent event, java.lang.String elementName)
XMLEventParserContext
isStartElement
in interface XMLEventParserContext
event
- an event identifying the event type of interest.elementName
- the local part of the event name to match.public javax.xml.stream.events.XMLEvent nextEvent() throws javax.xml.stream.XMLStreamException
XMLEventParserContext
nextEvent
in interface XMLEventParserContext
javax.xml.stream.XMLStreamException
- if there is an error with the underlying XML.XMLEventReader.nextEvent()
public void registerParser(javax.xml.namespace.QName elementName, XMLEventParser parser)
XMLEventParserContext
XMLEventParserContext.getParser(javax.xml.stream.events.XMLEvent)
is called for the same element name.registerParser
in interface XMLEventParserContext
elementName
- the element name for which to return a parser.parser
- the parser to register.@Deprecated public void resolveInternalReferences(java.lang.String referenceName, java.lang.String fieldName, AbstractXMLEventParser parser)
XMLEventParserContext
resolveInternalReferences
in interface XMLEventParserContext
referenceName
- the element name of the elements whose references this method resolves. An example is
styleUrl. Resolution is performed for only elements of this name.fieldName
- the key used to identify the resolved object in a parser's field table. After this method
resolves references, the referenced object can be obtained by calling the parsers AbstractXMLEventParser.getField(javax.xml.namespace.QName)
method with the fieldName
specified here as the name argument.parser
- the parser whose references to resolve.public void setDefaultNamespaceURI(java.lang.String defaultNamespaceURI)
XMLEventParserContext
setDefaultNamespaceURI
in interface XMLEventParserContext
defaultNamespaceURI
- the default namespace URI.XMLEventParserContext.getDefaultNamespaceURI()
,
XMLEventParserContext.isSameName(javax.xml.namespace.QName, javax.xml.namespace.QName)
public void setEventReader(javax.xml.stream.XMLEventReader reader)
reader
- the event reader to use.public void setNotificationListener(XMLParserNotificationListener listener)
XMLEventParserContext
XMLParserNotification
for
more information.
The parser context may have only one notification listener. That listener may be changed at any time.
setNotificationListener
in interface XMLEventParserContext
listener
- the object to receive notification events.