avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject cvs commit: avalon/src/java/org/apache/avalon/framework/configuration ConfigurationUtil.java
Date Wed, 12 Mar 2003 12:06:55 GMT
jefft       2003/03/12 04:06:55

  Modified:    src/java/org/apache/avalon/framework/configuration
                        ConfigurationUtil.java
  Log:
  Added a static toString(Configuration) method.  Useful in println() statements
  when debugging
  
  Revision  Changes    Path
  1.12      +28 -1     avalon/src/java/org/apache/avalon/framework/configuration/ConfigurationUtil.java
  
  Index: ConfigurationUtil.java
  ===================================================================
  RCS file: /home/cvs/avalon/src/java/org/apache/avalon/framework/configuration/ConfigurationUtil.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ConfigurationUtil.java	11 Feb 2003 15:58:38 -0000	1.11
  +++ ConfigurationUtil.java	12 Mar 2003 12:06:54 -0000	1.12
  @@ -64,6 +64,7 @@
   import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.Iterator;
  +import org.xml.sax.SAXException;
   
   /**
    * This class has a bunch of utility methods to work
  @@ -71,6 +72,7 @@
    *
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version CVS $Revision$ $Date$
  + * @since 4.1.4
    */
   public class ConfigurationUtil
   {
  @@ -100,6 +102,31 @@
           catch( final ParserConfigurationException pce )
           {
               throw new IllegalStateException( pce.toString() );
  +        }
  +    }
  +
  +    /**
  +     * 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; {@link
  +     * DefaultConfigurationSerializer#serialize(Configuration)} lets the caller
  +     * handle exceptions.
  +     *
  +     * @param configuration Configuration instance to serialize
  +     * @return a non-null String representing the <code>Configuration</code>,
  +     * or an error message.
  +     * @since 12 March, 2003
  +     */
  +    public static String toString( final Configuration configuration )
  +    {
  +        DefaultConfigurationSerializer ser = new DefaultConfigurationSerializer();
  +        try
  +        {
  +            return ser.serialize( configuration );
  +        }
  +        catch (Exception e ) 
  +        {
  +            return e.getMessage();
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message