Class ConfigurationXMLReader

java.lang.Object
org.apache.commons.configuration2.ConfigurationXMLReader
All Implemented Interfaces:
XMLReader
Direct Known Subclasses:
BaseConfigurationXMLReader, HierarchicalConfigurationXMLReader

public abstract class ConfigurationXMLReader extends Object implements 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 Details Link icon

  • Constructor Details Link icon

    • ConfigurationXMLReader Link icon

      Creates a new instance of ConfigurationXMLReader.
  • Method Details Link icon

    • fireCharacters Link icon

      protected void fireCharacters(String text)
      Fires a SAX characters event.
      Parameters:
      text - the text
    • fireElementEnd Link icon

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

      protected void fireElementStart(String name, 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 Link icon

      Gets the actually set content handler.
      Specified by:
      getContentHandler in interface XMLReader
      Returns:
      the content handler
    • getDTDHandler Link icon

      Gets the DTD handler. This class does not support DTD handlers, so this method always returns null.
      Specified by:
      getDTDHandler in interface XMLReader
      Returns:
      the DTD handler
    • getEntityResolver Link icon

      Gets the entity resolver. This class does not support an entity resolver, so this method always returns null.
      Specified by:
      getEntityResolver in interface XMLReader
      Returns:
      the entity resolver
    • getErrorHandler Link icon

      Gets the error handler. This class does not support an error handler, so this method always returns null.
      Specified by:
      getErrorHandler in interface XMLReader
      Returns:
      the error handler
    • getException Link icon

      Gets a reference to an exception that occurred during parsing.
      Returns:
      a SAXExcpetion or null if none occurred
    • getFeature Link icon

      public boolean getFeature(String name)
      Dummy implementation of the interface method.
      Specified by:
      getFeature in interface XMLReader
      Parameters:
      name - the name of the feature
      Returns:
      always false (no features are supported)
    • getParsedConfiguration Link icon

      Gets a reference to the configuration that is parsed by this object.
      Returns:
      the parsed configuration
    • getProperty Link icon

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

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

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

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

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

      protected abstract void processKeys() throws IOException, 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:
      IOException - if an IO error occurs
      SAXException - if a SAX error occurs
    • setContentHandler Link icon

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

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

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

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

      public void setFeature(String name, boolean value)
      Dummy implementation of the interface method.
      Specified by:
      setFeature in interface XMLReader
      Parameters:
      name - the name of the feature to be set
      value - the value of the feature
    • setProperty Link icon

      public void setProperty(String name, 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 XMLReader
      Parameters:
      name - the property name
      value - the property value
    • setRootName Link icon

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