Class NamespacedSAXConfigurationHandler

  • All Implemented Interfaces:
    org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

    public class NamespacedSAXConfigurationHandler
    extends SAXConfigurationHandler
    A SAXConfigurationHandler helps build Configurations out of sax events, including namespace information.
    Version:
    $Id: NamespacedSAXConfigurationHandler.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $
    Author:
    Avalon Development Team
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int EXPECTED_DEPTH
      Likely number of nested configuration items.
      private org.apache.avalon.framework.configuration.Configuration m_configuration  
      private java.util.ArrayList m_elements  
      private org.xml.sax.Locator m_locator  
      private org.xml.sax.helpers.NamespaceSupport m_namespaceSupport  
      private java.util.ArrayList m_prefixes  
      private java.util.BitSet m_preserveSpace
      Contains true at index n if space in the configuration with depth n is to be preserved.
      private java.util.ArrayList m_values  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int end)
      Handling hook for character data.
      void clear()
      Clears all data from this configuration handler.
      protected DefaultConfiguration createConfiguration​(java.lang.String localName, java.lang.String namespaceURI, java.lang.String location)
      Create a new DefaultConfiguration with the specified local name, namespace, and location.
      void endDocument()
      Handling hook for ending the document parsing.
      void endElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName)
      Handling hook for finishing parsing of an element.
      void error​(org.xml.sax.SAXParseException exception)
      This just throws an exception on a parse error.
      void fatalError​(org.xml.sax.SAXParseException exception)
      This just throws an exception on a parse error.
      org.apache.avalon.framework.configuration.Configuration getConfiguration()
      Get the configuration object that was built.
      protected java.lang.String getLocationString()
      Returns a string showing the current system ID, line number and column number.
      void setDocumentLocator​(org.xml.sax.Locator locator)
      Set the document Locator to use.
      void startDocument()
      Handling hook for starting the document parsing.
      void startElement​(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)
      Handling hook for starting parsing of an element.
      void startPrefixMapping​(java.lang.String prefix, java.lang.String uri)
      Handling hook for starting prefix mapping.
      void warning​(org.xml.sax.SAXParseException exception)
      This just throws an exception on a parse error.
      • Methods inherited from class org.xml.sax.helpers.DefaultHandler

        endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, unparsedEntityDecl
      • Methods inherited from class java.lang.Object

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

      • EXPECTED_DEPTH

        private static final int EXPECTED_DEPTH
        Likely number of nested configuration items. If more is encountered the lists will grow automatically.
        See Also:
        Constant Field Values
      • m_elements

        private final java.util.ArrayList m_elements
      • m_prefixes

        private final java.util.ArrayList m_prefixes
      • m_values

        private final java.util.ArrayList m_values
      • m_preserveSpace

        private final java.util.BitSet m_preserveSpace
        Contains true at index n if space in the configuration with depth n is to be preserved.
      • m_configuration

        private org.apache.avalon.framework.configuration.Configuration m_configuration
      • m_locator

        private org.xml.sax.Locator m_locator
      • m_namespaceSupport

        private org.xml.sax.helpers.NamespaceSupport m_namespaceSupport
    • Constructor Detail

      • NamespacedSAXConfigurationHandler

        public NamespacedSAXConfigurationHandler()
    • Method Detail

      • getConfiguration

        public org.apache.avalon.framework.configuration.Configuration getConfiguration()
        Get the configuration object that was built.
        Overrides:
        getConfiguration in class SAXConfigurationHandler
        Returns:
        a Configuration object
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Set the document Locator to use.
        Specified by:
        setDocumentLocator in interface org.xml.sax.ContentHandler
        Overrides:
        setDocumentLocator in class SAXConfigurationHandler
        Parameters:
        locator - a Locator value
      • startDocument

        public void startDocument()
                           throws org.xml.sax.SAXException
        Handling hook for starting the document parsing.
        Specified by:
        startDocument in interface org.xml.sax.ContentHandler
        Overrides:
        startDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • endDocument

        public void endDocument()
                         throws org.xml.sax.SAXException
        Handling hook for ending the document parsing.
        Specified by:
        endDocument in interface org.xml.sax.ContentHandler
        Overrides:
        endDocument in class org.xml.sax.helpers.DefaultHandler
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • characters

        public void characters​(char[] ch,
                               int start,
                               int end)
                        throws org.xml.sax.SAXException
        Handling hook for character data.
        Specified by:
        characters in interface org.xml.sax.ContentHandler
        Overrides:
        characters in class SAXConfigurationHandler
        Parameters:
        ch - a char[] of data
        start - offset in the character array from which to start reading
        end - length of character data
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • endElement

        public void endElement​(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String rawName)
                        throws org.xml.sax.SAXException
        Handling hook for finishing parsing of an element.
        Specified by:
        endElement in interface org.xml.sax.ContentHandler
        Overrides:
        endElement in class SAXConfigurationHandler
        Parameters:
        namespaceURI - a String value
        localName - a String value
        rawName - a String value
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • createConfiguration

        protected DefaultConfiguration createConfiguration​(java.lang.String localName,
                                                           java.lang.String namespaceURI,
                                                           java.lang.String location)
        Create a new DefaultConfiguration with the specified local name, namespace, and location.
        Parameters:
        localName - a String value
        namespaceURI - a String value
        location - a String value
        Returns:
        a DefaultConfiguration value
      • startElement

        public void startElement​(java.lang.String namespaceURI,
                                 java.lang.String localName,
                                 java.lang.String rawName,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException
        Handling hook for starting parsing of an element.
        Specified by:
        startElement in interface org.xml.sax.ContentHandler
        Overrides:
        startElement in class SAXConfigurationHandler
        Parameters:
        namespaceURI - a String value
        localName - a String value
        rawName - a String value
        attributes - an Attributes value
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • error

        public void error​(org.xml.sax.SAXParseException exception)
                   throws org.xml.sax.SAXException
        This just throws an exception on a parse error.
        Specified by:
        error in interface org.xml.sax.ErrorHandler
        Overrides:
        error in class SAXConfigurationHandler
        Parameters:
        exception - the parse error
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • warning

        public void warning​(org.xml.sax.SAXParseException exception)
                     throws org.xml.sax.SAXException
        This just throws an exception on a parse error.
        Specified by:
        warning in interface org.xml.sax.ErrorHandler
        Overrides:
        warning in class SAXConfigurationHandler
        Parameters:
        exception - the parse error
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • fatalError

        public void fatalError​(org.xml.sax.SAXParseException exception)
                        throws org.xml.sax.SAXException
        This just throws an exception on a parse error.
        Specified by:
        fatalError in interface org.xml.sax.ErrorHandler
        Overrides:
        fatalError in class SAXConfigurationHandler
        Parameters:
        exception - the parse error
        Throws:
        org.xml.sax.SAXException - if an error occurs
      • getLocationString

        protected java.lang.String getLocationString()
        Returns a string showing the current system ID, line number and column number.
        Overrides:
        getLocationString in class SAXConfigurationHandler
        Returns:
        a String value
      • startPrefixMapping

        public void startPrefixMapping​(java.lang.String prefix,
                                       java.lang.String uri)
                                throws org.xml.sax.SAXException
        Handling hook for starting prefix mapping.
        Specified by:
        startPrefixMapping in interface org.xml.sax.ContentHandler
        Overrides:
        startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
        Parameters:
        prefix - a String value
        uri - a String value
        Throws:
        org.xml.sax.SAXException - if an error occurs