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/antlib/core StringToBooleanConverter.java Resources.properties
Date Sat, 12 Jan 2002 05:49:07 GMT
donaldp     02/01/11 21:49:07

  Modified:    proposal/myrmidon/src/java/org/apache/antlib/core
                        Resources.properties
  Added:       proposal/myrmidon/src/java/org/apache/antlib/core
                        StringToBooleanConverter.java
  Log:
  Add a converter for booleans
  
  Revision  Changes    Path
  1.5       +1 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Resources.properties	5 Jan 2002 03:20:03 -0000	1.4
  +++ Resources.properties	12 Jan 2002 05:49:07 -0000	1.5
  @@ -9,6 +9,7 @@
   loadprop.missing-file.notice=Unable to find property file: {0}.
   loadprop.bad-resolve.error=Unable to resolve and set property named "{0}" to value "{1}".
   
  +convert.bad-boolean.error=Error converting object ({0}) to Boolean.
   convert.bad-byte.error=Error converting object ({0}) to Byte.
   convert.bad-class.error=Error converting object ({0}) to Class.
   convert.bad-double.error=Error converting object ({0}) to Double.
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/core/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.antlib.core;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.avalon.framework.context.Context;
  import org.apache.myrmidon.converter.AbstractConverter;
  import org.apache.myrmidon.converter.ConverterException;
  
  /**
   * String to boolean converter
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   */
  public class StringToBooleanConverter
      extends AbstractConverter
  {
      private static final Resources REZ =
          ResourceManager.getPackageResources( StringToBooleanConverter.class );
  
      public StringToBooleanConverter()
      {
          super( String.class, Boolean.class );
      }
  
      public Object convert( final Object object, final Context context )
          throws ConverterException
      {
          final String string = (String)object;
          if( string.equals( "true" ) )
          {
              return Boolean.TRUE;
          }
          else if( string.equals( "false" ) )
          {
              return Boolean.FALSE;
          }
          else
          {
              final String message = REZ.getString( "convert.bad-boolean.error", object );
              throw new ConverterException( message );
          }
      }
  }
  
  
  
  

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