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

public Class ConfigurationUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Iterator, javax.xml.parsers.DocumentBuilder, .DocumentBuilderFactory, .ParserConfigurationException, org.w3c.dom.Document, .Element, .Text, .NamedNodeMap, .Node, .NodeList, .CharacterData

This class has a bunch of utility methods to work with configuration objects.
Author
Avalon Development Team
Since
4.1.4
Version
$Id: ConfigurationUtil.java 506231 2007-02-12 02:36:54Z crossley $

Constructor Summary

AccessConstructor and Description
private
ConfigurationUtil()

Private constructor to block instantiation.

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true if the attributes of both configurations are equal.
areAttributesEqual
(final Configuration
configuration1
c1
,
final Configuration
configuration2
c2
)

Return true if the attributes of both configurations are equal.

private static boolean

Returns:

true if the children of both configurations are equal.
areChildrenEqual
(final Configuration
configuration1
c1
,
final Configuration
configuration2
c2
)

Return true if the children of both configurations are equal.

private static boolean

Returns:

true if the values of two configurations are equal.
areValuesEqual
(final Configuration
configuration1
c1
,
final Configuration
configuration2
c2
)

Return true if the values of two configurations are equal.

private static Element

Returns:

the DOM Element
createElement
(final Document
the DOM document
document
,
final Configuration
the configuration to convert
configuration
)

Create an DOM Element from a Configuration object.

public static boolean

Returns:

true if the configurations can be considered equals
equals
(final Configuration
Configuration to test
c1
,
final Configuration
Configuration to test
c2
)

Test to see if two Configuration's can be considered the same.

private static boolean

Returns:

true if the found.
findMatchingChild
(final Configuration
the configuration
c
,
final ArrayList<E>
the list of items to match against
matchAgainst
)

Return true if find a matching child and remove child from list.

public static Configuration

Returns:

the configuration object
toConfiguration
(final Element
the DOM Element
element
)

Convert a DOM Element tree into a configuration tree.

public static Element

Returns:

the DOM Element
toElement
(final Configuration
the configuration object
configuration
)

Convert a configuration tree into a DOM Element tree.

public static String

Returns:

a non-null String representing the Configuration, or an error message.
toString
(final Configuration
Configuration instance to serialize
configuration
)

Serialize the configuration object to a String.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ConfigurationUtilback to summary
private ConfigurationUtil()

Private constructor to block instantiation.

Method Detail

areAttributesEqualback to summary
private static boolean areAttributesEqual(final Configuration c1, final Configuration c2)

Return true if the attributes of both configurations are equal.

Parameters
c1:Configuration

configuration1

c2:Configuration

configuration2

Returns:boolean

true if the attributes of both configurations are equal.

areChildrenEqualback to summary
private static boolean areChildrenEqual(final Configuration c1, final Configuration c2)

Return true if the children of both configurations are equal.

Parameters
c1:Configuration

configuration1

c2:Configuration

configuration2

Returns:boolean

true if the children of both configurations are equal.

areValuesEqualback to summary
private static boolean areValuesEqual(final Configuration c1, final Configuration c2)

Return true if the values of two configurations are equal.

Parameters
c1:Configuration

configuration1

c2:Configuration

configuration2

Returns:boolean

true if the values of two configurations are equal.

createElementback to summary
private static Element createElement(final Document document, final Configuration configuration)

Create an DOM Element from a Configuration object.

Parameters
document:Document

the DOM document

configuration:Configuration

the configuration to convert

Returns:Element

the DOM Element

equalsback to summary
public static boolean equals(final Configuration c1, final Configuration c2)

Test to see if two Configuration's can be considered the same. Name, value, attributes and children are test. The order of children is not taken into consideration for equality.

Parameters
c1:Configuration

Configuration to test

c2:Configuration

Configuration to test

Returns:boolean

true if the configurations can be considered equals

findMatchingChildback to summary
private static boolean findMatchingChild(final Configuration c, final ArrayList<E> matchAgainst)

Return true if find a matching child and remove child from list.

Parameters
c:Configuration

the configuration

matchAgainst:ArrayList<E>

the list of items to match against

Returns:boolean

true if the found.

toConfigurationback to summary
public static Configuration toConfiguration(final Element element)

Convert a DOM Element tree into a configuration tree.

Parameters
element:Element

the DOM Element

Returns:Configuration

the configuration object

toElementback to summary
public static Element toElement(final Configuration configuration)

Convert a configuration tree into a DOM Element tree.

Parameters
configuration:Configuration

the configuration object

Returns:Element

the DOM Element

toStringback to summary
public static String toString(final Configuration configuration)

Serialize the configuration object to a String. If an exception occurs, the exception message will be returned instead. This method is intended to aid debugging; DefaultConfigurationSerializer#serialize(Configuration) lets the caller handle exceptions.

Parameters
configuration:Configuration

Configuration instance to serialize

Returns:String

a non-null String representing the Configuration, or an error message.

Since
12 March, 2003