com.ibm.xsp.convert
Class NumberConverter

java.lang.Object
  extended by javax.faces.convert.NumberConverter
      extended by com.ibm.xsp.convert.NumberConverter
All Implemented Interfaces:
ClientSideConverter, javax.faces.component.StateHolder, javax.faces.convert.Converter

public class NumberConverter
extends javax.faces.convert.NumberConverter
implements ClientSideConverter

The xp:convertNumber tag extends the default number converter.


Field Summary
static java.lang.String CONVERTER_ID
          The converter id for this converter.
 
Constructor Summary
NumberConverter()
           
 
Method Summary
protected  javax.faces.convert.Converter createConverter(javax.faces.context.FacesContext context, java.lang.Class<?> resultType)
          When converting to a new type, gets the appropriate converter or catches any conversion errors.
protected  java.lang.Object decodeCurrencyCode(javax.faces.context.FacesContext context, java.lang.String valueStr)
           
protected  java.lang.String decodeExtensionPatternValue(javax.faces.context.FacesContext context, java.lang.String value)
          Removes the IBM pattern extension characters from the value.
protected  java.lang.String encodeCurrencyCode(java.lang.Object value)
           
protected  java.lang.String encodeExtensionPatternValue(java.lang.Object value, java.lang.String objectAsString)
          Adds the IBM pattern extension characters to the value.
 java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Generate client side conversion.
 java.lang.Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String value)
          Return value as an object
 java.lang.String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Return value as a string
protected  char getDecimalSeparator()
          Return character used as decimal separator
 java.util.Locale getLocale()
          Return the Locale to be used when parsing or formatting numbers.
 java.lang.String getPatternExtension()
          Return the pattern extension
protected  char getThousandSeparator()
          Return character used as thousand separator
protected  boolean isCurrencyCodeSet()
          Return true if the currency code has been set using setCurrencyCode(String)
protected  boolean isCurrencySymbolSet()
          Return true if the currency symbol has been set using setCurrencySymbol(String)
protected  boolean isGroupingUsedSet()
          Return true if grouping separators has been set using setGroupingUsed(boolean)
protected  boolean isIntegerOnlySet()
          Return true if integer only has been set using setIntegerOnly(boolean)
protected  boolean isLocaleSet()
          Return true if locale has been set using setLocale(Locale)
protected  boolean isMaxFractionDigitsSet()
          Return true if the maximum number of digits (formatted within a fraction) has been set using setMaxFractionDigits(int)
protected  boolean isMaxIntegerDigitsSet()
          Return true if the maximum number of digits (formatted within a integer) has been set using setMaxIntegerDigits(int)
protected  boolean isMinFractionDigitsSet()
          Return true if the minimum number of digits (formatted within a fraction) has been set using setMinFractionDigits(int)
protected  boolean isMinIntegerDigitsSet()
          Return true if the minimum number of digits (formatted within a integer) has been set using setMinIntegerDigits(int)
protected  boolean isPatternExtensionSet()
          Return true if the pattern extension has been set using setPatternExtension(String)
protected  boolean isPatternSet()
          Return true if the user-defined numeric pattern has been set using setPattern(String)
protected  boolean isTypeSet()
          Return true if the number type has been set using setType(String)
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setCurrencyCode(java.lang.String currencyCode)
          Specifies the currency code to use when converting the value to a currency format.
 void setCurrencySymbol(java.lang.String currencySymbol)
          Specifies the currency symbol to use when formatting currencies.
 void setGroupingUsed(boolean groupingUsed)
          Specifies whether the converted value will contain grouping separators
 void setIntegerOnly(boolean integerOnly)
          Specifies whether only the integer part of the value string will be formatted and parsed, regardless of data type
 void setLocale(java.util.Locale locale)
          Specifies a locale to use when formatting and parsing styles for numbers.
 void setMaxFractionDigits(int maxFractionDigits)
          Specifies the maximum number of digits that will be formatted in the fractional portion of the number
 void setMaxIntegerDigits(int maxIntegerDigits)
          Specifies the maximum number of digits that will be formatted in the integer portion of the number
 void setMinFractionDigits(int minFractionDigits)
          Specifies the minimum number of digits that will be formatted in the fractional portion of the number
 void setMinIntegerDigits(int minIntegerDigits)
          Specifies the minimum number of digits that will be formatted in the integer portion of the number
 void setPattern(java.lang.String pattern)
          Specifies the user-defined pattern that determines how the number string should be formatted and parsed.
 void setPatternExtension(java.lang.String patternExtension)
          Set the pattern extension
 void setType(java.lang.String type)
          Specifies how the number string will be formatted and parsed.
 
