@JSFConverter(configExcluded=true)
public class NumberConverter
extends javax.faces.convert.NumberConverter
NumberConverter
 The converter provides all the standard functionality
 of the default NumberConverter and is strict while converting to object.
 JSF NumberConverter is lenient and will convert
 values like 22.22.2 or 22ABC to valid number 22.22 and 22 respectively,
 here it would result in a conversion failure and would throw
 ConverterException.
 If number grouping separator, decimal separator
 is configured in trinidad-config.xml file,
 it will be used during call to getAsObject() and
 getAsString() for parsing and formatting. If it has not been set,
 number grouping separator, decimal separator is
 defaulted based on the locale.
 If currencyCode is set on the converter then it will be used.
 Else uses the currencyCode set on trinidad-config.xml
 file. If it is not set, then it is defaulted based on the locale. The
 value registered in trinidad-config.xml is obtained using
 api from RequestContext.
Since Apache Trinidad is compatible only with JDK 1.4 and higher versions,
 the currencyCode gets preference over currencySymbol
 See RI's NumberConverter for the way in which
 currencyCode and currencySymbol gets preference for
 different version of JDK.
The detail part of the FacesMessage can be customized.
 For each message id there is a corresponding
 setter method, which provides for message customization. The customized
 messages can contain placeholders as specified in the documentation
 for its corresponding message id.
Example: to customize the message for invalid input values, which will result
 in conversion error containing CONVERT_NUMBER_MESSAGE_ID, the following,
 can be done.
 String convertNumberMessageDetail = "{0}" in "{1}" is not valid age.
 //  Note that, the string can contain placeholders and it will be replaced
 //  appropriately as specified in the documentation for the corresponding
 //  message id.
 setMessageDetailConvertNumber(convertNumberMessageDetail);
 This way user can override detail part of the FacesMessage for
 different conversion errors that occur for wrong values, that arise
 during conversion.
 There is a one to one mapping for message customization which is as given below. The methods used for customizing the detail message associated with each id is given below:
 - CONVERT_PATTERN_MESSAGE_ID-- setMessageDetailConvertPattern(String)
- CONVERT_NUMBER_MESSAGE_ID-- setMessageDetailConvertNumber(String)
- CONVERT_CURRENCY_MESSAGE_ID-- setMessageDetailConvertCurrency(String)
- CONVERT_PERCENT_MESSAGE_ID-- setMessageDetailConvertPercent(String)
 This NumberConverter is automatically registered under the standard
 converter ID, and therefore will be used when the
 <f:convertNumber> tag is used.
| Modifier and Type | Field and Description | 
|---|---|
| static String | CONVERT_CURRENCY_MESSAGE_IDThe message identifier of the  FacesMessageto be created if the input value is not a valid number whentypeis set to'currency'. | 
| static String | CONVERT_NUMBER_MESSAGE_IDThe message identifier of the  FacesMessageto be created if the input value is not a valid number. | 
| static String | CONVERT_PATTERN_MESSAGE_IDThe message identifier of the  FacesMessageto be created if the input value does not match the specified pattern. | 
| static String | CONVERT_PERCENT_MESSAGE_IDThe message identifier of the  FacesMessageto be created if the input value is not a valid number whentypeis set to'percent'. | 
| static String | CONVERTER_IDThe standard converter id for this converter. | 
| Constructor and Description | 
|---|
| NumberConverter() | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | equals(Object numberConverter)Compares this NumberConverter with the specified Object for equality. | 
| Object | getAsObject(javax.faces.context.FacesContext context,
           javax.faces.component.UIComponent component,
           String value)Performs strict conversion of string to number. | 
| String | getAsString(javax.faces.context.FacesContext context,
           javax.faces.component.UIComponent component,
           Object value) | 
| protected javax.faces.application.FacesMessage | getConvertMessage(javax.faces.context.FacesContext context,
                 javax.faces.component.UIComponent component,
                 String inputValue,
                 Object[] params) | 
| String | getCurrencyCode() | 
| String | getCurrencySymbol() | 
| String | getHintPattern()Return custom hintPattern message. | 
| Locale | getLocale()Return the  Localethat was set, returns null if it was not set,
 while faces RI returns theLocaleset on the view root if the locale
 is null. | 
