org.apache.cocoon.forms.datatype.convertor
Class FormattingDecimalConvertor

java.lang.Object
  extended byorg.apache.cocoon.forms.datatype.convertor.FormattingDecimalConvertor
All Implemented Interfaces:
Convertor
Direct Known Subclasses:
FormattingDoubleConvertor, FormattingFloatConvertor, FormattingIntegerConvertor, FormattingLongConvertor

public class FormattingDecimalConvertor
extends Object
implements Convertor

A Convertor for BigDecimals backed by the DecimalFormat class.

It can be configured to use one of these variants: integer, number, currency or percent.

Alternatively, a formatting pattern can be used. This can either be a locale-dependent or locale-independent formatting pattern. When looking up a formatting pattern, a mechansim similar to resource bundle lookup is used. Suppose the locale is nl-BE, then first a formatting 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.

Version:
$Id: FormattingDecimalConvertor.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
 
Nested classes inherited from class org.apache.cocoon.forms.datatype.convertor.Convertor
Convertor.FormatCache
 
Field Summary
static int CURRENCY
           
static int INTEGER
           
static int NUMBER
           
static int PERCENT
           
 
Constructor Summary
FormattingDecimalConvertor()
           
 
Method Summary
 void addFormattingPattern(Locale locale, String pattern)
           
 ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache)
          Converts string representation into the object of convertor's type.
 String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
           
 void generateSaxFragment(ContentHandler contentHandler, Locale locale)
          Generates a bit of information about this convertor (optional).
protected  DecimalFormat getDecimalFormat(Locale locale, Convertor.FormatCache formatCache)
           
protected  int getDefaultVariant()
           
 Class getTypeClass()
           
 void setNonLocalizedPattern(String pattern)
           
 void setVariant(int variant)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

NUMBER

public static final int NUMBER
See Also:
Constant Field Values

CURRENCY

public static final int CURRENCY
See Also:
Constant Field Values

PERCENT

public static final int PERCENT
See Also:
Constant Field Values
Constructor Detail

FormattingDecimalConvertor

public FormattingDecimalConvertor()
Method Detail

getDefaultVariant

protected int getDefaultVariant()

convertFromString

public ConversionResult convertFromString(String value,
                                          Locale locale,
                                          Convertor.FormatCache formatCache)
Description copied from interface: Convertor
Converts string representation into the object of convertor's type.

Specified by:
convertFromString in interface Convertor
Parameters:
formatCache - can be null if not needed

convertToString

public String convertToString(Object value,
                              Locale locale,
                              Convertor.FormatCache formatCache)
Specified by:
convertToString in interface Convertor

getDecimalFormat

protected final DecimalFormat getDecimalFormat(Locale locale,
                                               Convertor.FormatCache formatCache)

setVariant

public void setVariant(int variant)

addFormattingPattern

public void addFormattingPattern(Locale locale,
                                 String pattern)

setNonLocalizedPattern

public void setNonLocalizedPattern(String pattern)

getTypeClass

public Class getTypeClass()
Specified by:
getTypeClass in interface Convertor

generateSaxFragment

public void generateSaxFragment(ContentHandler contentHandler,
                                Locale locale)
                         throws SAXException
Description copied from interface: Convertor
Generates a bit of information about this convertor (optional).

Specified by:
generateSaxFragment in interface Convertor
Throws:
SAXException


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.