Package gov.nasa.worldwind.util.xml
Class BasicXMLEventParserContext
- java.lang.Object
- 
- gov.nasa.worldwind.avlist.AVListImpl
- 
- gov.nasa.worldwind.util.xml.BasicXMLEventParserContext
 
 
- 
- All Implemented Interfaces:
- AVList,- XMLEventParserContext
 - Direct Known Subclasses:
- AtomParserContext,- ColladaParserContext,- GXParserContext,- KMLParserContext,- XALParserContext
 
 public class BasicXMLEventParserContext extends AVListImpl implements XMLEventParserContext Provides an implementation ofXMLEventParserContext. This class is meant to be the base class for schema-specific parsers.
- 
- 
Field SummaryFields Modifier and Type Field Description static javax.xml.namespace.QNameBOOLEANThe parser name of the default boolean parser.static javax.xml.namespace.QNameBOOLEAN_INTEGERThe parser name of the default boolean integer parser.protected BooleanIntegerXMLEventParserbooleanIntegerParserprotected BooleanXMLEventParserbooleanParserprotected java.lang.StringdefaultNamespaceURIstatic javax.xml.namespace.QNameDOUBLEThe parser name of the default double parser.protected DoubleXMLEventParserdoubleParserprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object>idTablestatic javax.xml.namespace.QNameINTEGERThe parser name of the default integer parser.protected IntegerXMLEventParserintegerParserprotected XMLParserNotificationListenernotificationListenerprotected java.util.concurrent.ConcurrentHashMap<javax.xml.namespace.QName,XMLEventParser>parsersprotected javax.xml.stream.XMLEventReaderreaderstatic javax.xml.namespace.QNameSTRINGThe parser name of the default string parser.protected StringXMLEventParserstringParserstatic javax.xml.namespace.QNameUNRECOGNIZEDThe parser name of the unrecognized-element parser.- 
Fields inherited from interface gov.nasa.worldwind.util.xml.XMLEventParserContextUNRECOGNIZED_ELEMENT_PARSER
 
- 
 - 
Constructor SummaryConstructors Constructor 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.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete 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 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.IntegerXMLEventParsergetIntegerParser()Returns the default parser for a simple integer.XMLEventParsergetParser(javax.xml.namespace.QName name)Returns a new parser for a specified element name.XMLEventParsergetParser(javax.xml.stream.events.XMLEvent event)Returns a new parser for a specified event.protected XMLEventParsergetParser(javax.xml.stream.events.XMLEvent event, XMLEventParser defaultParser)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.protected voidinitialize()protected voidinitializeDefaultNotificationListener()protected voidinitializeParsers()Initializes the parser table with the default parsers for the strings, integers, etc., qualified for the default namespace.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.static booleanisEndElementEvent(javax.xml.stream.events.XMLEvent event, javax.xml.stream.events.XMLEvent startElement)protected static booleanisNullNamespace(java.lang.String namespaceURI)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.voidsetEventReader(javax.xml.stream.XMLEventReader reader)Specify the event reader for the parser context to use to parse XML.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 class gov.nasa.worldwind.avlist.AVListImpladdPropertyChangeListener, 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
 - 
Methods inherited from class java.lang.Objectclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface gov.nasa.worldwind.avlist.AVListaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
- 
 
- 
- 
- 
Field Detail- 
DOUBLEpublic static javax.xml.namespace.QName DOUBLE The parser name of the default double parser.
 - 
INTEGERpublic static javax.xml.namespace.QName INTEGER The parser name of the default integer parser.
 - 
STRINGpublic static javax.xml.namespace.QName STRING The parser name of the default string parser.
 - 
BOOLEANpublic static javax.xml.namespace.QName BOOLEAN The parser name of the default boolean parser.
 - 
BOOLEAN_INTEGERpublic static javax.xml.namespace.QName BOOLEAN_INTEGER The parser name of the default boolean integer parser.
 - 
UNRECOGNIZEDpublic static javax.xml.namespace.QName UNRECOGNIZED The parser name of the unrecognized-element parser.
 - 
readerprotected javax.xml.stream.XMLEventReader reader 
 - 
stringParserprotected StringXMLEventParser stringParser 
 - 
doubleParserprotected DoubleXMLEventParser doubleParser 
 - 
integerParserprotected IntegerXMLEventParser integerParser 
 - 
booleanParserprotected BooleanXMLEventParser booleanParser 
 - 