| String | getLocalizedPattern(javax.faces.context.FacesContext context,
                   String pattern,
                   DecimalFormatSymbols dfs)If  patterncontains the generic currency sign, this method will replace it 
 with the localized currency symbol (if one exists). | 
| int | getMaxFractionDigits() | 
| int | getMaxIntegerDigits() | 
| String | getMessageDetailConvertCurrency()Return custom detail error message that was set for creating  FacesMessage,
 when conversion fails for values, whentypeis set to'currency'andpatternis null or not set. | 
| String | getMessageDetailConvertNumber()Return custom detail error message that was set for creating  FacesMessage,
 when conversion fails for values, whentypeis set to'number'andpatternis null or not set. | 
| String | getMessageDetailConvertPattern()Custom detail error message that was set for creation of  FacesMessagewhen conversion fails for values that does not match the pattern set. | 
| String | getMessageDetailConvertPercent()Return custom detail error message that was set for creating  FacesMessage,
 when conversion fails for values, whenvaluecannot be converted to a
 number, whentypeis set to'percent'andpatternis null or not set. | 
| int | getMinFractionDigits() | 
| int | getMinIntegerDigits() | 
| String | getNegativePrefix()Gets the negative prefix that is applied on the number. | 
| String | getNegativeSuffix()Gets the negative suffix that is applied on the number. | 
| String | getPattern() | 
| RoundingMode | getRoundingMode() | 
| String | getType() | 
| javax.faces.el.ValueBinding | getValueBinding(String name)Deprecated.   | 
| javax.el.ValueExpression | getValueExpression(String name)Return the  ValueExpressionused to calculate the value for the
 specified attribute name, if any. | 
| int | hashCode()Returns the hash code for this Converter. | 
| boolean | isDisabled()Return whether it is disabled. | 
| boolean | isGroupingUsed() | 
| boolean | isIntegerOnly() | 
| boolean | isMaximumFractionDigitsSet()Return true if the maximum fraction digits have been set. | 
| boolean | isMaximumIntegerDigitsSet()Return true if the maximum integer digits have been set. | 
| boolean | isMinimumFractionDigitsSet()Return true if the minimum fraction digits have been set. | 
| boolean | isMinimumIntegerDigitsSet()Return true if the minimum integer digits have been set. | 
| boolean | isNegativePrefixSet()Return true if a non-null negative prefix has been set via  setNegativePrefix(String). | 
| boolean | isNegativeSuffixSet()Return true if a non-null negative suffix has been set via  setNegativeSuffix(String). | 
| boolean | isRoundingModeSet()Return true if a non-null rounding mode has been set via  setRoundingMode(RoundingMode). | 
| void | restoreState(javax.faces.context.FacesContext context,
            Object state) | 
| Object | saveState(javax.faces.context.FacesContext context) | 
| void | setCurrencyCode(String currencyCode) | 
| void | setCurrencySymbol(String currencySymbol) | 
| void | setDisabled(boolean isDisabled)Set the value to property  disabled. | 
| void | setGroupingUsed(boolean groupingUsed) | 
| void | setHintPattern(String hintPattern)Custom hintPattern message. | 
| void | setIntegerOnly(boolean integerOnly) | 
| void | setLocale(Locale locale)Set the  Localeto be used when parsing numbers. | 
| void | setMaxFractionDigits(int maxFractionDigits) | 
| void | setMaxIntegerDigits(int maxIntegerDigits) | 
| void | setMessageDetailConvertCurrency(String convertCurrencyMessageDetail)Custom error message to be used, for creating detail part of the
  FacesMessage,  whenvaluecannot be converted to a number, whentypeis set to'currency'andpatternis null or not set. | 
| void | setMessageDetailConvertNumber(String convertNumberMessageDetail)Custom error message to be used, for creating detail part of the  FacesMessage,
 whenvaluecannot be converted to a number,
 whentypeis set to'number'andpatternis null or not set. | 
