Class BasicXMLEventParserContext

    • Field Detail

      • DOUBLE

        public static javax.xml.namespace.QName DOUBLE
        The parser name of the default double parser.
      • INTEGER

        public static javax.xml.namespace.QName INTEGER
        The parser name of the default integer parser.
      • STRING

        public static javax.xml.namespace.QName STRING
        The parser name of the default string parser.
      • BOOLEAN

        public static javax.xml.namespace.QName BOOLEAN
        The parser name of the default boolean parser.
      • BOOLEAN_INTEGER

        public static javax.xml.namespace.QName BOOLEAN_INTEGER
        The parser name of the default boolean integer parser.
      • UNRECOGNIZED

        public static javax.xml.namespace.QName UNRECOGNIZED
        The parser name of the unrecognized-element parser.
      • reader

        protected javax.xml.stream.XMLEventReader reader
      • defaultNamespaceURI

        protected java.lang.String defaultNamespaceURI
      • idTable

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.Object> idTable
      • parsers

        protected java.util.concurrent.ConcurrentHashMap<javax.xml.namespace.QName,​XMLEventParser> parsers
    • Constructor Detail

      • BasicXMLEventParserContext

        public BasicXMLEventParserContext​(javax.xml.stream.XMLEventReader eventReader)
        Construct an instance for a specified event reader. Invokes initializeParsers() and initialize().
        Parameters:
        eventReader - the event reader to use for XML parsing.
      • BasicXMLEventParserContext

        public BasicXMLEventParserContext​(javax.xml.stream.XMLEventReader eventReader,
                                          java.lang.String defaultNamespace)
        Construct an instance for a specified event reader and default namespace. Invokes initializeParsers() and initialize().
        Parameters:
        eventReader - the event reader to use for XML parsing.
        defaultNamespace - the namespace URI of the default namespace.
    • Method Detail

      • initialize

        protected void initialize()
      • initializeDefaultNotificationListener

        protected void initializeDefaultNotificationListener()
      • initializeParsers

        protected void initializeParsers()
        Initializes the parser table with the default parsers for the strings, integers, etc., qualified for the default namespace.
      • addStringParsers

        public void addStringParsers​(java.lang.String namespace,
                                     java.lang.String[] stringFields)
        Description copied from interface: XMLEventParserContext
        Add string list parsers for a list of element types and qualified for a specified namespace.
        Specified by:
        addStringParsers in interface XMLEventParserContext
        Parameters:
        namespace - the namespace URI.
        stringFields - the string list parser names.
      • addDoubleParsers

        public void addDoubleParsers​(java.lang.String namespace,
                                     java.lang.String[] doubleFields)
        Description copied from interface: XMLEventParserContext
        Add double parsers for a list of element types and qualified for a specified namespace.
        Specified by:
        addDoubleParsers in interface XMLEventParserContext
        Parameters:
        namespace - the namespace URI.
        doubleFields - the string parsers.
      • addIntegerParsers

        public void addIntegerParsers​(java.lang.String namespace,
                                      java.lang.String[] integerFields)
        Description copied from interface: XMLEventParserContext
        Add integer parsers for a list of element types and qualified for a specified namespace.
        Specified by:
        addIntegerParsers in interface XMLEventParserContext
        Parameters:
        namespace - the namespace URI.
        integerFields - the string parsers.
      • addBooleanParsers

        public void addBooleanParsers​(java.lang.String namespace,
                                      java.lang.String[] booleanFields)
        Description copied from interface: XMLEventParserContext
        Add boolean parsers for a list of element types and qualified for a specified namespace.
        Specified by:
        addBooleanParsers in interface XMLEventParserContext
        Parameters:
        namespace - the namespace URI.
        booleanFields - the string parsers.
      • addBooleanIntegerParsers

        public void addBooleanIntegerParsers​(java.lang.String namespace,
                                             java.lang.String[] booleanIntegerFields)
        Description copied from interface: XMLEventParserContext
        Add boolean integer parsers for a list of element types and qualified for a specified namespace.
        Specified by:
        addBooleanIntegerParsers in interface XMLEventParserContext
        Parameters:
        namespace - the namespace URI.
        booleanIntegerFields - the string parser.
      • getEventReader

        public javax.xml.stream.XMLEventReader getEventReader()
        Returns the event reader used by this instance.
        Specified by:
        getEventReader in interface XMLEventParserContext
        Returns:
        the instance's event reader.
      • setEventReader

        public 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.
      • setNotificationListener

        public void setNotificationListener​(XMLParserNotificationListener listener)
        Description copied from interface: XMLEventParserContext
        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.

        Specified by:
        setNotificationListener in interface XMLEventParserContext
        Parameters:
        listener - the object to receive notification events.
      • getIdTable

        public java.util.Map<java.lang.String,​java.lang.Object> getIdTable()
        Description copied from interface: XMLEventParserContext
        Returns the table associating objects with their id attribute as specified in the object's KML file.
        Specified by:
        getIdTable in interface XMLEventParserContext
        Returns:
        the mapping table.
      • addId

        public void addId​(java.lang.String id,
                          java.lang.Object o)
        Description copied from interface: XMLEventParserContext
        Adds a mapping of an id attribute to its associated KML object.
        Specified by:
        addId in interface XMLEventParserContext
        Parameters:
        id - the object id. If null, this method returns without creating a mapping.
        o - the object to associate with the id.
      • hasNext

        public boolean hasNext()
        Description copied from interface: XMLEventParserContext
        Indicates whether the event stream associated with this context contains another event.
        Specified by:
        hasNext in interface XMLEventParserContext
        Returns:
        true if the stream contains another event, otherwise false.
        See Also:
        XMLEventReader.hasNext()
      • nextEvent

        public javax.xml.stream.events.XMLEvent nextEvent()
                                                   throws javax.xml.stream.XMLStreamException
        Description copied from interface: XMLEventParserContext
        Returns the next event in the event stream associated with this context.
        Specified by:
        nextEvent in interface XMLEventParserContext
        Returns:
        the next event,
        Throws:
        javax.xml.stream.XMLStreamException - if there is an error with the underlying XML.
        See Also:
        XMLEventReader.nextEvent()
      • allocate

        public XMLEventParser allocate​(javax.xml.stream.events.XMLEvent event,
                                       XMLEventParser defaultParser)
        Description copied from interface: XMLEventParserContext
        Create a parser for a specified event's element name, if a parser for that name is registered with the context.
        Specified by:
        allocate in 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.
      • allocate

        public XMLEventParser allocate​(javax.xml.stream.events.XMLEvent event)
        Description copied from interface: XMLEventParserContext
        Create a parser for a specified event's element name, if a parser for that name is registered with the context.
        Specified by:
        allocate in 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.
      • getParser

        public XMLEventParser getParser​(javax.xml.stream.events.XMLEvent event)
        Description copied from interface: XMLEventParserContext
        Returns a new parser for a specified event.
        Specified by:
        getParser in 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.
      • getCharacters

        public java.lang.String getCharacters​(javax.xml.stream.events.XMLEvent event)
        Description copied from interface: XMLEventParserContext
        Returns the text associated with the event.
        Specified by:
        getCharacters in interface XMLEventParserContext
        Parameters:
        event - the event of interest.
        Returns:
        the event's characters, or null if the event is not a character event.
      • isSameName

        public boolean isSameName​(javax.xml.namespace.QName qa,
                                  javax.xml.namespace.QName qb)
        Description copied from interface: XMLEventParserContext
        Determines whether two element names are the same.
        Specified by:
        isSameName in 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.
      • isSameAttributeName

        public boolean isSameAttributeName​(javax.xml.namespace.QName qa,
                                           javax.xml.namespace.QName qb)
        Description copied from interface: XMLEventParserContext
        Determines whether two fully qualified attribute names are the same.
        Specified by:
        isSameAttributeName in interface XMLEventParserContext
        Parameters:
        qa - the first attribute name.
        qb - the second attribute name.
        Returns:
        true if the names are the same, otherwise false.
      • isStartElement

        public boolean isStartElement​(javax.xml.stream.events.XMLEvent event,
                                      javax.xml.namespace.QName elementName)
        Description copied from interface: XMLEventParserContext
        Determines whether an event is a start event for a specific event type.
        Specified by:
        isStartElement in 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.
      • isStartElement

        public boolean isStartElement​(javax.xml.stream.events.XMLEvent event,
                                      java.lang.String elementName)
        Description copied from interface: XMLEventParserContext
        Determines whether an event is a start event for a specific event type indicated by its local name.
        Specified by:
        isStartElement in 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.
      • isEndElement

        public boolean isEndElement​(javax.xml.stream.events.XMLEvent event,
                                    javax.xml.stream.events.XMLEvent startElement)
        Description copied from interface: XMLEventParserContext
        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.

        Specified by:
        isEndElement in 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.
      • isEndElementEvent

        public static boolean isEndElementEvent​(javax.xml.stream.events.XMLEvent event,
                                                javax.xml.stream.events.XMLEvent startElement)
      • getParser

        public XMLEventParser getParser​(javax.xml.namespace.QName name)
        Description copied from interface: XMLEventParserContext
        Returns a new parser for a specified element name.
        Specified by:
        getParser in 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.
      • isNullNamespace

        protected static boolean isNullNamespace​(java.lang.String namespaceURI)
      • isDefaultNamespace

        public boolean isDefaultNamespace​(java.lang.String namespaceURI)
        Description copied from interface: XMLEventParserContext
        Indicates whether the specified namespace URI is the default namespace URI used by this parser context.
        Specified by:
        isDefaultNamespace in interface XMLEventParserContext
        Parameters:
        namespaceURI - the namespace URI to check.
        Returns:
        true if the specified namespace is the default namespace, otherwise false.