org.apache.taglibs.rdc
Class Currency

java.lang.Object
  extended by org.apache.taglibs.rdc.core.BaseModel
      extended by org.apache.taglibs.rdc.Currency
All Implemented Interfaces:
java.io.Serializable

public class Currency
extends BaseModel

Datamodel for the currency RDC. The currency RDC will be associated with the currency input, the maximum and minimum values within which the input must lie and the currency code. The currency value and the maximum and minimum values has an expected format of the form UUUmm.nn or mm.nn where UUU is the ISO 4217 currency code, mmm is integer part and nn is the fractional part. If currency code is not specified the defaultcurrency code for the default locale is assumed.

Author:
Tanveer Faruquie, Rahul Akolkar
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.taglibs.rdc.core.BaseModel
BaseModel.ValueInterpreter
 
Field Summary
static int ERR_NEED_HIGHER_VALUE
          A constant for Error Code stating the currency entered is lower than allowed
static int ERR_NEED_LOWER_VALUE
          A constant for Error Code stating the currency entered is higher than allowed
 
Fields inherited from class org.apache.taglibs.rdc.core.BaseModel
ambiguousValues, candidates, canonicalizedValue, className, configuration, confirm, confirmed, DEFAULT_INITIAL_GRAMMAR_NAME, DEFAULT_MIN_CONFIDENCE, DEFAULT_NUM_N_BEST, echo, ERR_NO_DEFAULT, ERR_NONE, errorCode, exitStatus, grammars, id, initial, initialGrammar, interpretation, isAmbiguous, isValid, locale, maxNoInput, maxNoMatch, minConfidence, numNBest, paramsMap, PROPERTY_INITIAL_GRAMMAR, rdcLocale, rdcResourceBundle, skipSubmit, state, subdialog, submit, utterance, value
 
Constructor Summary
Currency()
          Sets default values for all data model members
 
Method Summary
protected  java.lang.Object canonicalize(java.lang.Object input, boolean isAttribute)
          Sets up maximum or minimum permissible value.
 java.lang.String getCurrencyCode()
          Gets the currency code for the currency used
 java.lang.String getMaxValue()
          Gets the maximum allowed value for the amount
 java.lang.String getMinValue()
          Gets the minimum allowed value for the amount
 void setCurrencyCode(java.lang.String code)
          Sets the specified currency code
 void setMaxValue(java.lang.String maxValue)
          Sets the maximum allowed value for the amount
 void setMinValue(java.lang.String minValue)
          Sets the minimum allowed value for the amount
protected  java.lang.Boolean validate(java.lang.Object newValue, boolean setErrorCode)
          Validates the amount value against the given constraints
 
Methods inherited from class org.apache.taglibs.rdc.core.BaseModel
baseCanonicalize, baseValidate, calculateCanonicalizedValue, getAmbiguousValues, getCandidates, getCanonicalizedValue, getClassName, getConfiguration, getConfirm, getConfirmed, getEcho, getERR_NO_DEFAULT, getERR_NONE, getErrorCode, getExitStatus, getGrammars, getId, getInitial, getInterpretation, getIsAmbiguous, getIsValid, getLocale, getMaxNoInput, getMaxNoMatch, getMinConfidence, getNumNBest, getParamsMap, getRdcLocale, getRdcResourceBundle, getSerializedValue, getSkipSubmit, getState, getSubdialog, getSubmit, getUtterance, getValue, setAmbiguousValues, setCandidates, setCanonicalizedValue, setConfiguration, setConfirm, setConfirmed, setEcho, setErrorCode, setExitStatus, setGrammar, setId, setInitial, setInterpretation, setIsAmbiguous, setIsValid, setLocale, setMaxNoInput, setMaxNoMatch, setMinConfidence, setNumNBest, setSkipSubmit, setState, setSubdialog, setSubmit, setUtterance, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_NEED_LOWER_VALUE

public static final int ERR_NEED_LOWER_VALUE
A constant for Error Code stating the currency entered is higher than allowed

See Also:
Constant Field Values

ERR_NEED_HIGHER_VALUE

public static final int ERR_NEED_HIGHER_VALUE
A constant for Error Code stating the currency entered is lower than allowed

See Also:
Constant Field Values
Constructor Detail

Currency

public Currency()
Sets default values for all data model members

Method Detail

getCurrencyCode

public java.lang.String getCurrencyCode()
Gets the currency code for the currency used

Returns:
The ISO 4217 currency code currently used

setCurrencyCode

public void setCurrencyCode(java.lang.String code)
Sets the specified currency code

Parameters:
code - The currency code as defined in ISO 4217 standards

getMaxValue

public java.lang.String getMaxValue()
Gets the maximum allowed value for the amount

Returns:
the maximum allowed value for the amount

setMaxValue

public void setMaxValue(java.lang.String maxValue)
Sets the maximum allowed value for the amount

Parameters:
maxValue - The maximum allowed value

getMinValue

public java.lang.String getMinValue()
Gets the minimum allowed value for the amount

Returns:
the minimum allowed value for the amount

setMinValue

public void setMinValue(java.lang.String minValue)
Sets the minimum allowed value for the amount

Parameters:
minValue - The minimum allowed value

canonicalize

protected java.lang.Object canonicalize(java.lang.Object input,
                                        boolean isAttribute)
Sets up maximum or minimum permissible value. The format is UUUmm.nn or mm.nn. If value is in UUUmm.nn format the currency code UUU is ignored and the default currency code or the supplied currency code is assumed.

Overrides:
canonicalize in class BaseModel
Parameters:
input - The maximum or minimum amount, either in UUUmm.nn or mm.nn format
isAttribute - Whether the input is passed via a tag attribute
Returns:
formatted maximum or minimum value in mm.nn format

validate

protected java.lang.Boolean validate(java.lang.Object newValue,
                                     boolean setErrorCode)
Validates the amount value against the given constraints

Overrides:
validate in class BaseModel
Returns:
TRUE if valid, FALSE otherwise


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.