Class ContentHandler

  • Direct Known Subclasses:
    XmlRpcContentHandler

    public abstract class ContentHandler
    extends java.lang.Object
    Receive notification of the logical content of a document.

    Note: While in the SAX 2.0 spirit, this implementation is not fully compliant.  Speed and footprint took precedence over what the author judged being details.

    This is the main interface that most SAX applications implement: if the application needs to be informed of basic parsing events, it implements this interface and registers an instance with the XML reader using the XmlReader.setContentHandler(totalcross.xml.ContentHandler) method. The XML reader uses the instance to report basic document-related events like the start and end of elements and character data.

    The order of events in this interface is very important, and mirrors the order of information in the document itself. For example, all of an element's content (character data, processing instructions, and/or subelements) will appear, in order, between the startElement event and the corresponding endElement event.

    • Constructor Summary

      Constructors 
      Constructor Description
      ContentHandler()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void cdata​(int tag, java.lang.String cdata)
      Receive notification of cdata.
      abstract void characters​(java.lang.String s)
      Receive notification of character data.
      void comment​(java.lang.String s)
      Receive notification of comment data.
      abstract void endElement​(int tag)
      Receive notification of the end of an element.
      abstract void startElement​(int tag, AttributeList atts)
      Receive notification of the beginning of an element.
      void tagName​(int tag, java.lang.String name, AttributeList atts)
      Name of the tag.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ContentHandler

        public ContentHandler()
    • Method Detail

      • startElement

        public abstract void startElement​(int tag,
                                          AttributeList atts)
        Receive notification of the beginning of an element.

        The XmlReader will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.

        Parameters:
        tag - tag identifier for this element
        atts - The attributes list attached to the element.
      • endElement

        public abstract void endElement​(int tag)
        Receive notification of the end of an element.

        The XMLReader will invoke this method at the end of every element in the XML document; there will be a corresponding startElement event for every endElement event (even when the element is empty).

        Parameters:
        tag - tag identifier for this element
      • characters

        public abstract void characters​(java.lang.String s)
        Receive notification of character data.

        The XMLReader will call this method to report each chunk of character data. This XMLReader implementation return all contiguous character data in a single chunk.

        Parameters:
        s - The string of characters from the XML document.
      • comment

        public void comment​(java.lang.String s)
        Receive notification of comment data.

        The XMLReader will call this method to report each chunk of comments. This XMLReader implementation returns all contiguous comment data in a single chunk.

        Parameters:
        s - The string of characters from the XML document.
      • cdata

        public void cdata​(int tag,
                          java.lang.String cdata)
        Receive notification of cdata.

        The XMLReader will call this method to report each chunk of cdata found during the parse. This XMLReader implementation returns all contiguous data in a single chunk, except for the <![CDATA[ and ]]> delimiters.

        Parameters:
        tag - tag identifier for this element
        cdata - unparsed data from the XML document.
        Since:
        TotalCross 1.27
      • tagName

        public void tagName​(int tag,
                            java.lang.String name,
                            AttributeList atts)
        Name of the tag.

        The XmlReader will invoke this method at the beginning of every element in the XML document. All of the element's content will be reported in order.

        Parameters:
        tag - tag identifier for this element
        name - tag name