|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.droplet.CurrencyTagConverter atg.droplet.EuroTagConverter
public class EuroTagConverter
A tag converter which will parse and format a currency amounts if and only
if the user's locale indicates a country/language that supports the Euro.
N.B. the user's locale does not, itself, need to have the
"EURO" variant. For example, if the user's locale is fr_FR, then the currency
amount will be formatted as though the locale were "fr_FR_EURO".
If the user's locale indicates a country that does not use use the Euro (e.g., en_US), then the tag converter returns null, so that a <VALUEOF> tag will use its default value.
This converter is a subclass of CurrencyTagConverter, and relies upon CurrencyTagConverter to do parsing and formatting.
An example of the use of this converter is as follows:
<valueof param="priceInfo.amount" euro>no price</valueof>
You can also specify a locale as follows:
<valueof param="priceInfo.amount" euro locale="en_US">no price</valueof>
As with CurrencyTagConverter, if no locale is specified then the converter first looks for a request parameter named locale.
This parameter can either be a java.util.Locale object or a String which names a locale. If this
cannot be found then we fetch the locale from the RequestLocale.
You can optionally specify a string to substitute for the euro currency symbol. This is useful because the commonly-used character set ISO Latin-1 (ISO 8859-1) does not include this character. For example, you can specify:
<valueof param="priceInfo.amount" euro symbol="€" >no price</valueof>
This substitutes the HTML entity € in place of the euro currency symbol.
Most browsers correctly display this HTML entity as the currency symbol, even when
using ISO Latin-1.
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
static java.lang.String |
NAME
|
Constructor Summary | |
---|---|
EuroTagConverter()
Constructs an instance of EuroTagConverter |
Method Summary | |
---|---|
java.lang.String |
convertObjectToString(DynamoHttpServletRequest pRequest,
java.lang.Object pValue,
java.util.Properties pAttributes)
Converts the supplied Object value to a String value. |
static java.lang.String |
formatCurrency(java.lang.Object pCurrency,
java.util.Locale pLocale)
Return the supplied currency formatted in the given Locale as a String. |
static java.text.NumberFormat |
getCurrencyFormat(java.util.Locale pLocale)
Return a NumberFormat object which can be used to format currency as an amount in euros. |
static java.util.Map |
getFormatMap()
Returns property formatMap, and, as a side-effect, initializes it if it has not already been initialized. |
java.lang.String |
getName()
Returns the unique name for the TagConverter. |
TagAttributeDescriptor[] |
getTagAttributeDescriptors()
Returns the list of TagAttributeDescriptors which are used by this converter. |
protected static void |
initializeFormatMap()
Find all available euro-compatible locales, and construct a Map that associates their language/country with the number format for formatting amounts of money as an amount in Euros. |
protected static void |
initializeIfNecessary()
Do the initialization in initializeFormatMap on a just-in-time basis. |
static void |
setFormatMap(java.util.Map pFormatMap)
Sets property formatMap |
Methods inherited from class atg.droplet.CurrencyTagConverter |
---|
convertStringToObject, getDefaultLocale, getNumberFormat, isUseRequestLocale, setDefaultLocale, setUseRequestLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
public static final java.lang.String NAME
Constructor Detail |
---|
public EuroTagConverter()
Method Detail |
---|
public static void setFormatMap(java.util.Map pFormatMap)
The value of this property is a Map that has an entry for each euro-compatible locale. The name for each entry is a language/country locale name. The value for each entry is the NumberFormat to use to format currency for that locale.
public static java.util.Map getFormatMap()
initializeIfNecessary
public java.lang.String getName()
getName
in interface TagConverter
getName
in class CurrencyTagConverter
public TagAttributeDescriptor[] getTagAttributeDescriptors()
getTagAttributeDescriptors
in interface TagConverter
getTagAttributeDescriptors
in class CurrencyTagConverter
public java.lang.String convertObjectToString(DynamoHttpServletRequest pRequest, java.lang.Object pValue, java.util.Properties pAttributes) throws TagConversionException
The implementation here is copied from the superclass CurrencyTagConverter, but calls this class' override of static method formatCurrency.
convertObjectToString
in interface TagConverter
convertObjectToString
in class CurrencyTagConverter
pRequest
- the request this conversion applies to. You can use
this request to obtain the RequestLocale to localize the conversion
process. This can be null if the conversion is not performed in
the context of a request.pValue
- the Object value to be converted to a StringpAttributes
- the set of attributes supplied in this tag
declaration.
TagConversionException
public static java.lang.String formatCurrency(java.lang.Object pCurrency, java.util.Locale pLocale)
The implementation here differs from that in the superclass, CurrencyTagConverter, in that, here, if there is no (euro-oriented) NumberFormat available, then this method returns null.
public static java.text.NumberFormat getCurrencyFormat(java.util.Locale pLocale)
protected static void initializeIfNecessary()
initializeFormatMap
,
getFormatMap
protected static void initializeFormatMap()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |