| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectatg.nucleus.logging.VariableArgumentApplicationLoggingImpl
atg.nucleus.GenericService
atg.nucleus.TimedOperationService
atg.nucleus.servlet.ServletService
atg.nucleus.servlet.HttpServletService
atg.servlet.DynamoServlet
atg.droplet.CurrencyFormatter
atg.droplet.CurrencyConversionFormatter
public class CurrencyConversionFormatter
This droplet can be used to convert and format a numeric amount, within a particular Locale, from a specific currency into a specific currency.
Example:
 <importbean bean="/atg/dynamo/droplet/CurrencyConversionFormatter">
 <droplet bean="CurrencyConversionFormatter">
   <param name="currency" value="param:amount">
   <param name="locale" value="en_US">
   <param name="targetLocale" value="bean:/OriginatingRequest.requestLocale.locale">
   <param name="euroSymbol" value="&euro">
   <oparam name="output">
     <valueof param="formattedCurrency" valueishtml>no price</valueof>
   </oparam>
 </droplet>
 
 Usage:
 output parameter, this is the formatted currency
 
| Field Summary | |
|---|---|
| static java.lang.String | CLASS_VERSIONClass version string | 
| protected  java.util.Map | mExchangeRates | 
| Fields inherited from class atg.servlet.DynamoServlet | 
|---|
| mAllowCleanupRequest, mParameters | 
| Fields inherited from class atg.nucleus.servlet.ServletService | 
|---|
| SERVLET_INFO_KEY | 
| Fields inherited from class atg.nucleus.GenericService | 
|---|
| SERVICE_INFO_KEY | 
| Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging | 
|---|
| DEFAULT_LOG_TRACE_STATUS | 
| Fields inherited from interface atg.nucleus.logging.ApplicationLogging | 
|---|
| DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS | 
| Constructor Summary | |
|---|---|
| CurrencyConversionFormatter()Constructs an instanceof CurrencyConversionFormatter | |
| Method Summary | |
|---|---|
|  java.lang.Number | convertCurrency(java.lang.Number pOriginalValue,
                java.util.Locale pSourceLocale,
                java.util.Locale pTargetLocale)Convert an amount of money between the default currency and the currency of a specified locale Returns null if the locale does not have a configured exchange rate | 
| protected  java.lang.String | formatCurrency(DynamoHttpServletRequest pRequest,
               DynamoHttpServletResponse pResponse)Return the currency formatted in the given Locale as a String. | 
| protected  java.util.Locale | getCurrencyTargetLocale(DynamoHttpServletRequest pRequest,
                        DynamoHttpServletResponse pResponse)Returns the locale associated with the request. | 
| protected  java.lang.String | getEuroSymbol(DynamoHttpServletRequest pRequest,
              DynamoHttpServletResponse pResponse)Returns the symbol to use when formatting a price in Euros. | 
|  java.util.Map | getExchangeRates()Returns property exchangeRates, and, as a side-effect, initializes it if it has not already been initialized. | 
|  java.lang.String | getLookupKey(java.util.Locale pLocale)Obtain the string to use as a look-up key to determine the exchange rate. | 
| protected  java.lang.String | getYenSymbol(DynamoHttpServletRequest pRequest,
             DynamoHttpServletResponse pResponse)Returns the symbol to use when formatting a price in Yen. | 
|  void | initializeConversionMap()Constructs a Map of locale names to currency exchange rates, based on the entries in a ResourceBundle | 
| protected  void | initializeIfNecessary()Do the initialization in initializeConversionMap on a just-in-time basis. | 
|  void | service(DynamoHttpServletRequest pRequest,
        DynamoHttpServletResponse pResponse)Takes the formatted currency String and sets a request parameter named formattedCurrency, then services theoutputparameter. | 
|  void | setExchangeRates(java.util.Map pExchangeRates)Sets property exchangeRates | 
| Methods inherited from class atg.droplet.CurrencyFormatter | 
|---|
| getCurrency, getCurrencyLocale, getDefaultLocale, isUseRequestLocale, setDefaultLocale, setUseRequestLocale | 
| Methods inherited from class atg.servlet.DynamoServlet | 
|---|
| doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter | 
| Methods inherited from class atg.nucleus.servlet.ServletService | 
|---|
| destroy, getServletConfig, getServletInfo, setServletInfo | 
| Methods inherited from class atg.nucleus.TimedOperationService | 
|---|
| getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics | 
| Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl | 
|---|
| vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning | 
| 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
protected java.util.Map mExchangeRates
| Constructor Detail | 
|---|
public CurrencyConversionFormatter()
| Method Detail | 
|---|
public void setExchangeRates(java.util.Map pExchangeRates)
The value of this property is a Map that has an entry for each supported currency conversion. The name for each entry is a 2-letter country code. The value for each entry is a double that indicates how many of the locale-specific currency are equivalent to one (1) unit of the default currency.
public java.util.Map getExchangeRates()
initializeIfNecessary
protected java.util.Locale getCurrencyTargetLocale(DynamoHttpServletRequest pRequest,
                                                   DynamoHttpServletResponse pResponse)
                                            throws javax.servlet.ServletException,
                                                   java.io.IOException
sourceLocale. This value can be
 either a java.util.Locale object or a String which represents the locale.
 Next if the useRequestLocale property is true, then the locale
 of the request will be returned. Finally, if the locale cannot be determined,
 the the defaultLocale property is used.
javax.servlet.ServletException
java.io.IOException
protected java.lang.String getEuroSymbol(DynamoHttpServletRequest pRequest,
                                         DynamoHttpServletResponse pResponse)
                                  throws javax.servlet.ServletException,
                                         java.io.IOException
getEuroSymbol in class CurrencyFormatterjavax.servlet.ServletException
java.io.IOException
protected java.lang.String getYenSymbol(DynamoHttpServletRequest pRequest,
                                        DynamoHttpServletResponse pResponse)
                                 throws javax.servlet.ServletException,
                                        java.io.IOException
javax.servlet.ServletException
java.io.IOException
protected java.lang.String formatCurrency(DynamoHttpServletRequest pRequest,
                                          DynamoHttpServletResponse pResponse)
                                   throws javax.servlet.ServletException,
                                          java.io.IOException
getCurrency(request, response)
 getCurrencyLocale(request, response) and
 getCurrencyTargetLocale(request, response) methods.
formatCurrency in class CurrencyFormatterjavax.servlet.ServletException
java.io.IOExceptionprotected void initializeIfNecessary()
initializeConversionMap, 
getExchangeRatespublic void initializeConversionMap()
ServiceException - if an entry could not be parsed as a Double
public java.lang.Number convertCurrency(java.lang.Number pOriginalValue,
                                        java.util.Locale pSourceLocale,
                                        java.util.Locale pTargetLocale)
pOriginalValue - the amount of money to convertpSourceLocale - the locale indicating the currency from which to convertpTargetLocale - the locale indicating the currency to which to convertpublic java.lang.String getLookupKey(java.util.Locale pLocale)
pLocale - the user's locale
public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
formattedCurrency, then services the output
 parameter.
service in class CurrencyFormatterpRequest - the request to be processedpResponse - the response object for this request
javax.servlet.ServletException - an application specific error occurred
 processing this request
java.io.IOException - an error occurred reading data from the request
 or writing data to the response.| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||