Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 60775 invoked from network); 3 May 2002 03:19:33 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 May 2002 03:19:33 -0000 Received: (qmail 2457 invoked by uid 97); 3 May 2002 03:19:43 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@nagoya.betaversion.org Received: (qmail 2426 invoked by alias); 3 May 2002 03:19:43 -0000 Delivered-To: jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 2384 invoked by uid 97); 3 May 2002 03:19:42 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 2373 invoked by alias); 3 May 2002 03:19:41 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 3 May 2002 03:19:27 -0000 Message-ID: <20020503031927.43043.qmail@icarus.apache.org> From: mcconnell@apache.org To: jakarta-avalon-excalibur-cvs@apache.org Subject: cvs commit: jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/configuration CascadingConfiguration.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 02/05/02 20:19:27 Modified: all/src/scratchpad/org/apache/avalon/excalibur/configuration CascadingConfiguration.java Log: update to include static utility operation to list configuration Revision Changes Path 1.4 +94 -33 jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/configuration/CascadingConfiguration.java Index: CascadingConfiguration.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/configuration/CascadingConfiguration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CascadingConfiguration.java 21 Apr 2002 21:48:23 -0000 1.3 +++ CascadingConfiguration.java 3 May 2002 03:19:27 -0000 1.4 @@ -1,8 +1,11 @@ -/** - * File: CascadingConfiguration.java - * License: etc/LICENSE.TXT - * Copyright: Copyright (C) The Apache Software Foundation. All rights reserved. - * Copyright: OSM SARL 2001-2002, All Rights Reserved. +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.TXT file. + * + * Original contribution by OSM SARL, http://www.osm.net */ package org.apache.avalon.excalibur.configuration; @@ -12,7 +15,7 @@ import org.apache.avalon.framework.configuration.DefaultConfiguration; /** - * The CascadingConfiguration is a classic Configuration backed by parent + * The CascadingConfiguration is a classic Configuration backed by parent * Configuration. Operations such as getChild return a CascadingConfiguration * encapsulating both a primary and parent configuration. Requests for attribute * values are resolved against the base configuration initially. If the result @@ -36,19 +39,19 @@ /** * Create a CascadingConfiguration with specified parent. The base - * configuration shall override a parent configuration on request for + * configuration shall override a parent configuration on request for * attribute values and configuration body values. Unresolved request * are redirected up the parent chain until a classic configuration is - * reached. Request for child configurations will return a - * new CascadingConfiguration referencing the child of the base and + * reached. Request for child configurations will return a + * new CascadingConfiguration referencing the child of the base and * the child of the primary (i.e. a child configuration chain). * * @param base the base Configuration - * @param parent the parent Configuration + * @param parent the parent Configuration */ - public CascadingConfiguration( final Configuration base, final Configuration parent ) + public CascadingConfiguration( final Configuration base , final Configuration parent ) { - if( base == null ) + if( base == null ) { m_base = new DefaultConfiguration( "-", null ); } @@ -56,7 +59,7 @@ { m_base = base; } - if( parent == null ) + if( parent == null ) { m_parent = new DefaultConfiguration( "-", null ); } @@ -121,8 +124,8 @@ * @param child The name of the child node. * @param createNew If true, a new Configuration * will be created and returned if the specified child does not exist in either - * the base or parent configuratioin. If false, null - * will be returned when the specified child doesn't exist in either the base or + * the base or parent configuratioin. If false, null + * will be returned when the specified child doesn't exist in either the base or * the parent. * @return Configuration */ @@ -136,27 +139,27 @@ /** * Return an Array of Configuration - * elements containing all node children of both base and parent configurations. + * elements containing all node children of both base and parent configurations. * The array order will reflect the order in the source config file, commencing * with the base configuration. * - * @return All child nodes + * @return All child nodes */ public Configuration[] getChildren() { - Configuration[] b = m_base.getChildren(); - Configuration[] p = m_parent.getChildren(); + Configuration[] b = m_base.getChildren( ); + Configuration[] p = m_parent.getChildren( ); Configuration[] result = new Configuration[ b.length + p.length ]; - System.arraycopy( b, 0, result, 0, b.length ); - System.arraycopy( p, 0, result, b.length, p.length ); + System.arraycopy(b, 0, result, 0, b.length ); + System.arraycopy(p, 0, result, b.length, p.length ); return result; } /** * Return an Array of Configuration - * elements containing all node children with the specified name from + * elements containing all node children with the specified name from * both base and parent configurations. The array - * order will reflect the order in the source config file commencing + * order will reflect the order in the source config file commencing * with the base configuration. * * @param name The name of the children to get. @@ -167,8 +170,8 @@ Configuration[] b = m_base.getChildren( name ); Configuration[] p = m_parent.getChildren( name ); Configuration[] result = new Configuration[ b.length + p.length ]; - System.arraycopy( b, 0, result, 0, b.length ); - System.arraycopy( p, 0, result, b.length, p.length ); + System.arraycopy(b, 0, result, 0, b.length ); + System.arraycopy(p, 0, result, b.length, p.length ); return result; } @@ -187,20 +190,20 @@ java.util.Vector vector = new java.util.Vector(); String[] names = m_base.getAttributeNames(); String[] names2 = m_parent.getAttributeNames(); - for( int i = 0; i < names.length; i++ ) + for( int i=0; ilong. * - * @param name The name of the parameter you ask the value of. + * @param paramName The name of the parameter you ask the value of. * @return long value of attribute * @exception ConfigurationException If no parameter with that name exists. * or if conversion to long fails. @@ -260,6 +263,7 @@ } } + /** * Return the float value of the specified parameter contained * in this node. @@ -280,6 +284,7 @@ } } + /** * Return the boolean value of the specified parameter contained * in this node.
@@ -318,6 +323,7 @@ } } + /** * Return the int value of the node. * @@ -410,6 +416,7 @@ } } + /** * Returns the value of the configuration element as an int. * If the configuration value is not set, the default value will be @@ -431,6 +438,7 @@ } } + /** * Returns the value of the configuration element as a long. * If the configuration value is not set, the default value will be @@ -452,6 +460,7 @@ } } + /** * Returns the value of the configuration element as a float. * If the configuration value is not set, the default value will be @@ -473,6 +482,7 @@ } } + /** * Returns the value of the configuration element as a boolean. * If the configuration value is not set, the default value will be @@ -494,6 +504,7 @@ } } + /** * Returns the value of the attribute specified by its name as a * String, or the default value if no attribute by @@ -608,4 +619,54 @@ return m_parent.getAttributeAsBoolean( name, defaultValue ); } } -} \ No newline at end of file + + //======================================================================= + // utilities + //======================================================================= + + public static String list( Configuration config ) + { + final StringBuffer buffer = new StringBuffer(); + list( buffer, " ", config ); + buffer.append("\n"); + return buffer.toString(); + } + + private static void list( StringBuffer buffer, String lead, Configuration config ) + { + + buffer.append( "\n" + lead + "<" + config.getName() ); + String[] names = config.getAttributeNames(); + if( names.length > 0 ) + { + for( int i=0; i 0 ) + { + buffer.append(">"); + for( int j=0; j"); + } + else + { + if( config.getValue( null ) != null ) + { + buffer.append( ">..."); + } + else + { + buffer.append( "/>"); + } + } + } +} + + + -- To unsubscribe, e-mail: For additional commands, e-mail: