ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/converter Resources.properties
Date Sat, 23 Mar 2002 05:34:18 GMT
donaldp     02/03/22 21:34:17

  Modified:    proposal/myrmidon/src/java/org/apache/aut/converter
                        AbstractMasterConverter.java Resources.properties
               proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test
                        AbstractPropertyResolverTestCase.java
               proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test
                        DefaultConfigurerTestCase.java
  Added:       proposal/myrmidon/src/java/org/apache/aut/converter/lib
                        ObjectToStringConverter.java
                        StringToBooleanConverter.java
                        StringToByteConverter.java
                        StringToClassConverter.java
                        StringToDoubleConverter.java
                        StringToFileConverter.java
                        StringToFloatConverter.java
                        StringToIntegerConverter.java
                        StringToLongConverter.java
                        StringToShortConverter.java
                        StringToURLConverter.java
  Removed:     proposal/myrmidon/src/java/org/apache/antlib/core
                        ObjectToStringConverter.java
                        StringToBooleanConverter.java
                        StringToByteConverter.java
                        StringToClassConverter.java
                        StringToDoubleConverter.java
                        StringToFileConverter.java
                        StringToFloatConverter.java
                        StringToIntegerConverter.java
                        StringToLongConverter.java
                        StringToShortConverter.java
                        StringToURLConverter.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/converter
                        Resources.properties
  Log:
  Move the primitive, reusable and non-myrmidon specific converters into the aut hierarchy
  
  Revision  Changes    Path
  1.3       +2 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/AbstractMasterConverter.java
  
  Index: AbstractMasterConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/AbstractMasterConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractMasterConverter.java	23 Mar 2002 04:57:09 -0000	1.2
  +++ AbstractMasterConverter.java	23 Mar 2002 05:34:17 -0000	1.3
  @@ -33,9 +33,9 @@
    * when it is first used.</p>
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2002/03/23 04:57:09 $
  + * @version $Revision: 1.3 $ $Date: 2002/03/23 05:34:17 $
    */
  -public class AbstractMasterConverter
  +public abstract class AbstractMasterConverter
       implements Converter
   {
       private final static Resources REZ =
  
  
  
  1.4       +6 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/Resources.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Resources.properties	21 Feb 2002 10:16:42 -0000	1.3
  +++ Resources.properties	23 Mar 2002 05:34:17 -0000	1.4
  @@ -1,2 +1,8 @@
   bad-destination.error=Destination type ({0}) is not equal to {1}.
   bad-instance.error=Object {0} is not an instance of {1}.
  +
  +#AbstractMasterConverter
  +convert.error=Could not convert from {0} to {1}.
  +no-converter.error=Could not find an appropriate converter.
  +bad-return-type.error=Converter {0} returned an object of type {1} which is assignable
to the expected type {2}.
  +ambiguous-converter.error=More than one converter available for this conversion.
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java
  
  Index: AbstractPropertyResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/property/test/AbstractPropertyResolverTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractPropertyResolverTestCase.java	21 Mar 2002 10:29:15 -0000	1.3
  +++ AbstractPropertyResolverTestCase.java	23 Mar 2002 05:34:17 -0000	1.4
  @@ -9,7 +9,7 @@
   
   import java.io.File;
   import java.util.Date;
  -import org.apache.antlib.core.ObjectToStringConverter;
  +import org.apache.aut.converter.lib.ObjectToStringConverter;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
  @@ -21,7 +21,7 @@
    * General-purpose property resolver test cases.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.3 $ $Date: 2002/03/21 10:29:15 $
  + * @version $Revision: 1.4 $ $Date: 2002/03/23 05:34:17 $
    */
   public abstract class AbstractPropertyResolverTestCase
       extends AbstractComponentTest
  
  
  
  1.4       +1 -1      jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java
  
  Index: DefaultConfigurerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/test/org/apache/myrmidon/components/configurer/test/DefaultConfigurerTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultConfigurerTestCase.java	21 Mar 2002 10:29:15 -0000	1.3
  +++ DefaultConfigurerTestCase.java	23 Mar 2002 05:34:17 -0000	1.4
  @@ -8,7 +8,7 @@
   package org.apache.myrmidon.components.configurer.test;
   
   import java.io.File;
  -import org.apache.antlib.core.StringToIntegerConverter;
  +import org.apache.aut.converter.lib.StringToIntegerConverter;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.ExceptionUtil;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/ObjectToStringConverter.java
  
  Index: ObjectToStringConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  
  /**
   * A general-purpose converter that converts an Object to a String using
   * its toString() method.
   *
   * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/23 05:34:17 $
   *
   * @ant.converter source="java.lang.Object" destination="java.lang.String"
   */
  public class ObjectToStringConverter
      extends AbstractConverter
  {
      public ObjectToStringConverter()
      {
          super( Object.class, String.class );
      }
  
      /**
       * Converts an object.
       */
      protected Object convert( final Object original, final Object context )
          throws ConverterException
      {
          return original.toString();
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToBooleanConverter.java
  
  Index: StringToBooleanConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to boolean converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Boolean"
   */
  public class StringToBooleanConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToBooleanConverter.class );
  
      public StringToBooleanConverter()
      {
          super( String.class, Boolean.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          final String string = (String)object;
          if( string.equalsIgnoreCase( "true" )
              || string.equalsIgnoreCase( "yes" ) )
          {
              return Boolean.TRUE;
          }
          else if( string.equalsIgnoreCase( "false" )
                   || string.equalsIgnoreCase( "no" ) )
          {
              return Boolean.FALSE;
          }
          else
          {
              final String message = REZ.getString( "convert.bad-boolean.error", object );
              throw new ConverterException( message );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToByteConverter.java
  
  Index: StringToByteConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to byte converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Byte"
   */
  public class StringToByteConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToByteConverter.class );
  
      public StringToByteConverter()
      {
          super( String.class, Byte.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Byte( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-byte.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToClassConverter.java
  
  Index: StringToClassConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to class converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Class"
   */
  public class StringToClassConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToClassConverter.class );
  
      public StringToClassConverter()
      {
          super( String.class, Class.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          //TODO: Should we use ContextClassLoader here???
          try
          {
              return Class.forName( (String)object );
          }
          catch( final Exception e )
          {
              final String message = REZ.getString( "convert.bad-class.error", object );
              throw new ConverterException( message, e );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToDoubleConverter.java
  
  Index: StringToDoubleConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to double converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Double"
   */
  public class StringToDoubleConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToDoubleConverter.class );
  
      public StringToDoubleConverter()
      {
          super( String.class, Double.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Double( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-double.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToFileConverter.java
  
  Index: StringToFileConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import java.io.File;
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * String to file converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.io.File"
   */
  public class StringToFileConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToFileConverter.class );
  
      public StringToFileConverter()
      {
          super( String.class, File.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              final TaskContext taskContext = (TaskContext)context;
              return taskContext.resolveFile( (String)object );
          }
          catch( final TaskException te )
          {
              final String message = REZ.getString( "convert.bad-file.error", object );
              throw new ConverterException( message, te );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToFloatConverter.java
  
  Index: StringToFloatConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to float converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Float"
   */
  public class StringToFloatConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToFloatConverter.class );
  
      public StringToFloatConverter()
      {
          super( String.class, Float.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Float( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-float.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToIntegerConverter.java
  
  Index: StringToIntegerConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.aut.converter.lib.StringToFloatConverter;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to integer converter.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Integer"
   */
  public class StringToIntegerConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToFloatConverter.class );
  
      public StringToIntegerConverter()
      {
          super( String.class, Integer.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Integer( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-integer.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToLongConverter.java
  
  Index: StringToLongConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to long converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Long"
   */
  public class StringToLongConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToLongConverter.class );
  
      public StringToLongConverter()
      {
          super( String.class, Long.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Long( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-long.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToShortConverter.java
  
  Index: StringToShortConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to short converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.lang.Short"
   */
  public class StringToShortConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToShortConverter.class );
  
      public StringToShortConverter()
      {
          super( String.class, Short.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new Short( (String)object );
          }
          catch( final NumberFormatException nfe )
          {
              final String message = REZ.getString( "convert.bad-short.error", object );
              throw new ConverterException( message, nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/StringToURLConverter.java
  
  Index: StringToURLConverter.java
  ===================================================================
  /*
   * 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.
   */
  package org.apache.aut.converter.lib;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  import org.apache.aut.converter.AbstractConverter;
  import org.apache.aut.converter.ConverterException;
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  
  /**
   * String to url converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @ant.converter source="java.lang.String" destination="java.net.URL"
   */
  public class StringToURLConverter
      extends AbstractConverter
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( StringToURLConverter.class );
  
      public StringToURLConverter()
      {
          super( String.class, URL.class );
      }
  
      public Object convert( final Object object, final Object context )
          throws ConverterException
      {
          try
          {
              return new URL( (String)object );
          }
          catch( final MalformedURLException mue )
          {
              final String message = REZ.getString( "convert.bad-url.error", object );
              throw new ConverterException( message, mue );
          }
  
      }
  }
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message