| void | setMessageDetailConvertPattern(String convertPatternMessageDetail)Custom error message to be used, for creating detail part of the  FacesMessage,
 message, whenvaluecannot be converted to a number,
 based on thepatternset. | 
| void | setMessageDetailConvertPercent(String convertPercentMessageDetail)Custom error message to be used, for creating detail part of the
  FacesMessage, whenvaluecannot be converted to a
 number, whentypeis set to'percent'andpatternis null or not set. | 
| void | setMinFractionDigits(int minFractionDigits) | 
| void | setMinIntegerDigits(int minIntegerDigits) | 
| void | setNegativePrefix(String negPrefix)Sets the negative prefix on the converter. | 
| void | setNegativeSuffix(String negSuffix)Sets the negative suffix on the converter. | 
| void | setPattern(String pattern) | 
| void | setRoundingMode(RoundingMode mode) | 
| void | setType(String type) | 
| void | setValueBinding(String name,
               javax.faces.el.ValueBinding binding)Deprecated.   | 
| void | setValueExpression(String name,
                  javax.el.ValueExpression expression)Set the  ValueExpressionused to calculate the value for the
 specified attribute if any. | 
public static final String CONVERTER_ID
The standard converter id for this converter.
public static final String CONVERT_PATTERN_MESSAGE_ID
The message identifier of the FacesMessage
 to be created if the input value does not match the specified pattern.
 The message format string for this message may optionally
 include {0}, {1} and {4}
 placeholders, which will be replaced with the input value,
 label associated with the component and the pattern respectively.
public static final String CONVERT_NUMBER_MESSAGE_ID
The message identifier of the FacesMessage
 to be created if the input value is not a valid number.  The message format
 string for this message may optionally include {0} and
 {1} placeholders, which will be replaced with
 the input value and label associated with the component
 respectively.
public static final String CONVERT_CURRENCY_MESSAGE_ID
The message identifier of the FacesMessage
 to be created if the input value is not a valid number when type
 is set to 'currency'. The message format
 string for this message may optionally include {0} and
 {1} placeholders, which will be replaced with
 the input value and label associated with the component
 respectively.
public static final String CONVERT_PERCENT_MESSAGE_ID
The message identifier of the FacesMessage
 to be created if the input value is not a valid number when type
 is set to 'percent'. The message format
 string for this message may optionally include {0} and
 {1} placeholders, which will be replaced with
 the input value and label associated with the component
 respectively.
public Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String value)
22.22.22
 and values of the form 22ABC, 22%ABC will result in
 ConverterException.getAsObject in interface javax.faces.convert.ConvertergetAsObject in class javax.faces.convert.NumberConverterpublic String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)
getAsString in interface javax.faces.convert.ConvertergetAsString in class javax.faces.convert.NumberConvertercontext - FacesContext for the request being processedcomponent - UIComponent with which this model object
        value is associated.value - Model object value to be converted (may be null)null,
         if the passed value is a String, it's returned unchanged,
         otherwise String representation for the number object based on the
         attributes set.javax.faces.convert.ConverterException - if conversion cannot be successfully
            performedNullPointerException - if context or
            component is nullIllegalArgumentException - if the value is not of
            type other than Number, String.
            value can be null.public void restoreState(javax.faces.context.FacesContext context,
                Object state)
restoreState in interface javax.faces.component.StateHolderrestoreState in class javax.faces.convert.NumberConverterpublic Object saveState(javax.faces.context.FacesContext context)
saveState in interface javax.faces.component.StateHoldersaveState in class javax.faces.convert.NumberConverterpublic void setValueExpression(String name, javax.el.ValueExpression expression)
Set the ValueExpression used to calculate the value for the
 specified attribute if any.
name - Name of the attribute for which to set a ValueExpressionexpression - The ValueExpression to set, or null
  to remove any currently set ValueExpressionNullPointerException - if name
  is nullIllegalArgumentException - if name is not a valid
            attribute of this converterpublic javax.el.ValueExpression getValueExpression(String name)
Return the ValueExpression used to calculate the value for the
 specified attribute name, if any.