booleanIntegerParserprotected BooleanIntegerXMLEventParser booleanIntegerParser 
 - 
defaultNamespaceURIprotected java.lang.String defaultNamespaceURI 
 - 
notificationListenerprotected XMLParserNotificationListener notificationListener 
 - 
idTableprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.Object> idTable 
 - 
parsersprotected java.util.concurrent.ConcurrentHashMap<javax.xml.namespace.QName,XMLEventParser> parsers 
 
- 
 - 
Constructor Detail- 
BasicXMLEventParserContextpublic BasicXMLEventParserContext() Construct an instance. InvokesinitializeParsers()andinitialize().
 - 
BasicXMLEventParserContextpublic BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader) Construct an instance for a specified event reader. InvokesinitializeParsers()andinitialize().- Parameters:
- eventReader- the event reader to use for XML parsing.
 
 - 
BasicXMLEventParserContextpublic BasicXMLEventParserContext(javax.xml.stream.XMLEventReader eventReader, java.lang.String defaultNamespace)Construct an instance for a specified event reader and default namespace. InvokesinitializeParsers()andinitialize().- Parameters:
- eventReader- the event reader to use for XML parsing.
- defaultNamespace- the namespace URI of the default namespace.
 
 - 
BasicXMLEventParserContextpublic BasicXMLEventParserContext(BasicXMLEventParserContext ctx) 
 
- 
 - 
Method Detail- 
initializeprotected void initialize() 
 - 
initializeDefaultNotificationListenerprotected void initializeDefaultNotificationListener() 
 - 
initializeParsersprotected void initializeParsers() Initializes the parser table with the default parsers for the strings, integers, etc., qualified for the default namespace.
 - 
addStringParserspublic void addStringParsers(java.lang.String namespace, java.lang.String[] stringFields)Description copied from interface:XMLEventParserContextAdd string list parsers for a list of element types and qualified for a specified namespace.- Specified by:
- addStringParsersin interface- XMLEventParserContext
- Parameters:
- namespace- the namespace URI.
- stringFields- the string list parser names.
 
 - 
addDoubleParserspublic void addDoubleParsers(java.lang.String namespace, java.lang.String[] doubleFields)Description copied from interface:XMLEventParserContextAdd double parsers for a list of element types and qualified for a specified namespace.- Specified by:
- addDoubleParsersin interface- XMLEventParserContext
- Parameters:
- namespace- the namespace URI.
- doubleFields- the string parsers.
 
 - 
addIntegerParserspublic void addIntegerParsers(java.lang.String namespace, java.lang.String[] integerFields)Description copied from interface:XMLEventParserContextAdd integer parsers for a list of element types and qualified for a specified namespace.- Specified by:
- addIntegerParsersin interface- XMLEventParserContext
- Parameters:
- namespace- the namespace URI.
- integerFields- the string parsers.
 
 - 
addBooleanParserspublic void addBooleanParsers(java.lang.String namespace, java.lang.String[] booleanFields)Description copied from interface:XMLEventParserContextAdd boolean parsers for a list of element types and qualified for a specified namespace.- Specified by:
- addBooleanParsersin interface- XMLEventParserContext
- Parameters:
- namespace- the namespace URI.
- booleanFields- the string parsers.
 
 - 
addBooleanIntegerParserspublic void addBooleanIntegerParsers(java.lang.String namespace, java.lang.String[] booleanIntegerFields)Description copied from interface:XMLEventParserContextAdd boolean integer parsers for a list of element types and qualified for a specified namespace.- Specified by:
- addBooleanIntegerParsersin interface- XMLEventParserContext
- Parameters:
- namespace- the namespace URI.
- booleanIntegerFields- the string parser.
 
 - 
getEventReaderpublic javax.xml.stream.XMLEventReader getEventReader() Returns the event reader used by this instance.- Specified by:
- getEventReaderin interface- XMLEventParserContext
- Returns:
- the instance's event reader.
 
 - 
setEventReaderpublic void setEventReader(javax.xml.stream.XMLEventReader reader) Specify the event reader for the parser context to use to parse XML.- Parameters:
- reader- the event reader to use.
 
 - 
getDefaultNamespaceURIpublic java.lang.String getDefaultNamespaceURI() Description copied from interface:XMLEventParserContextReturns the context's default namespace URI.- Specified by:
- getDefaultNamespaceURIin interface- XMLEventParserContext
- Returns:
- the context's default namespace URI.
- See Also:
- XMLEventParserContext.setDefaultNamespaceURI(String)
 
 - 