Methods inherited from class javax.faces.convert.NumberConverter
getCurrencyCode, getCurrencySymbol, getMaxFractionDigits, getMaxIntegerDigits, getMinFractionDigits, getMinIntegerDigits, getPattern, getType, isGroupingUsed, isIntegerOnly, isTransient, setTransient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERTER_ID

public static final java.lang.String CONVERTER_ID
The converter id for this converter.

See Also:
Constant Field Values
Constructor Detail

NumberConverter

public NumberConverter()
Method Detail

getAsString

public java.lang.String getAsString(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.Object value)
Return value as a string

Specified by:
getAsString in interface javax.faces.convert.Converter
Overrides:
getAsString in class javax.faces.convert.NumberConverter

getAsObject

public java.lang.Object getAsObject(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.String value)
Return value as an object

Specified by:
getAsObject in interface javax.faces.convert.Converter
Overrides:
getAsObject in class javax.faces.convert.NumberConverter

generateClientSideConverter

public java.lang.String generateClientSideConverter(javax.faces.context.FacesContext context,
                                                    javax.faces.component.UIComponent component)
                                             throws java.io.IOException
Description copied from interface: ClientSideConverter
Generate client side conversion.

Specified by:
generateClientSideConverter in interface ClientSideConverter
Throws:
java.io.IOException

getDecimalSeparator

protected char getDecimalSeparator()
Return character used as decimal separator


getThousandSeparator

protected char getThousandSeparator()
Return character used as thousand separator


isPatternExtensionSet

protected boolean isPatternExtensionSet()
Return true if the pattern extension has been set using setPatternExtension(String)


getPatternExtension

public java.lang.String getPatternExtension()
Return the pattern extension


setPatternExtension

public void setPatternExtension(java.lang.String patternExtension)
Set the pattern extension


getLocale

public java.util.Locale getLocale()
Return the Locale to be used when parsing or formatting numbers. If not set using setLocale(Locale), the root component locale is returned.

Overrides:
getLocale in class javax.faces.convert.NumberConverter

setCurrencyCode

public void setCurrencyCode(java.lang.String currencyCode)
Specifies the currency code to use when converting the value to a currency format. Valid values are ISO 4217 currency codes, e.g. USD for US Dollars.

Overrides:
setCurrencyCode in class javax.faces.convert.NumberConverter

setCurrencySymbol

public void setCurrencySymbol(java.lang.String currencySymbol)
Specifies the currency symbol to use when formatting currencies. This is a 'hardcoded' value in that it will override the value which would have been used based on the Locale.

Overrides:
setCurrencySymbol in class javax.faces.convert.NumberConverter

setGroupingUsed

public void setGroupingUsed(boolean groupingUsed)
Specifies whether the converted value will contain grouping separators

Overrides:
setGroupingUsed in class javax.faces.convert.NumberConverter

setIntegerOnly

public void setIntegerOnly(boolean integerOnly)
Specifies whether only the integer part of the value string will be formatted and parsed, regardless of data type

Overrides:
setIntegerOnly in class javax.faces.convert.NumberConverter

setLocale

public void setLocale(java.util.Locale locale)
Specifies a locale to use when formatting and parsing styles for numbers. Value can be a string or an expression that evaluates to a locale data type.

Overrides:
setLocale in class javax.faces.convert.NumberConverter

setMaxFractionDigits

