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/libs/core StringToByteConverter.java StringToClassConverter.java StringToDoubleConverter.java StringToFileConverter.java StringToFloatConverter.java StringToIntegerConverter.java StringToLongConverter.java StringToShortConverter.java StringToURLConverter.java
Date Sat, 16 Jun 2001 03:28:54 GMT
donaldp     01/06/15 20:28:54

  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/libs/core
                        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/ant/modules/basic
                        StringToByteConverter.java
                        StringToClassConverter.java
                        StringToDoubleConverter.java
                        StringToFileConverter.java
                        StringToFloatConverter.java
                        StringToIntegerConverter.java
                        StringToLongConverter.java
                        StringToShortConverter.java
                        StringToURLConverter.java
  Log:
  Migrated converter files into separate library.
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to byte converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToByteConverter
      extends AbstractConverter
  {
      public StringToByteConverter()
      {
          super( String.class, Byte.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Byte( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
  
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to class converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToClassConverter
      extends AbstractConverter
  {
      public StringToClassConverter()
      {
          super( String.class, Class.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          //TODO: Should we use ContextClassLoader here???
          try { return Class.forName( (String)original ); }
          catch( final Exception e )
          {
              throw new ConverterException( "Error converting to class type", e );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to double converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToDoubleConverter
      extends AbstractConverter
  {
      public StringToDoubleConverter()
      {
          super( String.class, Double.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Double( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import java.io.File;
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to file converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToFileConverter
      extends AbstractConverter
  {
      public StringToFileConverter()
      {
          super( String.class, File.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try
          {
              final TaskContext taskContext = (TaskContext)context;
              return taskContext.resolveFile( (String)original );
          }
          catch( final TaskException te )
          {
              throw new ConverterException( "Error resolving file during conversion", te );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to float converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToFloatConverter
      extends AbstractConverter
  {
      public StringToFloatConverter()
      {
          super( String.class, Float.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Float( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to integer converter.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToIntegerConverter
      extends AbstractConverter
  {
      public StringToIntegerConverter()
      {
          super( String.class, Integer.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Integer( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to long converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToLongConverter
      extends AbstractConverter
  {
      public StringToLongConverter()
      {
          super( String.class, Long.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Long( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to short converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToShortConverter
      extends AbstractConverter
  {
      public StringToShortConverter()
      {
          super( String.class, Short.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new Short( (String)original ); }
          catch( final NumberFormatException nfe )
          {
              throw new ConverterException( "Error formatting object", nfe );
          }
  
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/libs/core/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 file.
   */
  package org.apache.myrmidon.libs.core;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to url converter
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class StringToURLConverter
      extends AbstractConverter
  {
      public StringToURLConverter()
      {
          super( String.class, URL.class );
      }
  
      public Object convert( final Object original, final Context context )
          throws ConverterException
      {
          try { return new URL( (String)original ); }
          catch( final MalformedURLException mue )
          {
              throw new ConverterException( "Error formatting object", mue );
          }
  
      }
  }
  
  
  
  

Mime
View raw message