Package gov.nasa.worldwind.util.xml
Interface XMLEventParserContext
-
- All Superinterfaces:
AVList
- All Known Implementing Classes:
AtomParserContext,BasicXMLEventParserContext,ColladaParserContext,GXParserContext,KMLParserContext,XALParserContext
public interface XMLEventParserContext extends AVList
Provides services and resources used by XML event parsers during event reading and parsing.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringUNRECOGNIZED_ELEMENT_PARSERIdentifies the name of the parser handling unrecognized elements.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddBooleanIntegerParsers(java.lang.String namespace, java.lang.String[] booleanIntegerFields)Add boolean integer parsers for a list of element types and qualified for a specified namespace.voidaddBooleanParsers(java.lang.String namespace, java.lang.String[] booleanFields)Add boolean parsers for a list of element types and qualified for a specified namespace.voidaddDoubleParsers(java.lang.String namespace, java.lang.String[] doubleFields)Add double parsers for a list of element types and qualified for a specified namespace.voidaddId(java.lang.String id, java.lang.Object o)Adds a mapping of an id attribute to its associated KML object.voidaddIntegerParsers(java.lang.String namespace, java.lang.String[] integerFields)Add integer parsers for a list of element types and qualified for a specified namespace.voidaddStringParsers(java.lang.String namespace, java.lang.String[] stringFields)Add string list parsers for a list of element types and qualified for a specified namespace.XMLEventParserallocate(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.XMLEventParserallocate(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.BooleanIntegerXMLEventParsergetBooleanIntegerParser()Returns the default parser for a simple boolean integer (0 or 1).BooleanXMLEventParsergetBooleanParser()Returns the default parser for a simple boolean.java.lang.StringgetCharacters(javax.xml.stream.events.XMLEvent event)Returns the text associated with the event.java.lang.StringgetDefaultNamespaceURI()Returns the context's default namespace URI.DoubleXMLEventParsergetDoubleParser()Returns a parser for a simple double.javax.xml.stream.XMLEventReadergetEventReader()Returns the event reader associated with the context.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.IntegerXMLEventParsergetIntegerParser()Returns the default parser for a simple integer.XMLEventParsergetParser(javax.xml.namespace.QName eventName)Returns a new parser for a specified element name.XMLEventParsergetParser(javax.xml.stream.events.XMLEvent event)Returns a new parser for a specified event.StringXMLEventParsergetStringParser()Returns the default parser for a simple string.XMLEventParsergetUnrecognizedElementParser()Returns a parser to handle unrecognized elements.booleanhasNext()Indicates whether the event stream associated with this context contains another event.booleanisDefaultNamespace(java.lang.String namespaceURI)Indicates whether the specified namespace URI is the default namespace URI used by this parser context.booleanisEndElement(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.booleanisSameAttributeName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Determines whether two fully qualified attribute names are the same.booleanisSameName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Determines whether two element names are the same.booleanisStartElement(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.booleanisStartElement(javax.xml.stream.events.XMLEvent event, javax.xml.namespace.QName elementName)Determines whether an event is a start event for a specific event type.javax.xml.stream.events.XMLEventnextEvent()Returns the next event in the event stream associated with this context.voidregisterParser(javax.xml.namespace.QName elementName, XMLEventParser parser)Registers a parser for a specified element name.voidsetDefaultNamespaceURI(java.lang.String defaultNamespaceURI)Specifies the context's default namespace URI.voidsetNotificationListener(XMLParserNotificationListener listener)Specify the object to receive notifications, which are sent when exceptions occur during parsing and when unrecognized element types are encountered.-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
-
-
-
Field Detail
-
UNRECOGNIZED_ELEMENT_PARSER
static final java.lang.String UNRECOGNIZED_ELEMENT_PARSER
Identifies the name of the parser handling unrecognized elements. Can be used to explicitly specify the context's parser-table entry for unrecognized elements.- See Also:
- Constant Field Values
-
-
Method Detail
-
getEventReader
javax.xml.stream.XMLEventReader getEventReader()
Returns the event reader associated with the context.- Returns:
- the associated event reader, or null if no reader is associated.
-
getParser
XMLEventParser getParser(javax.xml.stream.events.XMLEvent event)
Returns a new parser for a specified event.- Parameters:
event- indicates the element name for which a parser is created.- Returns:
- the new parser, or null if no parser has been registered for the specified event's element name.
-
getParser
XMLEventParser getParser(javax.xml.namespace.QName eventName)
Returns a new parser for a specified element name.- Parameters:
eventName- indicates the element name for which a parser is created.- Returns:
- the new parser, or null if no parser has been registered for the specified element name.
-
isStartElement
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.- Parameters:
event- an event identifying the event type of interest.elementName- the event name.- Returns:
- true if the event is a start event for the named event type.
-
isStartElement
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.- Parameters:
event- an event identifying the event type of interest.elementName- the local part of the event name to match.- Returns:
- true if the event is a start event for the named event type.
-
isEndElement
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.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.
- Parameters:
event- the event of interest.startElement- the start event associated with the potential end event.- Returns:
- true if the event is the corresponding end event to the specified start event, otherwise false.
-
getCharacters
java.lang.String getCharacters(javax.xml.stream.events.XMLEvent event)
Returns the text associated with the event.- Parameters:
event- the event of interest.- Returns:
- the event's characters, or null if the event is not a character event.
-
getStringParser
StringXMLEventParser getStringParser()
Returns the default parser for a simple string.- Returns:
- a string parser.
-
getDoubleParser
DoubleXMLEventParser getDoubleParser()
Returns a parser for a simple double.- Returns:
- a double parser.
-
getBooleanParser
BooleanXMLEventParser getBooleanParser()
Returns the default parser for a simple boolean.- Returns:
- a boolean parser.
-
getBooleanIntegerParser
BooleanIntegerXMLEventParser getBooleanIntegerParser()
Returns the default parser for a simple boolean integer (0 or 1).- Returns:
- a boolean integer parser.
-
getIntegerParser
IntegerXMLEventParser getIntegerParser()
Returns the default parser for a simple integer.- Returns:
- an integer parser.
-
registerParser
void registerParser(javax.xml.namespace.QName elementName, XMLEventParser parser)Registers a parser for a specified element name. A parser of the same type and namespace is returned whengetParser(javax.xml.stream.events.XMLEvent)is called for the same element name.- Parameters:
elementName- the element name for which to return a parser.parser- the parser to register.
-
hasNext
boolean hasNext()
Indicates whether the event stream associated with this context contains another event.- Returns:
- true if the stream contains another event, otherwise false.
- See Also:
XMLEventReader.hasNext()
-
nextEvent
javax.xml.stream.events.XMLEvent nextEvent() throws javax.xml.stream.XMLStreamExceptionReturns the next event in the event stream associated with this context.- Returns:
- the next event,
- Throws:
javax.xml.stream.XMLStreamException- if there is an error with the underlying XML.- See Also:
XMLEventReader.nextEvent()
-
getDefaultNamespaceURI
java.lang.String getDefaultNamespaceURI()
Returns the context's default namespace URI.- Returns:
- the context's default namespace URI.
- See Also:
setDefaultNamespaceURI(String)
-
setDefaultNamespaceURI
void setDefaultNamespaceURI(java.lang.String defaultNamespaceURI)
Specifies the context's default namespace URI. Must be called prior to initiating the parser table if this context's parsers will be qualified for the default namespace.- Parameters:
defaultNamespaceURI- the default namespace URI.- See Also:
getDefaultNamespaceURI(),isSameName(javax.xml.namespace.QName, javax.xml.namespace.QName)
-
isSameName
boolean isSameName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Determines whether two element names are the same.- Parameters:
qa- first element nameqb- second element name- Returns:
- true if both names have the same namespace (or no namespace) and local name, or if either name has no namespace but the namespace of the other is the context's default namespace.
-
allocate
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.- Parameters:
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.- Returns:
- a new parser, or the specified default parser if no parser has been registered for the element name.
-
allocate
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.- Parameters:
event- the event whose element name identifies the parser to create.- Returns:
- a new parser, or the specified default parser if no parser has been registered for the element name.
-
isSameAttributeName
boolean isSameAttributeName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Determines whether two fully qualified attribute names are the same.- Parameters:
qa- the first attribute name.qb- the second attribute name.- Returns:
- true if the names are the same, otherwise false.
-
getIdTable
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.- Returns:
- the mapping table.
-
addId
void addId(java.lang.String id, java.lang.Object o)Adds a mapping of an id attribute to its associated KML object.- Parameters:
id- the object id. If null, this method returns without creating a mapping.o- the object to associate with the id.
-
setNotificationListener
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. SeeXMLParserNotificationfor more information.The parser context may have only one notification listener. That listener may be changed at any time.
- Parameters:
listener- the object to receive notification events.
-
isDefaultNamespace
boolean isDefaultNamespace(java.lang.String namespaceURI)
Indicates whether the specified namespace URI is the default namespace URI used by this parser context.- Parameters:
namespaceURI- the namespace URI to check.- Returns:
- true if the specified namespace is the default namespace, otherwise false.
-
getUnrecognizedElementParser
XMLEventParser getUnrecognizedElementParser()
Returns a parser to handle unrecognized elements. The default unrecognized event parser isUnrecognizedXMLEventParser.- Returns:
- a parser to handle unrecognized elements.
-
addStringParsers
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.- Parameters:
namespace- the namespace URI.stringFields- the string list parser names.
-
addDoubleParsers
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.- Parameters:
namespace- the namespace URI.doubleFields- the string parsers.
-
addIntegerParsers
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.- Parameters:
namespace- the namespace URI.integerFields- the string parsers.
-
addBooleanParsers
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.- Parameters:
namespace- the namespace URI.booleanFields- the string parsers.
-
addBooleanIntegerParsers
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.- Parameters:
namespace- the namespace URI.booleanIntegerFields- the string parser.
-
-