Author: tim
Date: Tue Mar 15 06:51:52 2005
New Revision: 157545
URL: http://svn.apache.org/viewcvs?view=rev&rev=157545
Log:
Sync with trunk.
Added:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java
- copied unchanged from r157540,
cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java
- copied unchanged from r157540,
cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/datatype/convertor/Icu4jDateConvertorBuilder.java
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDateConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDateConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDateConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDateConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDateConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,8 +15,6 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.DateFormat;
-import org.outerj.i18n.I18nSupport;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.apache.cocoon.forms.Constants;
@@ -24,7 +22,9 @@
import java.util.Locale;
import java.util.Date;
+import java.text.DateFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
/**
* A Convertor for [EMAIL PROTECTED] java.util.Date Date} objects backed by the
@@ -39,11 +39,6 @@
* pattern for nl-BE will be sought, then one for nl, and if that is not
* found, finally the locale-independent formatting pattern will be used.
*
- * <p><strong>NOTE:</strong> the earlier statement about the fact that this
class uses java.text.SimpleDateFormat
- * is not entirely correct. In fact, it uses a small wrapper class that will
either delegate to
- * java.text.SimpleDateFormat or com.ibm.icu.text.SimpleDateFormat. The
com.ibm version will automatically
- * be used if it is present on the classpath, otherwise the java.text version
will be used.
- *
* @version $Id$
*/
public class FormattingDateConvertor implements Convertor {
@@ -61,13 +56,13 @@
public static final String DATE_TIME = "datetime";
public FormattingDateConvertor() {
- this.style = java.text.DateFormat.SHORT;
+ this.style = DateFormat.SHORT;
this.variant = DATE;
this.localizedPatterns = new LocaleMap();
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
- DateFormat dateFormat = getDateFormat(locale, formatCache);
+ SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
try {
return new ConversionResult(dateFormat.parse(value));
} catch (ParseException e) {
@@ -76,14 +71,14 @@
}
public String convertToString(Object value, Locale locale,
Convertor.FormatCache formatCache) {
- DateFormat dateFormat = getDateFormat(locale, formatCache);
+ SimpleDateFormat dateFormat = getDateFormat(locale, formatCache);
return dateFormat.format((Date)value);
}
- private final DateFormat getDateFormat(Locale locale,
Convertor.FormatCache formatCache) {
- DateFormat dateFormat = null;
+ private final SimpleDateFormat getDateFormat(Locale locale,
Convertor.FormatCache formatCache) {
+ SimpleDateFormat dateFormat = null;
if (formatCache != null)
- dateFormat = (DateFormat)formatCache.get();
+ dateFormat = (SimpleDateFormat)formatCache.get();
if (dateFormat == null) {
dateFormat = getDateFormat(locale);
if (formatCache != null)
@@ -92,21 +87,28 @@
return dateFormat;
}
- protected DateFormat getDateFormat(Locale locale) {
- DateFormat dateFormat = null;
+ protected SimpleDateFormat getDateFormat(Locale locale) {
+ SimpleDateFormat dateFormat = null;
if (this.variant.equals(DATE)) {
- dateFormat = I18nSupport.getInstance().getDateFormat(style,
locale);
+ //dateFormat = I18nSupport.getInstance().getDateFormat(style,
locale);
+ dateFormat = (SimpleDateFormat)DateFormat.getDateInstance(style,
locale);
} else if (this.variant.equals(TIME)) {
- dateFormat = I18nSupport.getInstance().getTimeFormat(style,
locale);
+ //dateFormat = I18nSupport.getInstance().getTimeFormat(style,
locale);
+ dateFormat = (SimpleDateFormat)DateFormat.getTimeInstance(style,
locale);
} else if (this.variant.equals(DATE_TIME)) {
- dateFormat = I18nSupport.getInstance().getDateTimeFormat(style,
style, locale);
+ //dateFormat = I18nSupport.getInstance().getDateTimeFormat(style,
style, locale);
+ dateFormat =
(SimpleDateFormat)DateFormat.getDateTimeInstance(style, style, locale);
}
String pattern = (String)localizedPatterns.get(locale);
if (pattern != null)
- dateFormat.applyLocalizedPattern(pattern);
+ // Note: this was previously using applyLocalizedPattern() which
allows to use
+ // a locale-specific pattern syntax, e.g. in french "j" (jour) for
"d" and
+ // "a" (annee) for "y". But the localized pattern syntax is very
little known and thus
+ // led to some weird pattern syntax error messages.
+ dateFormat.applyPattern(pattern);
else if (nonLocalizedPattern != null)
dateFormat.applyPattern(nonLocalizedPattern);
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDecimalConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,12 +15,12 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.I18nSupport;
-import org.outerj.i18n.DecimalFormat;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import java.util.Locale;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
import java.text.ParseException;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -38,11 +38,6 @@
* pattern for nl-BE will be sought, then one for nl, and if that is not
* found, finally the locale-independent formatting pattern will be used.
*
- * <p>Note: the earlier statement about the fact that this class uses
java.text.DecimalFormat
- * is not entirely correct. In fact, it uses a small wrapper class that will
either delegate to
- * java.text.DecimalFormat or com.ibm.icu.text.DecimalFormat. The com.ibm
version will automatically
- * be used if it is present on the classpath, otherwise the java.text version
will be used.
- *
* @version $Id$
*/
public class FormattingDecimalConvertor implements Convertor {
@@ -67,6 +62,8 @@
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as
space by the browser
+ value = value.replace(' ', (char)160);
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
Number decimalValue;
try {
@@ -113,23 +110,26 @@
switch (variant) {
case INTEGER:
- decimalFormat =
I18nSupport.getInstance().getIntegerFormat(locale);
+ decimalFormat =
(DecimalFormat)NumberFormat.getNumberInstance(locale);
+ decimalFormat.setMaximumFractionDigits(0);
+ decimalFormat.setDecimalSeparatorAlwaysShown(false);
+ decimalFormat.setParseIntegerOnly(true);
break;
case NUMBER:
- decimalFormat =
I18nSupport.getInstance().getNumberFormat(locale);
+ decimalFormat =
(DecimalFormat)NumberFormat.getNumberInstance(locale);
break;
case CURRENCY:
- decimalFormat =
I18nSupport.getInstance().getCurrencyFormat(locale);
+ decimalFormat =
(DecimalFormat)NumberFormat.getCurrencyInstance(locale);
break;
case PERCENT:
- decimalFormat =
I18nSupport.getInstance().getPercentFormat(locale);
+ decimalFormat =
(DecimalFormat)NumberFormat.getPercentInstance(locale);
break;
}
String pattern = (String)localizedPatterns.get(locale);
if (pattern != null) {
- decimalFormat.applyLocalizedPattern(pattern);
+ decimalFormat.applyPattern(pattern);
} else if (nonLocalizedPattern != null) {
decimalFormat.applyPattern(nonLocalizedPattern);
}
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingDoubleConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.DecimalFormat;
-
import java.util.Locale;
+import java.text.DecimalFormat;
import java.text.ParseException;
/**
@@ -36,6 +35,8 @@
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as
space by the browser
+ value = value.replace(' ', (char)160);
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
try {
Number decimalValue = decimalFormat.parse(value);
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingFloatConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.DecimalFormat;
-
import java.util.Locale;
+import java.text.DecimalFormat;
import java.text.ParseException;
/**
@@ -36,6 +35,8 @@
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as
space by the browser
+ value = value.replace(' ', (char)160);
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
try {
Number decimalValue = decimalFormat.parse(value);
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingIntegerConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.DecimalFormat;
-
import java.util.Locale;
+import java.text.DecimalFormat;
import java.text.ParseException;
/**
@@ -37,6 +36,8 @@
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as
space by the browser
+ value = value.replace(' ', (char)160);
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
try {
Number decimalValue = decimalFormat.parse(value);
Modified:
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
URL:
http://svn.apache.org/viewcvs/cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java?view=diff&r1=157544&r2=157545
==============================================================================
---
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
(original)
+++
cocoon/whiteboard/forms/java/org/apache/cocoon/forms/datatype/convertor/FormattingLongConvertor.java
Tue Mar 15 06:51:52 2005
@@ -15,9 +15,8 @@
*/
package org.apache.cocoon.forms.datatype.convertor;
-import org.outerj.i18n.DecimalFormat;
-
import java.util.Locale;
+import java.text.DecimalFormat;
import java.text.ParseException;
/**
@@ -36,6 +35,8 @@
}
public ConversionResult convertFromString(String value, Locale locale,
Convertor.FormatCache formatCache) {
+ // Some locales (e.g. "fr") produce non-breaking spaces sent back as
space by the browser
+ value = value.replace(' ', (char)160);
DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
try {
Number decimalValue = decimalFormat.parse(value);