Class ConfigurationXMLReader
java.lang.Object
org.apache.commons.configuration2.ConfigurationXMLReader
- All Implemented Interfaces:
XMLReader
- Direct Known Subclasses:
BaseConfigurationXMLReader
,HierarchicalConfigurationXMLReader
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
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new instance ofConfigurationXMLReader
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
fireCharacters
(String text) Fires a SAX characters event.protected void
fireElementEnd
(String name) Fires a SAX element end event.protected void
fireElementStart
(String name, Attributes attribs) Fires a SAX element start event.Gets the actually set content handler.Gets the DTD handler.Gets the entity resolver.Gets the error handler.Gets a reference to an exception that occurred during parsing.boolean
getFeature
(String name) Dummy implementation of the interface method.abstract Configuration
Gets a reference to the configuration that is parsed by this object.getProperty
(String name) Dummy implementation of the interface method.Gets the name to be used for the root element.void
Parses the current configuration object.void
parse
(InputSource input) Parses the actual configuration object.protected void
Parses the configuration object and generates SAX events.protected abstract void
Processes all keys stored in the actual configuration.void
setContentHandler
(ContentHandler handler) Sets the content handler.void
setDTDHandler
(DTDHandler handler) Sets the DTD handler.void
setEntityResolver
(EntityResolver resolver) Sets the entity resolver.void
setErrorHandler
(ErrorHandler handler) Sets the error handler.void
setFeature
(String name, boolean value) Dummy implementation of the interface method.void
setProperty
(String name, Object value) Dummy implementation of the interface method.void
setRootName
(String string) Sets the name for the root element.
-
Field Details
-
NS_URI
Constant for the namespace URI.- See Also:
-
-
Constructor Details
-
ConfigurationXMLReader
protected ConfigurationXMLReader()Creates a new instance ofConfigurationXMLReader
.
-
-
Method Details
-
fireCharacters
Fires a SAX characters event.- Parameters:
text
- the text
-
fireElementEnd
Fires a SAX element end event.- Parameters:
name
- the name of the affected element
-
fireElementStart
Fires a SAX element start event.- Parameters:
name
- the name of the actual elementattribs
- the attributes of this element (can be null)
-
getContentHandler
Gets the actually set content handler.- Specified by:
getContentHandler
in interfaceXMLReader
- Returns:
- the content handler
-
getDTDHandler
Gets the DTD handler. This class does not support DTD handlers, so this method always returns null.- Specified by:
getDTDHandler
in interfaceXMLReader
- Returns:
- the DTD handler
-
getEntityResolver
Gets the entity resolver. This class does not support an entity resolver, so this method always returns null.- Specified by:
getEntityResolver
in interfaceXMLReader
- Returns:
- the entity resolver
-
getErrorHandler
Gets the error handler. This class does not support an error handler, so this method always returns null.- Specified by:
getErrorHandler
in interfaceXMLReader
- Returns:
- the error handler
-
getException
Gets a reference to an exception that occurred during parsing.- Returns:
- a SAXExcpetion or null if none occurred
-
getFeature
Dummy implementation of the interface method.- Specified by:
getFeature
in interfaceXMLReader
- Parameters:
name
- the name of the feature- Returns:
- always false (no features are supported)
-
getParsedConfiguration
Gets a reference to the configuration that is parsed by this object.- Returns:
- the parsed configuration
-
getProperty
Dummy implementation of the interface method. No properties are supported, so this method always returns null.- Specified by:
getProperty
in interfaceXMLReader
- Parameters:
name
- the name of the requested property- Returns:
- the property value
-
getRootName
Gets the name to be used for the root element.- Returns:
- the name for the root element
-
parse
Parses the actual configuration object. The passed input source will be ignored.- Specified by:
parse
in interfaceXMLReader
- Parameters:
input
- the input source (ignored)- Throws:
IOException
- if no configuration was specifiedSAXException
- if an error occurs during parsing
-
parse
Parses the current configuration object. The passed system ID will be ignored.- Specified by:
parse
in interfaceXMLReader
- Parameters:
systemId
- the system ID (ignored)- Throws:
IOException
- if no configuration was specifiedSAXException
- if an error occurs during parsing
-
parseConfiguration
Parses the configuration object and generates SAX events. This is the main processing method.- Throws:
IOException
- if no configuration has been specifiedSAXException
- if an error occurs during parsing
-
processKeys
Processes all keys stored in the actual configuration. This method is called byparseConfiguration()
to start the main parsing process.parseConfiguration()
calls the content handler'sstartDocument()
andendElement()
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 occursSAXException
- if a SAX error occurs
-
setContentHandler
Sets the content handler. The object specified here will receive SAX events during parsing.- Specified by:
setContentHandler
in interfaceXMLReader
- Parameters:
handler
- the content handler
-
setDTDHandler
Sets the DTD handler. The passed value is ignored.- Specified by:
setDTDHandler
in interfaceXMLReader
- Parameters:
handler
- the handler to be set
-
setEntityResolver
Sets the entity resolver. The passed value is ignored.- Specified by:
setEntityResolver
in interfaceXMLReader
- Parameters:
resolver
- the entity resolver
-
setErrorHandler
Sets the error handler. The passed value is ignored.- Specified by:
setErrorHandler
in interfaceXMLReader
- Parameters:
handler
- the error handler
-
setFeature
Dummy implementation of the interface method.- Specified by:
setFeature
in interfaceXMLReader
- Parameters:
name
- the name of the feature to be setvalue
- the value of the feature
-
setProperty
Dummy implementation of the interface method. No properties are supported, so a call of this method just has no effect.- Specified by:
setProperty
in interfaceXMLReader
- Parameters:
name
- the property namevalue
- the property value
-
setRootName
Sets the name for the root element.- Parameters:
string
- the name for the root element.
-