name - Name of the attribute or property for which to retrieve a
  ValueExpressionNullPointerException - if name
  is nullIllegalArgumentException - if name is not a valid
 attribute of this converterpublic void setValueBinding(String name, javax.faces.el.ValueBinding binding)
Set the ValueBinding used to calculate the value for the
 specified attribute if any.
name - Name of the attribute for which to set a ValueBindingbinding - The ValueBinding to set, or null
  to remove any currently set ValueBindingNullPointerException - if name
  is nullIllegalArgumentException - if name is not a valid
            attribute of this converterpublic javax.faces.el.ValueBinding getValueBinding(String name)
Return the ValueBinding used to calculate the value for the
 specified attribute name, if any.
name - Name of the attribute or property for which to retrieve a
  ValueBindingNullPointerException - if name
  is nullIllegalArgumentException - if name is not a valid
 attribute of this converterpublic void setMessageDetailConvertPattern(String convertPatternMessageDetail)
FacesMessage,
 message, when value cannot be converted to a number,
 based on the pattern set.
 Overrides detail message identified by message id CONVERT_PATTERN_MESSAGE_IDconvertPatternMessageDetail - Custom error message.@JSFProperty public String getMessageDetailConvertPattern()
FacesMessage
 when conversion fails for values that does not match the pattern set.setMessageDetailConvertPattern(String)public void setMessageDetailConvertNumber(String convertNumberMessageDetail)
Custom error message to be used, for creating detail part of the FacesMessage,
 when value cannot be converted to a number,
 when type is set to 'number' and
 pattern is null or not set.
CONVERT_NUMBER_MESSAGE_IDconvertNumberMessageDetail - custom error message.@JSFProperty public String getMessageDetailConvertNumber()
Return custom detail error message that was set for creating FacesMessage,
 when conversion fails for values, when type is set to 'number' and
 pattern is null or not set.
setMessageDetailConvertNumber(String)public void setMessageDetailConvertCurrency(String convertCurrencyMessageDetail)
FacesMessage,  when value
 cannot be converted to a number, when type is set to
 'currency' and pattern is null or not set.
 Overrides detail message identified by message id CONVERT_CURRENCY_MESSAGE_ID.convertCurrencyMessageDetail - custom error message.@JSFProperty public String getMessageDetailConvertCurrency()
Return custom detail error message that was set for creating FacesMessage,
 when conversion fails for values, when type is set to
 'currency' and pattern is null or not set.
setMessageDetailConvertCurrency(String)public void setMessageDetailConvertPercent(String convertPercentMessageDetail)
FacesMessage, when value cannot be converted to a
 number, when type is set to 'percent' and
 pattern is null or not set.
 Overrides detail message identified by message id CONVERT_PERCENT_MESSAGE_IDconvertPercentMessageDetail - custom error message.@JSFProperty public String getMessageDetailConvertPercent()
Return custom detail error message that was set for creating FacesMessage,
 when conversion fails for values, when value cannot be converted to a
 number, when type is set to 'percent'
 and pattern is null or not set.
setMessageDetailConvertPercent(String)public void setHintPattern(String hintPattern)
Custom hintPattern message.
Overrides default hint messagehintPattern - Custom hint message.public String getHintPattern()
Return custom hintPattern message.
setHintPattern(String)public void setCurrencyCode(String currencyCode)
setCurrencyCode in class javax.faces.convert.NumberConverter@JSFProperty public String getCurrencyCode()
getCurrencyCode in class javax.faces.convert.NumberConverterpublic void setCurrencySymbol(String currencySymbol)
setCurrencySymbol in class javax.faces.convert.NumberConverter@JSFProperty public String getCurrencySymbol()
getCurrencySymbol in class javax.faces.convert.NumberConverterpublic void setGroupingUsed(boolean groupingUsed)
setGroupingUsed in class javax.faces.convert.NumberConverter@JSFProperty(defaultValue="true") public boolean isGroupingUsed()
isGroupingUsed in class javax.faces.convert.NumberConverterpublic void setIntegerOnly(boolean integerOnly)
setIntegerOnly in class javax.faces.convert.NumberConverter@JSFProperty(defaultValue="false") public boolean isIntegerOnly()
isIntegerOnly in class javax.faces.convert.NumberConverterpublic void setLocale(Locale locale)
Set the Locale to be used when parsing numbers.
 If set to null, the Locale stored in the
 UIViewRoot for the current request
 will be utilized.
