You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/11/11 02:51:11 UTC
cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/configuration DefaultConfiguration.java
donaldp 2002/11/10 17:51:11
Modified: src/java/org/apache/avalon/framework/configuration
DefaultConfiguration.java
Log:
Add in some helper methods to make it easier to manipulate the modifiable trees
Revision Changes Path
1.24 +52 -0 jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java
Index: DefaultConfiguration.java
===================================================================
RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DefaultConfiguration.java 7 Nov 2002 08:35:27 -0000 1.23
+++ DefaultConfiguration.java 11 Nov 2002 01:51:11 -0000 1.24
@@ -434,6 +434,58 @@
}
/**
+ * Add all the attributes, children and value
+ * from specified configuration element to current
+ * configuration element.
+ *
+ * @param other the {@link Configuration} element
+ */
+ public void addAll( final Configuration other )
+ {
+ checkWriteable();
+
+ setValue( other.getValue( null ) );
+ addAllAttributes( other );
+ addAllChildren( other );
+ }
+
+ /**
+ * Add all attributes from specified configuration
+ * element to current configuration element.
+ *
+ * @param other the {@link Configuration} element
+ */
+ public void addAllAttributes( final Configuration other )
+ {
+ checkWriteable();
+
+ final String[] attributes = other.getAttributeNames();
+ for( int i = 0; i < attributes.length; i++ )
+ {
+ final String name = attributes[ i ];
+ final String value = other.getAttribute( name );
+ setAttribute( name, value );
+ }
+ }
+
+ /**
+ * Add all child <code>Configuration</code> objects from specified
+ * configuration element to current configuration element.
+ *
+ * @param other the other {@link Configuration} value
+ */
+ public void addAllChildren( final Configuration other )
+ {
+ checkWriteable();
+
+ final Configuration[] children = other.getChildren();
+ for( int i = 0; i < children.length; i++ )
+ {
+ addChild( children[ i ] );
+ }
+ }
+
+ /**
* Remove a child <code>Configuration</code> to this configuration element.
* @param configuration a <code>Configuration</code> value
*/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>