setDefaultNamespaceURIpublic void setDefaultNamespaceURI(java.lang.String defaultNamespaceURI) Description copied from interface:XMLEventParserContextSpecifies 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.- Specified by:
- setDefaultNamespaceURIin interface- XMLEventParserContext
- Parameters:
- defaultNamespaceURI- the default namespace URI.
- See Also:
- XMLEventParserContext.getDefaultNamespaceURI(),- XMLEventParserContext.isSameName(javax.xml.namespace.QName, javax.xml.namespace.QName)
 
 - 
setNotificationListenerpublic void setNotificationListener(XMLParserNotificationListener listener) Description copied from interface:XMLEventParserContextSpecify 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. - Specified by:
- setNotificationListenerin interface- XMLEventParserContext
- Parameters:
- listener- the object to receive notification events.
 
 - 
getIdTablepublic java.util.Map<java.lang.String,java.lang.Object> getIdTable() Description copied from interface:XMLEventParserContextReturns the table associating objects with their id attribute as specified in the object's KML file.- Specified by:
- getIdTablein interface- XMLEventParserContext
- Returns:
- the mapping table.
 
 - 
addIdpublic void addId(java.lang.String id, java.lang.Object o)Description copied from interface:XMLEventParserContextAdds a mapping of an id attribute to its associated KML object.- Specified by:
- addIdin interface- XMLEventParserContext
- Parameters:
- id- the object id. If null, this method returns without creating a mapping.
- o- the object to associate with the id.
 
 - 
hasNextpublic boolean hasNext() Description copied from interface:XMLEventParserContextIndicates whether the event stream associated with this context contains another event.- Specified by:
- hasNextin interface- XMLEventParserContext
- Returns:
- true if the stream contains another event, otherwise false.
- See Also:
- XMLEventReader.hasNext()
 
 - 
nextEventpublic javax.xml.stream.events.XMLEvent nextEvent() throws javax.xml.stream.XMLStreamExceptionDescription copied from interface:XMLEventParserContextReturns the next event in the event stream associated with this context.- Specified by:
- nextEventin interface- XMLEventParserContext
- Returns:
- the next event,
- Throws:
- javax.xml.stream.XMLStreamException- if there is an error with the underlying XML.
- See Also:
- XMLEventReader.nextEvent()
 
 - 
allocatepublic XMLEventParser allocate(javax.xml.stream.events.XMLEvent event, XMLEventParser defaultParser) Description copied from interface:XMLEventParserContextCreate a parser for a specified event's element name, if a parser for that name is registered with the context.- Specified by:
- allocatein interface- XMLEventParserContext
- 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.
 
 - 
allocatepublic XMLEventParser allocate(javax.xml.stream.events.XMLEvent event) Description copied from interface:XMLEventParserContextCreate a parser for a specified event's element name, if a parser for that name is registered with the context.- Specified by:
- allocatein interface- XMLEventParserContext
- 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.
 
 - 
getParserpublic XMLEventParser getParser(javax.xml.stream.events.XMLEvent event) Description copied from interface:XMLEventParserContextReturns a new parser for a specified event.- Specified by:
- getParserin interface- XMLEventParserContext
- 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.
 
 - 
getParserprotected XMLEventParser getParser(javax.xml.stream.events.XMLEvent event, XMLEventParser defaultParser) 
 - 
getStringParserpublic StringXMLEventParser getStringParser() Description copied from interface:XMLEventParserContextReturns the default parser for a simple string.- Specified by:
- getStringParserin interface- XMLEventParserContext
- Returns:
- a string parser.
 
 - 
getDoubleParserpublic DoubleXMLEventParser getDoubleParser() Description copied from interface:XMLEventParserContextReturns a parser for a simple double.- Specified by:
- getDoubleParserin interface- XMLEventParserContext
- Returns:
- a double parser.
 
 - 
getIntegerParserpublic IntegerXMLEventParser getIntegerParser() Description copied from interface:XMLEventParserContextReturns the default parser for a simple integer.- Specified by:
- getIntegerParserin interface- XMLEventParserContext
- Returns:
- an integer parser.
 
 - 
getBooleanParserpublic BooleanXMLEventParser getBooleanParser() Description copied from interface:XMLEventParserContextReturns the default parser for a simple boolean.- Specified by:
- getBooleanParserin interface- XMLEventParserContext
- Returns:
- a boolean parser.
 
 - 
