Top Description Fields Constructors Methods
org.apache.avalon.framework.configuration

public Class SAXConfigurationHandler

extends DefaultHandler
implements ErrorHandler
Class Inheritance
All Implemented Interfaces
org.xml.sax.ErrorHandler
Known Direct Subclasses
org.apache.avalon.framework.configuration.NamespacedSAXConfigurationHandler
Imports
java.util.ArrayList, .BitSet, org.xml.sax.Attributes, .ErrorHandler, .Locator, .SAXException, .SAXParseException, org.xml.sax.helpers.DefaultHandler

A SAXConfigurationHandler helps build Configurations out of sax events.
Author
Avalon Development Team
Version
$Id: SAXConfigurationHandler.java 506231 2007-02-12 02:36:54Z crossley $

Field Summary

Modifier and TypeField and Description
private static final int
EXPECTED_DEPTH

Likely number of nested configuration items.

private Configuration
private final ArrayList<E>
private Locator
private final BitSet
m_preserveSpace

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

private final ArrayList<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
characters(final char[]
a char[] of data
ch
,
int
offset in the character array from which to start reading
start
,
int
length of character data
end
)

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Handling hook for character data.
public void
clear()

Clears all data from this configuration handler.

protected DefaultConfiguration

Returns:

a DefaultConfiguration value
createConfiguration
(final String
a String value
localName
,
final String
a String value
location
)

Create a new DefaultConfiguration with the specified local name and location.

public void
endElement(final String
a String value
namespaceURI
,
final String
a String value
localName
,
final String
a String value
rawName
)

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Handling hook for finishing parsing of an element.
public void
error(final SAXParseException
the parse error
exception
)

Overrides org.xml.sax.helpers.DefaultHandler.error.

Implements org.xml.sax.ErrorHandler.error.

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

Overrides org.xml.sax.helpers.DefaultHandler.fatalError.

Implements org.xml.sax.ErrorHandler.fatalError.

This just throws an exception on a parse error.
public Configuration

Returns:

a Configuration object
getConfiguration
()

Get the configuration object that was built.

protected String

Returns:

a String value
getLocationString
()

Returns a string showing the current system ID, line number and column number.

public void
setDocumentLocator(final Locator
a Locator value
locator
)

Overrides org.xml.sax.helpers.DefaultHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Set the document Locator to use.
public void
startElement(final String
a String value
namespaceURI
,
final String
a String value
localName
,
final String
a String value
rawName
,
final Attributes
an Attributes value
attributes
)

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Handling hook for starting parsing of an element.
public void
warning(final SAXParseException
the parse error
exception
)

Overrides org.xml.sax.helpers.DefaultHandler.warning.

Implements org.xml.sax.ErrorHandler.warning.

This just throws an exception on a parse error.
Inherited from org.xml.sax.helpers.DefaultHandler:
endDocumentendPrefixMappingignorableWhitespacenotationDeclprocessingInstructionresolveEntityskippedEntitystartDocumentstartPrefixMappingunparsedEntityDecl

Field Detail

EXPECTED_DEPTHback to summary
private static final int EXPECTED_DEPTH

Likely number of nested configuration items. If more is encountered the lists will grow automatically.

m_configurationback to summary
private Configuration m_configuration
m_elementsback to summary
private final ArrayList<E> m_elements
m_locatorback to summary
private Locator m_locator
m_preserveSpaceback to summary
private final BitSet m_preserveSpace

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

m_valuesback to summary
private final ArrayList<E> m_values

Constructor Detail

SAXConfigurationHandlerback to summary
public SAXConfigurationHandler()

Method Detail

charactersback to summary
public void characters(final char[] ch, int start, int end) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.characters.

Implements org.xml.sax.ContentHandler.characters.

Handling hook for character data.

Parameters
ch:char[]

a char[] of data

start:int

offset in the character array from which to start reading

end:int

length of character data

Exceptions
SAXException:
if an error occurs
clearback to summary
public void clear()

Clears all data from this configuration handler.

createConfigurationback to summary
protected DefaultConfiguration createConfiguration(final String localName, final String location)

Create a new DefaultConfiguration with the specified local name and location.

Parameters
localName:String

a String value

location:String

a String value

Returns:DefaultConfiguration

a DefaultConfiguration value

endElementback to summary
public void endElement(final String namespaceURI, final String localName, final String rawName) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.endElement.

Implements org.xml.sax.ContentHandler.endElement.

Handling hook for finishing parsing of an element.

Parameters
namespaceURI:String

a String value

localName:String

a String value

rawName:String

a String value

Exceptions
SAXException:
if an error occurs
errorback to summary
public void error(final SAXParseException exception) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.error.

Implements org.xml.sax.ErrorHandler.error.

This just throws an exception on a parse error.

Parameters
exception:SAXParseException

the parse error

Exceptions
SAXException:
if an error occurs
fatalErrorback to summary
public void fatalError(final SAXParseException exception) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.fatalError.

Implements org.xml.sax.ErrorHandler.fatalError.

This just throws an exception on a parse error.

Parameters
exception:SAXParseException

the parse error

Exceptions
SAXException:
if an error occurs
getConfigurationback to summary
public Configuration getConfiguration()

Get the configuration object that was built.

Returns:Configuration

a Configuration object

getLocationStringback to summary
protected String getLocationString()

Returns a string showing the current system ID, line number and column number.

Returns:String

a String value

setDocumentLocatorback to summary
public void setDocumentLocator(final Locator locator)

Overrides org.xml.sax.helpers.DefaultHandler.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Set the document Locator to use.

Parameters
locator:Locator

a Locator value

startElementback to summary
public void startElement(final String namespaceURI, final String localName, final String rawName, final Attributes attributes) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Handling hook for starting parsing of an element.

Parameters
namespaceURI:String

a String value

localName:String

a String value

rawName:String

a String value

attributes:Attributes

an Attributes value

Exceptions
SAXException:
if an error occurs
warningback to summary
public void warning(final SAXParseException exception) throws SAXException

Overrides org.xml.sax.helpers.DefaultHandler.warning.

Implements org.xml.sax.ErrorHandler.warning.

This just throws an exception on a parse error.

Parameters
exception:SAXParseException

the parse error

Exceptions
SAXException:
if an error occurs