Class ConfigurationXMLReader

  • All Implemented Interfaces:
    org.xml.sax.XMLReader
    Direct Known Subclasses:
    BaseConfigurationXMLReader, HierarchicalConfigurationXMLReader

    public abstract class ConfigurationXMLReader
    extends java.lang.Object
    implements org.xml.sax.XMLReader

    A base class for "faked" XMLReader classes that transform a configuration object in a set of SAX parsing events.

    This class provides dummy implementations for most of the methods defined in the XMLReader interface that are not used for this special purpose. There will be concrete sub classes that process specific configuration classes.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.xml.sax.ContentHandler contentHandler
      Stores the content handler.
      private static java.lang.String DEFAULT_ROOT_NAME
      Constant for the default name of the root element.
      private static org.xml.sax.Attributes EMPTY_ATTRS
      An empty attributes object.
      private org.xml.sax.SAXException exception
      Stores an exception that occurred during parsing.
      protected static java.lang.String NS_URI
      Constant for the namespace URI.
      private java.lang.String rootName
      Stores the name for the root element.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ConfigurationXMLReader()
      Creates a new instance of ConfigurationXMLReader.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void fireCharacters​(java.lang.String text)
      Fires a SAX characters event.
      protected void fireElementEnd​(java.lang.String name)
      Fires a SAX element end event.
      protected void fireElementStart​(java.lang.String name, org.xml.sax.Attributes attribs)
      Fires a SAX element start event.
      org.xml.sax.ContentHandler getContentHandler()
      Gets the actually set content handler.
      org.xml.sax.DTDHandler getDTDHandler()
      Gets the DTD handler.
      org.xml.sax.EntityResolver getEntityResolver()
      Gets the entity resolver.
      org.xml.sax.ErrorHandler getErrorHandler()
      Gets the error handler.
      org.xml.sax.SAXException getException()
      Gets a reference to an exception that occurred during parsing.
      boolean getFeature​(java.lang.String name)
      Dummy implementation of the interface method.
      abstract Configuration getParsedConfiguration()
      Gets a reference to the configuration that is parsed by this object.
      java.lang.Object getProperty​(java.lang.String name)
      Dummy implementation of the interface method.
      java.lang.String getRootName()
      Gets the name to be used for the root element.
      void parse​(java.lang.String systemId)
      Parses the current configuration object.
      void parse​(org.xml.sax.InputSource input)
      Parses the actual configuration object.
      protected void parseConfiguration()
      Parses the configuration object and generates SAX events.
      protected abstract void processKeys()
      Processes all keys stored in the actual configuration.
      void setContentHandler​(org.xml.sax.ContentHandler handler)
      Sets the content handler.
      void setDTDHandler​(org.xml.sax.DTDHandler handler)
      Sets the DTD handler.
      void setEntityResolver​(org.xml.sax.EntityResolver resolver)
      Sets the entity resolver.
      void setErrorHandler​(org.xml.sax.ErrorHandler handler)
      Sets the error handler.
      void setFeature​(java.lang.String name, boolean value)
      Dummy implementation of the interface method.
      void setProperty​(java.lang.String name, java.lang.Object value)
      Dummy implementation of the interface method.
      void setRootName​(java.lang.String string)
      Sets the name for the root element.
      • Methods inherited from class java.lang.Object

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

      • NS_URI

        protected static final java.lang.String NS_URI
        Constant for the namespace URI.
        See Also:
        Constant Field Values
      • DEFAULT_ROOT_NAME

        private static final java.lang.String DEFAULT_ROOT_NAME
        Constant for the default name of the root element.
        See Also:
        Constant Field Values
      • EMPTY_ATTRS

        private static final org.xml.sax.Attributes EMPTY_ATTRS
        An empty attributes object.
      • contentHandler

        private org.xml.sax.ContentHandler contentHandler
        Stores the content handler.
      • exception

        private org.xml.sax.SAXException exception
        Stores an exception that occurred during parsing.
      • rootName

        private java.lang.String rootName
        Stores the name for the root element.
    • Constructor Detail

      • ConfigurationXMLReader

        protected ConfigurationXMLReader()
        Creates a new instance of ConfigurationXMLReader.
    • Method Detail

      • fireCharacters

        protected void fireCharacters​(java.lang.String text)
        Fires a SAX characters event.
        Parameters:
        text - the text
      • fireElementEnd

        protected void fireElementEnd​(java.lang.String name)
        Fires a SAX element end event.
        Parameters:
        name - the name of the affected element
      • fireElementStart

        protected void fireElementStart​(java.lang.String name,
                                        org.xml.sax.Attributes attribs)
        Fires a SAX element start event.
        Parameters:
        name - the name of the actual element
        attribs - the attributes of this element (can be null)
      • getContentHandler

        public org.xml.sax.ContentHandler getContentHandler()
        Gets the actually set content handler.
        Specified by:
        getContentHandler in interface org.xml.sax.XMLReader
        Returns:
        the content handler
      • getDTDHandler

        public org.xml.sax.DTDHandler getDTDHandler()
        Gets the DTD handler. This class does not support DTD handlers, so this method always returns null.
        Specified by:
        getDTDHandler in interface org.xml.sax.XMLReader
        Returns:
        the DTD handler
      • getEntityResolver

        public org.xml.sax.EntityResolver getEntityResolver()
        Gets the entity resolver. This class does not support an entity resolver, so this method always returns null.
        Specified by:
        getEntityResolver in interface org.xml.sax.XMLReader
        Returns:
        the entity resolver
      • getErrorHandler

        public org.xml.sax.ErrorHandler getErrorHandler()
        Gets the error handler. This class does not support an error handler, so this method always returns null.
        Specified by:
        getErrorHandler in interface org.xml.sax.XMLReader
        Returns:
        the error handler
      • getException

        public org.xml.sax.SAXException getException()
        Gets a reference to an exception that occurred during parsing.
        Returns:
        a SAXExcpetion or null if none occurred
      • getFeature

        public boolean getFeature​(java.lang.String name)
        Dummy implementation of the interface method.
        Specified by:
        getFeature in interface org.xml.sax.XMLReader
        Parameters:
        name - the name of the feature
        Returns:
        always false (no features are supported)
      • getParsedConfiguration

        public abstract Configuration getParsedConfiguration()
        Gets a reference to the configuration that is parsed by this object.
        Returns:
        the parsed configuration
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
        Dummy implementation of the interface method. No properties are supported, so this method always returns null.
        Specified by:
        getProperty in interface org.xml.sax.XMLReader
        Parameters:
        name - the name of the requested property
        Returns:
        the property value
      • getRootName

        public java.lang.String getRootName()
        Gets the name to be used for the root element.
        Returns:
        the name for the root element
      • parse

        public void parse​(org.xml.sax.InputSource input)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
        Parses the actual configuration object. The passed input source will be ignored.
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Parameters:
        input - the input source (ignored)
        Throws:
        java.io.IOException - if no configuration was specified
        org.xml.sax.SAXException - if an error occurs during parsing
      • parse

        public void parse​(java.lang.String systemId)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
        Parses the current configuration object. The passed system ID will be ignored.
        Specified by:
        parse in interface org.xml.sax.XMLReader
        Parameters:
        systemId - the system ID (ignored)
        Throws:
        java.io.IOException - if no configuration was specified
        org.xml.sax.SAXException - if an error occurs during parsing
      • parseConfiguration

        protected void parseConfiguration()
                                   throws java.io.IOException,
                                          org.xml.sax.SAXException
        Parses the configuration object and generates SAX events. This is the main processing method.
        Throws:
        java.io.IOException - if no configuration has been specified
        org.xml.sax.SAXException - if an error occurs during parsing
      • processKeys

        protected abstract void processKeys()
                                     throws java.io.IOException,
                                            org.xml.sax.SAXException
        Processes all keys stored in the actual configuration. This method is called by parseConfiguration() to start the main parsing process. parseConfiguration() calls the content handler's startDocument() and endElement() methods and cares for exception handling. The remaining actions are left to this method that must be implemented in a concrete sub class.
        Throws:
        java.io.IOException - if an IO error occurs
        org.xml.sax.SAXException - if a SAX error occurs
      • setContentHandler

        public void setContentHandler​(org.xml.sax.ContentHandler handler)
        Sets the content handler. The object specified here will receive SAX events during parsing.
        Specified by:
        setContentHandler in interface org.xml.sax.XMLReader
        Parameters:
        handler - the content handler
      • setDTDHandler

        public void setDTDHandler​(org.xml.sax.DTDHandler handler)
        Sets the DTD handler. The passed value is ignored.
        Specified by:
        setDTDHandler in interface org.xml.sax.XMLReader
        Parameters:
        handler - the handler to be set
      • setEntityResolver

        public void setEntityResolver​(org.xml.sax.EntityResolver resolver)
        Sets the entity resolver. The passed value is ignored.
        Specified by:
        setEntityResolver in interface org.xml.sax.XMLReader
        Parameters:
        resolver - the entity resolver
      • setErrorHandler

        public void setErrorHandler​(org.xml.sax.ErrorHandler handler)
        Sets the error handler. The passed value is ignored.
        Specified by:
        setErrorHandler in interface org.xml.sax.XMLReader
        Parameters:
        handler - the error handler
      • setFeature

        public void setFeature​(java.lang.String name,
                               boolean value)
        Dummy implementation of the interface method.
        Specified by:
        setFeature in interface org.xml.sax.XMLReader
        Parameters:
        name - the name of the feature to be set
        value - the value of the feature
      • setProperty

        public void setProperty​(java.lang.String name,
                                java.lang.Object value)
        Dummy implementation of the interface method. No properties are supported, so a call of this method just has no effect.
        Specified by:
        setProperty in interface org.xml.sax.XMLReader
        Parameters:
        name - the property name
        value - the property value
      • setRootName

        public void setRootName​(java.lang.String string)
        Sets the name for the root element.
        Parameters:
        string - the name for the root element.