Class SAXConfigurationHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.avalon.framework.configuration.SAXConfigurationHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Direct Known Subclasses:
NamespacedSAXConfigurationHandler
public class SAXConfigurationHandler extends org.xml.sax.helpers.DefaultHandler implements org.xml.sax.ErrorHandlerA SAXConfigurationHandler helps build Configurations out of sax events.- Version:
- $Id: SAXConfigurationHandler.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 intEXPECTED_DEPTHLikely number of nested configuration items.private org.apache.avalon.framework.configuration.Configurationm_configurationprivate java.util.ArrayListm_elementsprivate org.xml.sax.Locatorm_locatorprivate java.util.BitSetm_preserveSpaceContains true at index n if space in the configuration with depth n is to be preserved.private java.util.ArrayListm_values
-
Constructor Summary
Constructors Constructor Description SAXConfigurationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int end)Handling hook for character data.voidclear()Clears all data from this configuration handler.protected DefaultConfigurationcreateConfiguration(java.lang.String localName, java.lang.String location)Create a newDefaultConfigurationwith the specified local name and location.voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName)Handling hook for finishing parsing of an element.voiderror(org.xml.sax.SAXParseException exception)This just throws an exception on a parse error.voidfatalError(org.xml.sax.SAXParseException exception)This just throws an exception on a parse error.org.apache.avalon.framework.configuration.ConfigurationgetConfiguration()Get the configuration object that was built.protected java.lang.StringgetLocationString()Returns a string showing the current system ID, line number and column number.voidsetDocumentLocator(org.xml.sax.Locator locator)Set the documentLocatorto use.voidstartElement(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.voidwarning(org.xml.sax.SAXParseException exception)This just throws an exception on a parse error.
-
-
-
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_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
-
-
Method Detail
-
getConfiguration
public org.apache.avalon.framework.configuration.Configuration getConfiguration()
Get the configuration object that was built.- Returns:
- a
Configurationobject
-
clear
public void clear()
Clears all data from this configuration handler.
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
Set the documentLocatorto use.- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler- Parameters:
locator- aLocatorvalue
-
characters
public void characters(char[] ch, int start, int end) throws org.xml.sax.SAXExceptionHandling hook for character data.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ch- achar[]of datastart- offset in the character array from which to start readingend- 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.SAXExceptionHandling hook for finishing parsing of an element.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- aStringvaluelocalName- aStringvaluerawName- aStringvalue- Throws:
org.xml.sax.SAXException- if an error occurs
-
createConfiguration
protected DefaultConfiguration createConfiguration(java.lang.String localName, java.lang.String location)
Create a newDefaultConfigurationwith the specified local name and location.- Parameters:
localName- aStringvaluelocation- aStringvalue- Returns:
- a
DefaultConfigurationvalue
-
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.SAXExceptionHandling hook for starting parsing of an element.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- aStringvaluelocalName- aStringvaluerawName- aStringvalueattributes- anAttributesvalue- Throws:
org.xml.sax.SAXException- if an error occurs
-
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXExceptionThis just throws an exception on a parse error.- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler- Overrides:
errorin classorg.xml.sax.helpers.DefaultHandler- 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.SAXExceptionThis just throws an exception on a parse error.- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler- Overrides:
warningin classorg.xml.sax.helpers.DefaultHandler- 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.SAXExceptionThis just throws an exception on a parse error.- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler- Overrides:
fatalErrorin classorg.xml.sax.helpers.DefaultHandler- 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.- Returns:
- a
Stringvalue
-
-