public void setMaxFractionDigits(int maxFractionDigits)
Specifies the maximum number of digits that will be formatted in the fractional portion of the number

Overrides:
setMaxFractionDigits in class javax.faces.convert.NumberConverter

setMaxIntegerDigits

public void setMaxIntegerDigits(int maxIntegerDigits)
Specifies the maximum number of digits that will be formatted in the integer portion of the number

Overrides:
setMaxIntegerDigits in class javax.faces.convert.NumberConverter

setMinFractionDigits

public void setMinFractionDigits(int minFractionDigits)
Specifies the minimum number of digits that will be formatted in the fractional portion of the number

Overrides:
setMinFractionDigits in class javax.faces.convert.NumberConverter

setMinIntegerDigits

public void setMinIntegerDigits(int minIntegerDigits)
Specifies the minimum number of digits that will be formatted in the integer portion of the number

Overrides:
setMinIntegerDigits in class javax.faces.convert.NumberConverter

setPattern

public void setPattern(java.lang.String pattern)
Specifies the user-defined pattern that determines how the number string should be formatted and parsed. Choosing the custom data type allows users to specify a pattern. Patterns conform to the Java NumberFormat class.

Overrides:
setPattern in class javax.faces.convert.NumberConverter

setType

public void setType(java.lang.String type)
Specifies how the number string will be formatted and parsed. Valid values are 'Decimal', 'Currency', 'Percent' and 'Custom'.

Overrides:
setType in class javax.faces.convert.NumberConverter

isCurrencyCodeSet

protected boolean isCurrencyCodeSet()
Return true if the currency code has been set using setCurrencyCode(String)


isCurrencySymbolSet

protected boolean isCurrencySymbolSet()
Return true if the currency symbol has been set using setCurrencySymbol(String)


isGroupingUsedSet

protected boolean isGroupingUsedSet()
Return true if grouping separators has been set using setGroupingUsed(boolean)


isIntegerOnlySet

protected boolean isIntegerOnlySet()
Return true if integer only has been set using setIntegerOnly(boolean)


isLocaleSet

protected boolean isLocaleSet()
Return true if locale has been set using setLocale(Locale)


isMaxFractionDigitsSet

protected boolean isMaxFractionDigitsSet()
Return true if the maximum number of digits (formatted within a fraction) has been set using setMaxFractionDigits(int)


isMaxIntegerDigitsSet

protected boolean isMaxIntegerDigitsSet()
Return true if the maximum number of digits (formatted within a integer) has been set using setMaxIntegerDigits(int)


isMinFractionDigitsSet

protected boolean isMinFractionDigitsSet()
Return true if the minimum number of digits (formatted within a fraction) has been set using setMinFractionDigits(int)


isMinIntegerDigitsSet

protected boolean isMinIntegerDigitsSet()
Return true if the minimum number of digits (formatted within a integer) has been set using setMinIntegerDigits(int)


isPatternSet

protected boolean isPatternSet()
Return true if the user-defined numeric pattern has been set using setPattern(String)


isTypeSet

protected boolean isTypeSet()
Return true if the number type has been set using setType(String)


decodeExtensionPatternValue

protected java.lang.String decodeExtensionPatternValue(javax.faces.context.FacesContext context,
                                                       java.lang.String value)
Removes the IBM pattern extension characters from the value.


createConverter

protected javax.faces.convert.Converter createConverter(javax.faces.context.FacesContext context,
                                                        java.lang.Class<?> resultType)
When converting to a new type, gets the appropriate converter or catches any conversion errors.


encodeCurrencyCode

protected java.lang.String encodeCurrencyCode(java.lang.Object value)

decodeCurrencyCode

protected java.lang.Object decodeCurrencyCode(javax.faces.context.FacesContext context,
                                              java.lang.String valueStr)

encodeExtensionPatternValue

protected java.lang.String encodeExtensionPatternValue(java.lang.Object value,
                                                       java.lang.String objectAsString)
Adds the IBM pattern extension characters to the value.


restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.convert.NumberConverter

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.convert.NumberConverter