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/aut/converter/lib SimpleMasterConverter.java
Date Thu, 28 Mar 2002 01:59:14 GMT
donaldp     02/03/27 17:59:14

  Added:       proposal/myrmidon/src/java/org/apache/aut/converter/lib
                        SimpleMasterConverter.java
  Log:
  Add in a basic MasterConverter
  
  Not used in ant but will be used by outside users of the library.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/aut/converter/lib/SimpleMasterConverter.java
  
  Index: SimpleMasterConverter.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.AbstractMasterConverter;
  import org.apache.aut.converter.Converter;
  
  /**
   * A very simple master converter that is capable of using
   * any of the converters in this package.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/03/28 01:59:14 $
   */
  public class SimpleMasterConverter
      extends AbstractMasterConverter
  {
      public SimpleMasterConverter()
      {
          registerConverter( ObjectToStringConverter.class.getName(),
                             "java.lang.Object",
                             "java.lang.String" );
          registerConverter( StringToBooleanConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Boolean" );
          registerConverter( StringToByteConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Byte" );
          registerConverter( StringToClassConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Class" );
          registerConverter( StringToDoubleConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Double" );
          registerConverter( StringToFloatConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Float" );
          registerConverter( StringToIntegerConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Integer" );
          registerConverter( StringToLongConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Long" );
          registerConverter( StringToShortConverter.class.getName(),
                             "java.lang.String",
                             "java.lang.Short" );
          registerConverter( StringToURLConverter.class.getName(),
                             "java.lang.String",
                             "java.net.URL" );
          registerConverter( StringToDateConverter.class.getName(),
                             "java.lang.String",
                             "java.util.Date" );
      }
  
      /**
       * Create an instance of converter with specified name.
       *
       * @param name the name of converter
       * @return the created converter instance
       * @throws Exception if converter can not be created.
       */
      protected Converter createConverter( final String name )
          throws Exception
      {
          final ClassLoader classLoader = getClass().getClassLoader();
          final Class clazz = classLoader.loadClass( name );
          return (Converter)clazz.newInstance();
      }
  }
  
  
  

--
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