setLocale in class javax.faces.convert.NumberConverterlocale - The new Locale (or null)@JSFProperty public Locale getLocale()
Return the Locale that was set, returns null if it was not set,
 while faces RI returns the Locale set on the view root if the locale
 is null.
 If this value is null, the Locale stored
 in the UIViewRoot for the current request
 will be utilized during parsing.
getLocale in class javax.faces.convert.NumberConverterpublic void setMaxFractionDigits(int maxFractionDigits)
setMaxFractionDigits in class javax.faces.convert.NumberConverter@JSFProperty public int getMaxFractionDigits()
getMaxFractionDigits in class javax.faces.convert.NumberConverterpublic void setMaxIntegerDigits(int maxIntegerDigits)
setMaxIntegerDigits in class javax.faces.convert.NumberConverter@JSFProperty public int getMaxIntegerDigits()
getMaxIntegerDigits in class javax.faces.convert.NumberConverterpublic void setMinFractionDigits(int minFractionDigits)
setMinFractionDigits in class javax.faces.convert.NumberConverter@JSFProperty public int getMinFractionDigits()
getMinFractionDigits in class javax.faces.convert.NumberConverterpublic void setMinIntegerDigits(int minIntegerDigits)
setMinIntegerDigits in class javax.faces.convert.NumberConverter@JSFProperty public int getMinIntegerDigits()
getMinIntegerDigits in class javax.faces.convert.NumberConverterpublic void setRoundingMode(RoundingMode mode)
@JSFProperty public RoundingMode getRoundingMode()
public void setNegativePrefix(String negPrefix)
setPattern(String) or any other means.negPrefix - Prefix to be applied on negative number@JSFProperty public String getNegativePrefix()
setNegativePrefix(String).
 Negative prefix specified using negative pattern string has no affect on this method.setNegativePrefix(String) or nullpublic void setNegativeSuffix(String negSuffix)
setPattern(String) or any other means.negSuffix - Suffix to be applied on negative number@JSFProperty public String getNegativeSuffix()
setNegativeSuffix(String).
 Negative suffix specified using negative pattern string has no affect on this method.setNegativeSuffix(String) or nullpublic void setPattern(String pattern)
setPattern in class javax.faces.convert.NumberConverter@JSFProperty public String getPattern()
getPattern in class javax.faces.convert.NumberConverterpublic String getLocalizedPattern(javax.faces.context.FacesContext context, String pattern, DecimalFormatSymbols dfs)
pattern contains the generic currency sign, this method will replace it 
 with the localized currency symbol (if one exists).context - the FacesContextpattern - the pattern to be localizeddfs - the DecimalFormatSymbols; if null, will be constructed from the contextpublic void setType(String type)
setType in class javax.faces.convert.NumberConverter@JSFProperty(defaultValue="number") public String getType()
getType in class javax.faces.convert.NumberConverterpublic int hashCode()
public boolean equals(Object numberConverter)
Compares this NumberConverter with the specified Object for equality.
public void setDisabled(boolean isDisabled)
Set the value to property disabled. Default value is false.
isDisabled - true if it's disabled, false otherwise.public boolean isDisabled()
protected final javax.faces.application.FacesMessage getConvertMessage(javax.faces.context.FacesContext context,
                                                     javax.faces.component.UIComponent component,
                                                     String inputValue,
                                                     Object[] params)
public boolean isMaximumFractionDigitsSet()
public boolean isMinimumFractionDigitsSet()
public boolean isMaximumIntegerDigitsSet()
public boolean isMinimumIntegerDigitsSet()
public boolean isNegativePrefixSet()
setNegativePrefix(String). 
 If not set, return false;public boolean isNegativeSuffixSet()
setNegativeSuffix(String). 
 If not set, return false;public boolean isRoundingModeSet()
setRoundingMode(RoundingMode). 
 If not set, return false;Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.