org.apache.avalon.framework.configuration

Class ConfigurationUtil

public class ConfigurationUtil extends Object

This class has a bunch of utility methods to work with configuration objects.

Since: 4.1.4

Version: $Id: ConfigurationUtil.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $

Author: Avalon Development Team

Constructor Summary
ConfigurationUtil()
Private constructor to block instantiation.
Method Summary
static booleanareAttributesEqual(Configuration c1, Configuration c2)
Return true if the attributes of both configurations are equal.
static booleanareChildrenEqual(Configuration c1, Configuration c2)
Return true if the children of both configurations are equal.
static booleanareValuesEqual(Configuration c1, Configuration c2)
Return true if the values of two configurations are equal.
static ElementcreateElement(Document document, Configuration configuration)
Create an DOM Element from a Configuration object.
static booleanequals(Configuration c1, Configuration c2)
Test to see if two Configuration's can be considered the same.
static booleanfindMatchingChild(Configuration c, ArrayList matchAgainst)
Return true if find a matching child and remove child from list.
static ConfigurationtoConfiguration(Element element)
Convert a DOM Element tree into a configuration tree.
static ElementtoElement(Configuration configuration)
Convert a configuration tree into a DOM Element tree.
static StringtoString(Configuration configuration)
Serialize the configuration object to a String.

Constructor Detail

ConfigurationUtil

private ConfigurationUtil()
Private constructor to block instantiation.

Method Detail

areAttributesEqual

private static boolean areAttributesEqual(Configuration c1, Configuration c2)
Return true if the attributes of both configurations are equal.

Parameters: c1 configuration1 c2 configuration2

Returns: true if the attributes of both configurations are equal.

areChildrenEqual

private static boolean areChildrenEqual(Configuration c1, Configuration c2)
Return true if the children of both configurations are equal.

Parameters: c1 configuration1 c2 configuration2

Returns: true if the children of both configurations are equal.

areValuesEqual

private static boolean areValuesEqual(Configuration c1, Configuration c2)
Return true if the values of two configurations are equal.

Parameters: c1 configuration1 c2 configuration2

Returns: true if the values of two configurations are equal.

createElement

private static Element createElement(Document document, Configuration configuration)
Create an DOM Element from a Configuration object.

Parameters: document the DOM document configuration the configuration to convert

Returns: the DOM Element

equals

public static boolean equals(Configuration c1, 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 to test c2 Configuration to test

Returns: true if the configurations can be considered equals

findMatchingChild

private static boolean findMatchingChild(Configuration c, ArrayList matchAgainst)
Return true if find a matching child and remove child from list.

Parameters: c the configuration matchAgainst the list of items to match against

Returns: true if the found.

toConfiguration

public static Configuration toConfiguration(Element element)
Convert a DOM Element tree into a configuration tree.

Parameters: element the DOM Element

Returns: the configuration object

toElement

public static Element toElement(Configuration configuration)
Convert a configuration tree into a DOM Element tree.

Parameters: configuration the configuration object

Returns: the DOM Element

toString

public static String toString(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; serialize lets the caller handle exceptions.

Parameters: configuration Configuration instance to serialize

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

Since: 12 March, 2003