You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/07/25 03:41:00 UTC

cvs commit: jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib StringToByteConverter.java StringToIntegerConverter.java StringToLongConverter.java StringToShortConverter.java

donaldp     2002/07/24 18:41:00

  Modified:    converter/src/java/org/apache/excalibur/converter/lib
                        StringToByteConverter.java
                        StringToIntegerConverter.java
                        StringToLongConverter.java
                        StringToShortConverter.java
  Log:
  Use decode to decode integers rather than a custom mechanism
  
  Revision  Changes    Path
  1.5       +1 -18     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToByteConverter.java
  
  Index: StringToByteConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToByteConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToByteConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  +++ StringToByteConverter.java	25 Jul 2002 01:41:00 -0000	1.5
  @@ -56,24 +56,7 @@
           try
           {
               final String value = (String)object;
  -            byte result = 0;
  -            if( value.startsWith( "0x" ) )
  -            {
  -                result = Byte.parseByte( value.substring( 2 ), 16 );
  -            }
  -            else if( value.startsWith( "0o" ) )
  -            {
  -                result = Byte.parseByte( value.substring( 2 ), 8 );
  -            }
  -            else if( value.startsWith( "0b" ) )
  -            {
  -                result = Byte.parseByte( value.substring( 2 ), 2 );
  -            }
  -            else
  -            {
  -                result = Byte.parseByte( value );
  -            }
  -            return new Byte( result );
  +            return Byte.decode( value.substring( 2 ) );
           }
           catch( final NumberFormatException nfe )
           {
  
  
  
  1.5       +1 -18     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToIntegerConverter.java
  
  Index: StringToIntegerConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToIntegerConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToIntegerConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  +++ StringToIntegerConverter.java	25 Jul 2002 01:41:00 -0000	1.5
  @@ -56,24 +56,7 @@
           try
           {
               final String value = (String)object;
  -            int result = 0;
  -            if( value.startsWith( "0x" ) )
  -            {
  -                result = Integer.parseInt( value.substring( 2 ), 16 );
  -            }
  -            else if( value.startsWith( "0o" ) )
  -            {
  -                result = Integer.parseInt( value.substring( 2 ), 8 );
  -            }
  -            else if( value.startsWith( "0b" ) )
  -            {
  -                result = Integer.parseInt( value.substring( 2 ), 2 );
  -            }
  -            else
  -            {
  -                result = Integer.parseInt( value );
  -            }
  -            return new Integer( result );
  +            return Integer.decode( value );
           }
           catch( final NumberFormatException nfe )
           {
  
  
  
  1.5       +1 -18     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToLongConverter.java
  
  Index: StringToLongConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToLongConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToLongConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  +++ StringToLongConverter.java	25 Jul 2002 01:41:00 -0000	1.5
  @@ -56,24 +56,7 @@
           try
           {
               final String value = (String)object;
  -            long result = 0;
  -            if( value.startsWith( "0x" ) )
  -            {
  -                result = Long.parseLong( value.substring( 2 ), 16 );
  -            }
  -            else if( value.startsWith( "0o" ) )
  -            {
  -                result = Long.parseLong( value.substring( 2 ), 8 );
  -            }
  -            else if( value.startsWith( "0b" ) )
  -            {
  -                result = Long.parseLong( value.substring( 2 ), 2 );
  -            }
  -            else
  -            {
  -                result = Long.parseLong( value );
  -            }
  -            return new Long( result );
  +            return Long.decode( value );
           }
           catch( final NumberFormatException nfe )
           {
  
  
  
  1.5       +1 -18     jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToShortConverter.java
  
  Index: StringToShortConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/converter/src/java/org/apache/excalibur/converter/lib/StringToShortConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringToShortConverter.java	16 Jul 2002 01:09:49 -0000	1.4
  +++ StringToShortConverter.java	25 Jul 2002 01:41:00 -0000	1.5
  @@ -56,24 +56,7 @@
           try
           {
               final String value = (String)object;
  -            short result = 0;
  -            if( value.startsWith( "0x" ) )
  -            {
  -                result = Short.parseShort( value.substring( 2 ), 16 );
  -            }
  -            else if( value.startsWith( "0o" ) )
  -            {
  -                result = Short.parseShort( value.substring( 2 ), 8 );
  -            }
  -            else if( value.startsWith( "0b" ) )
  -            {
  -                result = Short.parseShort( value.substring( 2 ), 2 );
  -            }
  -            else
  -            {
  -                result = Short.parseShort( value );
  -            }
  -            return new Short( result );
  +            return Short.decode( value );
           }
           catch( final NumberFormatException nfe )
           {
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>