org.apache.avalon.framework.configuration

Class SAXConfigurationHandler

public class SAXConfigurationHandler extends DefaultHandler implements ErrorHandler

A 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
static intEXPECTED_DEPTH
Likely number of nested configuration items.
Configurationm_configuration
ArrayListm_elements
Locatorm_locator
BitSetm_preserveSpace
Contains true at index n if space in the configuration with depth n is to be preserved.
ArrayListm_values
Method Summary
voidcharacters(char[] ch, int start, int end)
Handling hook for character data.
voidclear()
Clears all data from this configuration handler.
protected DefaultConfigurationcreateConfiguration(String localName, String location)
Create a new DefaultConfiguration with the specified local name and location.
voidendElement(String namespaceURI, String localName, String rawName)
Handling hook for finishing parsing of an element.
voiderror(SAXParseException exception)
This just throws an exception on a parse error.
voidfatalError(SAXParseException exception)
This just throws an exception on a parse error.
ConfigurationgetConfiguration()
Get the configuration object that was built.
protected StringgetLocationString()
Returns a string showing the current system ID, line number and column number.
voidsetDocumentLocator(Locator locator)
Set the document Locator to use.
voidstartElement(String namespaceURI, String localName, String rawName, Attributes attributes)
Handling hook for starting parsing of an element.
voidwarning(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.

m_configuration

private Configuration m_configuration

m_elements

private final ArrayList m_elements

m_locator

private Locator m_locator

m_preserveSpace

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

m_values

private final ArrayList m_values

Method Detail

characters

public void characters(char[] ch, int start, int end)
Handling hook for character data.

Parameters: ch a char[] of data start offset in the character array from which to start reading end length of character data

Throws: SAXException if an error occurs

clear

public void clear()
Clears all data from this configuration handler.

createConfiguration

protected DefaultConfiguration createConfiguration(String localName, String location)
Create a new DefaultConfiguration with the specified local name and location.

Parameters: localName a String value location a String value

Returns: a DefaultConfiguration value

endElement

public void endElement(String namespaceURI, String localName, String rawName)
Handling hook for finishing parsing of an element.

Parameters: namespaceURI a String value localName a String value rawName a String value

Throws: SAXException if an error occurs

error

public void error(SAXParseException exception)
This just throws an exception on a parse error.

Parameters: exception the parse error

Throws: SAXException if an error occurs

fatalError

public void fatalError(SAXParseException exception)
This just throws an exception on a parse error.

Parameters: exception the parse error

Throws: SAXException if an error occurs

getConfiguration

public Configuration getConfiguration()
Get the configuration object that was built.

Returns: a Configuration object

getLocationString

protected String getLocationString()
Returns a string showing the current system ID, line number and column number.

Returns: a String value

setDocumentLocator

public void setDocumentLocator(Locator locator)
Set the document Locator to use.

Parameters: locator a Locator value

startElement

public void startElement(String namespaceURI, String localName, String rawName, Attributes attributes)
Handling hook for starting parsing of an element.

Parameters: namespaceURI a String value localName a String value rawName a String value attributes an Attributes value

Throws: SAXException if an error occurs

warning

public void warning(SAXParseException exception)
This just throws an exception on a parse error.

Parameters: exception the parse error

Throws: SAXException if an error occurs