NASA World Wind

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
static String UNRECOGNIZED_ELEMENT_PARSER
          Identifies the name of the parser handling unrecognized elements.
 
Method Summary
 void addId(String id, Object o)
          Adds a mapping of an id attribute to its associated KML object.
 XMLEventParser allocate(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(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.
 String getCharacters(XMLEvent event)
          Returns the text associated with the event.
 String getDefaultNamespaceURI()
          Returns the context's default namespace URI.
 DoubleXMLEventParser getDoubleParser()
          Returns a parser for a simple double.
 XMLEventReader getEventReader()
          Returns the event reader associated with the context.
 Map<String,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(QName eventName)
          Returns a new parser for a specified element name.
 XMLEventParser getParser(XMLEvent event)
          Returns a new parser for a specified event.
 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.
 boolean isDefaultNamespace(String namespaceURI)
          Indicates whether the specified namespace URI is the default namespace URI used by this parser context.
 boolean isEndElement(XMLEvent event, XMLEvent startElement)
          Determines whether an event is the corresponding end element for a specified start event.
 boolean isSameAttributeName(QName qa, QName qb)
          Determines whether two fully qualified attribute names are the same.
 boolean isSameName(QName qa, QName qb)
          Determines whether two element names are the same.
 boolean isStartElement(XMLEvent event, QName elementName)
          Determines whether an event is a start event for a specific event type.
 XMLEvent nextEvent()
          Returns the next event in the event stream associated with this context.
 void registerParser(QName elementName, XMLEventParser parser)
          Registers a parser for a specified element name.
 void setDefaultNamespaceURI(String defaultNamespaceURI)
          Specifies the context's default namespace URI.
 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.
 
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 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

addId

void addId(String id,
           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.

allocate

XMLEventParser allocate(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.

allocate

XMLEventParser allocate(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.

getBooleanIntegerParser

BooleanIntegerXMLEventParser getBooleanIntegerParser()
Returns the default parser for a simple boolean integer (0 or 1).

Returns:
a boolean integer parser.

getBooleanParser

BooleanXMLEventParser getBooleanParser()
Returns the default parser for a simple boolean.

Returns:
a boolean parser.

getCharacters

String getCharacters(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.

getDefaultNamespaceURI

String getDefaultNamespaceURI()
Returns the context's default namespace URI.

Returns:
the context's default namespace URI.
See Also:
setDefaultNamespaceURI(String)

getDoubleParser

DoubleXMLEventParser getDoubleParser()
Returns a parser for a simple double.

Returns:
a double parser.

getEventReader

XMLEventReader getEventReader()
Returns the event reader associated with the context.

Returns:
the associated event reader, or null if no reader is associated.

getIdTable

Map<String,Object> getIdTable()
Returns the table associating objects with their id attribute as specified in the object's KML file.

Returns:
the mapping table.

getIntegerParser

IntegerXMLEventParser getIntegerParser()
Returns the default parser for a simple integer.

Returns:
an integer parser.

getParser

XMLEventParser getParser(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.

getParser

XMLEventParser getParser(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.

getStringParser

StringXMLEventParser getStringParser()
Returns the default parser for a simple string.

Returns:
a string parser.

getUnrecognizedElementParser

XMLEventParser getUnrecognizedElementParser()
Returns a parser to handle unrecognized elements. The default unrecognized event parser is UnrecognizedXMLEventParser.

Returns:
a parser to handle unrecognized elements.

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()

isDefaultNamespace

boolean isDefaultNamespace(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.

isEndElement

boolean isEndElement(XMLEvent event,
                     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.

isSameAttributeName

boolean isSameAttributeName(QName qa,
                            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.

isSameName

boolean isSameName(QName qa,
                   QName qb)
Determines whether two element names are the same.

Parameters:
qa - first element name
qb - 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.

isStartElement

boolean isStartElement(XMLEvent event,
                       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.

nextEvent

XMLEvent nextEvent()
                   throws XMLStreamException
Returns the next event in the event stream associated with this context.

Returns:
the next event,
Throws:
XMLStreamException - if there is an error with the underlying XML.
See Also:
XMLEventReader.nextEvent()

registerParser

void registerParser(QName elementName,
                    XMLEventParser parser)
Registers a parser for a specified element name. A parser of the same type and namespace is returned when getParser(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.

setDefaultNamespaceURI

void setDefaultNamespaceURI(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)

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. See XMLParserNotification for 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.

NASA World Wind