cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor FormattingDecimalConvertor.java
Date Wed, 26 May 2004 01:41:21 GMT
joerg       2004/05/25 18:41:21

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor
                        FormattingFloatConvertor.java
                        FormattingDecimalConvertor.java
               src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor
                        FormattingDecimalConvertor.java
  Log:
  code formatting
  
  Revision  Changes    Path
  1.5       +19 -16    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingFloatConvertor.java
  
  Index: FormattingFloatConvertor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingFloatConvertor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FormattingFloatConvertor.java	9 Mar 2004 13:54:15 -0000	1.4
  +++ FormattingFloatConvertor.java	26 May 2004 01:41:21 -0000	1.5
  @@ -63,25 +63,28 @@
   
       public Object convertFromString(String value, Locale locale, Convertor.FormatCache
formatCache) {
           DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
  +        Number decimalValue;
           try {
  -            Number decimalValue = decimalFormat.parse(value);
  -            if (decimalValue instanceof BigDecimal)
  -                ;
  -			else if (decimalValue instanceof Integer)
  -				decimalValue = new BigDecimal(decimalValue .intValue());
  -            else if (decimalValue instanceof Long)
  -                decimalValue = new BigDecimal(decimalValue.longValue());
  -            else if (decimalValue instanceof Double)
  -                decimalValue = new BigDecimal(decimalValue.doubleValue());
  -            else if (decimalValue instanceof BigInteger)
  -                decimalValue = new BigDecimal((BigInteger)decimalValue);
  -            else
  -                return null;
  -
  -            return decimalValue;
  +            decimalValue = decimalFormat.parse(value);
           } catch (ParseException e) {
               return null;
           }
  +
  +        if (decimalValue instanceof BigDecimal) {
  +            // no need for conversion
  +        } else if (decimalValue instanceof Integer) {
  +            decimalValue = new BigDecimal(decimalValue .intValue());
  +        } else if (decimalValue instanceof Long) {
  +            decimalValue = new BigDecimal(decimalValue.longValue());
  +        } else if (decimalValue instanceof Double) {
  +            decimalValue = new BigDecimal(decimalValue.doubleValue());
  +        } else if (decimalValue instanceof BigInteger) {
  +            decimalValue = new BigDecimal((BigInteger)decimalValue);
  +        } else {
  +            return null;
  +        }
  +
  +        return decimalValue;
       }
   
       public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
{
  
  
  
  1.7       +19 -16    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingDecimalConvertor.java
  
  Index: FormattingDecimalConvertor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor/FormattingDecimalConvertor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FormattingDecimalConvertor.java	9 Mar 2004 13:54:15 -0000	1.6
  +++ FormattingDecimalConvertor.java	26 May 2004 01:41:21 -0000	1.7
  @@ -66,25 +66,28 @@
   
       public Object convertFromString(String value, Locale locale, Convertor.FormatCache
formatCache) {
           DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
  +        Number decimalValue;
           try {
  -            Number decimalValue = decimalFormat.parse(value);
  -            if (decimalValue instanceof BigDecimal)
  -                ;
  -			else if (decimalValue instanceof Integer)
  -				decimalValue = new BigDecimal(decimalValue .intValue());
  -            else if (decimalValue instanceof Long)
  -                decimalValue = new BigDecimal(decimalValue.longValue());
  -            else if (decimalValue instanceof Double)
  -                decimalValue = new BigDecimal(decimalValue.doubleValue());
  -            else if (decimalValue instanceof BigInteger)
  -                decimalValue = new BigDecimal((BigInteger)decimalValue);
  -            else
  -                return null;
  -
  -            return decimalValue;
  +            decimalValue = decimalFormat.parse(value);
           } catch (ParseException e) {
               return null;
           }
  +
  +        if (decimalValue instanceof BigDecimal) {
  +            // no need for conversion
  +        } else if (decimalValue instanceof Integer) {
  +            decimalValue = new BigDecimal(decimalValue .intValue());
  +        } else if (decimalValue instanceof Long) {
  +            decimalValue = new BigDecimal(decimalValue.longValue());
  +        } else if (decimalValue instanceof Double) {
  +            decimalValue = new BigDecimal(decimalValue.doubleValue());
  +        } else if (decimalValue instanceof BigInteger) {
  +            decimalValue = new BigDecimal((BigInteger)decimalValue);
  +        } else {
  +            return null;
  +        }
  +
  +        return decimalValue;
       }
   
       public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
{
  
  
  
  1.5       +18 -16    cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java
  
  Index: FormattingDecimalConvertor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FormattingDecimalConvertor.java	6 May 2004 14:59:44 -0000	1.4
  +++ FormattingDecimalConvertor.java	26 May 2004 01:41:21 -0000	1.5
  @@ -68,25 +68,27 @@
   
       public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache
formatCache) {
           DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
  +        Number decimalValue;
           try {
  -            Number decimalValue = decimalFormat.parse(value);
  -            if (decimalValue instanceof BigDecimal)
  -                ;
  -			else if (decimalValue instanceof Integer)
  -				decimalValue = new BigDecimal(decimalValue .intValue());
  -            else if (decimalValue instanceof Long)
  -                decimalValue = new BigDecimal(decimalValue.longValue());
  -            else if (decimalValue instanceof Double)
  -                decimalValue = new BigDecimal(decimalValue.doubleValue());
  -            else if (decimalValue instanceof BigInteger)
  -                decimalValue = new BigDecimal((BigInteger)decimalValue);
  -            else
  -                return ConversionResult.create("decimal");
  -
  -            return new ConversionResult(decimalValue);
  +            decimalValue = decimalFormat.parse(value);
           } catch (ParseException e) {
               return ConversionResult.create("decimal");
           }
  +
  +        if (decimalValue instanceof BigDecimal) {
  +            // no need for conversion
  +        } else if (decimalValue instanceof Integer) {
  +            decimalValue = new BigDecimal(decimalValue.intValue());
  +        } else if (decimalValue instanceof Long) {
  +            decimalValue = new BigDecimal(decimalValue.longValue());
  +        } else if (decimalValue instanceof Double) {
  +            decimalValue = new BigDecimal(decimalValue.doubleValue());
  +        } else if (decimalValue instanceof BigInteger) {
  +            decimalValue = new BigDecimal((BigInteger)decimalValue);
  +        } else {
  +            return ConversionResult.create("decimal");
  +        }
  +        return new ConversionResult(decimalValue);
       }
   
       public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
{
  
  
  

Mime
View raw message