getBooleanIntegerParserpublic BooleanIntegerXMLEventParser getBooleanIntegerParser() Description copied from interface:XMLEventParserContextReturns the default parser for a simple boolean integer (0 or 1).- Specified by:
- getBooleanIntegerParserin interface- XMLEventParserContext
- Returns:
- a boolean integer parser.
 
 - 
getUnrecognizedElementParserpublic XMLEventParser getUnrecognizedElementParser() Returns a parser to handle unrecognized elements. The default unrecognized event parser isUnrecognizedXMLEventParser, and may be replaced by callingregisterParser(javax.xml.namespace.QName, XMLEventParser)and specifyingUNRECOGNIZEDas the parser name.- Specified by:
- getUnrecognizedElementParserin interface- XMLEventParserContext
- Returns:
- a parser to handle unrecognized elements.
 
 - 
getCharacterspublic java.lang.String getCharacters(javax.xml.stream.events.XMLEvent event) Description copied from interface:XMLEventParserContextReturns the text associated with the event.- Specified by:
- getCharactersin interface- XMLEventParserContext
- Parameters:
- event- the event of interest.
- Returns:
- the event's characters, or null if the event is not a character event.
 
 - 
isSameNamepublic boolean isSameName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Description copied from interface:XMLEventParserContextDetermines whether two element names are the same.- Specified by:
- isSameNamein interface- XMLEventParserContext
- 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.
 
 - 
isSameAttributeNamepublic boolean isSameAttributeName(javax.xml.namespace.QName qa, javax.xml.namespace.QName qb)Description copied from interface:XMLEventParserContextDetermines whether two fully qualified attribute names are the same.- Specified by:
- isSameAttributeNamein interface- XMLEventParserContext
- Parameters:
- qa- the first attribute name.
- qb- the second attribute name.
- Returns:
- true if the names are the same, otherwise false.
 
 - 
isStartElementpublic boolean isStartElement(javax.xml.stream.events.XMLEvent event, javax.xml.namespace.QName elementName)Description copied from interface:XMLEventParserContextDetermines whether an event is a start event for a specific event type.- Specified by:
- isStartElementin interface- XMLEventParserContext
- 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.
 
 - 
isStartElementpublic boolean isStartElement(javax.xml.stream.events.XMLEvent event, java.lang.String elementName)Description copied from interface:XMLEventParserContextDetermines whether an event is a start event for a specific event type indicated by its local name.- Specified by:
- isStartElementin interface- XMLEventParserContext
- 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.
 
 - 
isEndElementpublic boolean isEndElement(javax.xml.stream.events.XMLEvent event, javax.xml.stream.events.XMLEvent startElement)Description copied from interface:XMLEventParserContextDetermines 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. - Specified by:
- isEndElementin interface- XMLEventParserContext
- 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.
 
 - 
isEndElementEventpublic static boolean isEndElementEvent(javax.xml.stream.events.XMLEvent event, javax.xml.stream.events.XMLEvent startElement)
 - 
registerParserpublic void registerParser(javax.xml.namespace.QName elementName, XMLEventParser parser)Description copied from interface:XMLEventParserContextRegisters a parser for a specified element name. A parser of the same type and namespace is returned whenXMLEventParserContext.getParser(javax.xml.stream.events.XMLEvent)is called for the same element name.- Specified by:
- registerParserin interface- XMLEventParserContext
- Parameters:
- elementName- the element name for which to return a parser.
- parser- the parser to register.
 
 - 
getParserpublic XMLEventParser getParser(javax.xml.namespace.QName name) Description copied from interface:XMLEventParserContextReturns a new parser for a specified element name.- Specified by:
- getParserin interface- XMLEventParserContext
- Parameters:
- name- 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.
 
 - 
isNullNamespaceprotected static boolean isNullNamespace(java.lang.String namespaceURI) 
 - 
isDefaultNamespacepublic boolean isDefaultNamespace(java.lang.String namespaceURI) Description copied from interface:XMLEventParserContextIndicates whether the specified namespace URI is the default namespace URI used by this parser context.- Specified by:
- isDefaultNamespacein interface- XMLEventParserContext
- Parameters:
- namespaceURI- the namespace URI to check.
- Returns:
- true if the specified namespace is the default namespace, otherwise false.
 
 
- 
 
-