Class AbstractParseState

  • Direct Known Subclasses:
    ParseState

    public abstract class AbstractParseState
    extends java.lang.Object
    Abstract parse state for the XMLParserHandler class. Derived classes create parse states based on this class.
    See Also:
    ParseState, AnyElementState
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String context
      SAX context string.
      protected java.lang.String elementName
      The name of the element being parsed.
      protected java.lang.StringBuffer text
      Accumulates any text that appears within the element tags.
    • Field Detail

      • context

        protected java.lang.String context
        SAX context string.
      • elementName

        protected java.lang.String elementName
        The name of the element being parsed.
      • text

        protected java.lang.StringBuffer text
        Accumulates any text that appears within the element tags.
    • Constructor Detail

      • AbstractParseState

        public AbstractParseState()
    • Method Detail

      • setElementName

        public void setElementName​(java.lang.String name)
        Sets the element name.
        Parameters:
        name - the name of the element.
      • jumpTo

        public AbstractParseState jumpTo()
        Jumps to the specified state that the current state needs to go.
        Returns:
        the other state.
      • parseAttrs

        public void parseAttrs​(org.xml.sax.Attributes attrs)
                        throws XMLParserException
        Called to parse attributes. This is the first method called after the state is created.Returns the value of attribute name.
        Parameters:
        attrs - the SAX attributes object
        Throws:
        XMLParserException - if any parse exception
        See Also:
        DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
      • startElement

        public AbstractParseState startElement​(java.lang.String tagName)
        Start a new tag. Derived classes override this to create a state to handle the element. Call this method to issue an error for, and ignore, any unrecognized tags.
        Parameters:
        tagName - the name of the starting element
        Returns:
        the state to parse the given tag
        See Also:
        DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
      • getHandler

        public abstract XMLParserHandler getHandler()
        Returns the parser handler. Required to be implemented by derived states. States will implement this differently depending on whether the state is a normal or inner class.
        Returns:
        the XML parser handler
      • endElement

        public void endElement​(AbstractParseState state)
        Called when a child element is ending.
        Parameters:
        state - the child state that is ending
      • end

        public void end()
                 throws org.xml.sax.SAXException
        Called when the element for this state is ending.
        Throws:
        org.xml.sax.SAXException - if the SAX exception is encountered.
        See Also:
        DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
      • getAttrib

        protected java.lang.String getAttrib​(org.xml.sax.Attributes attrs,
                                             java.lang.String attrName)
        Parse a string value. Normalizes the string: blank strings are converted to a null string.
        Parameters:
        attrs - the SAX attributes object
        attrName - the name of the attribute to parse
        Returns:
        the parsed string