jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt FormatNumberSupport.java
Date Mon, 15 Apr 2002 16:58:31 GMT
luehe       02/04/15 09:58:31

  Modified:    standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tag/common/fmt
                        FormatNumberSupport.java
  Log:
  <fmt:formatNumber> has been changed to use Long.valueOf() or Double.valueOf() (instead
of the default formatting pattern of the EN locale) to parse numeric string values
  
  Revision  Changes    Path
  1.19      +3 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Resources.properties	14 Apr 2002 02:10:31 -0000	1.18
  +++ Resources.properties	15 Apr 2002 16:58:31 -0000	1.19
  @@ -101,6 +101,9 @@
   FORMAT_NUMBER_NO_VALUE=\
       &lt;formatNumber&gt; needs 'value' attribute or non-whitespace body
   
  +FORMAT_NUMBER_PARSE_ERROR=\
  +    In &lt;formatNumber&gt;, 'value' attribute can not be parsed into java.lang.Number:
"{0}"
  +
   PARSE_NUMBER_INVALID_TYPE=\
       In &lt;parseNumber&gt;, invalid 'type' attribute: "{0}"
   
  
  
  
  1.16      +10 -7     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/FormatNumberSupport.java
  
  Index: FormatNumberSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/FormatNumberSupport.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- FormatNumberSupport.java	12 Apr 2002 19:16:49 -0000	1.15
  +++ FormatNumberSupport.java	15 Apr 2002 16:58:31 -0000	1.16
  @@ -169,16 +169,19 @@
   
   	/*
   	 * If 'value' is a String, it is first parsed into an instance of
  -	 * java.lang.Number according to the default pattern of the "en"
  -	 * locale.
  +	 * java.lang.Number
   	 */
   	if (value instanceof String) {
  -	    NumberFormat parser
  -		= NumberFormat.getNumberInstance(Locale.ENGLISH);
   	    try {
  -		value = parser.parse((String) value);
  -	    } catch (ParseException pe) {
  -		throw new JspTagException(pe.getMessage());
  +		if (((String) value).indexOf('.') != -1) {
  +		    value = Double.valueOf((String) value);
  +		} else {
  +		    value = Long.valueOf((String) value);
  +		}
  +	    } catch (NumberFormatException nfe) {
  +		throw new JspException(
  +                    Resources.getMessage("FORMAT_NUMBER_PARSE_ERROR", value),
  +		    nfe);
   	    }
   	}
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message