Converter
implementation for java.lang.Number values.
The getAsObject() method parses a String into an
java.lang.Double or java.lang.Long, according
to the following algorithm:
null. Otherwise, trim leading and trailing
whitespace before proceeding.null.locale property is not null,
use that Locale for managing parsing. Otherwise, use the
Locale from the UIViewRoot.pattern has been specified, its syntax must conform
the rules specified by java.text.DecimalFormat. Such
a pattern will be used to parse, and the type property
will be ignored.pattern has not been specified, parsing will be based
on the type property, which expects a currency, a number,
or a percent. The parse pattern for currencies, numbers, and
percentages is determined by calling the
getCurrencyInstance(), getNumberInstance(),
or getPercentInstance() method of the
java.text.NumberFormat class, passing in the selected
Locale.integerOnly property has been set to true, only
the integer portion of the String will be parsed. See the JavaDocs
for the setParseIntegerOnly() method of the
java.text.NumberFormat class for more information.The getAsString() method expects a value of type
java.lang.Number (or a subclass), and creates a formatted
String according to the following algorithm:
locale property is not null,
use that Locale for managing formatting. Otherwise, use the
Locale from the FacesContext.pattern has been specified, its syntax must conform
the rules specified by java.text.DecimalFormat. Such
a pattern will be used to format, and the type property
(along with related formatting options described in the next paragraph)
will be ignored.pattern has not been specified, formatting will be
based on the type property, which formats the value as a
currency, a number, or a percent. The format pattern for currencies,
numbers, and percentages is determined by calling the
percentages is determined by calling the
getCurrencyInstance(), getNumberInstance(),
or getPercentInstance() method of the
java.text.NumberFormat class, passing in the selected
Locale. In addition, the following properties will be
applied to the format pattern, if specified:
groupingUsed property is true, the
setGroupingUsed(true) method on the corresponding
NumberFormat instance will be called.maxFractionDigits,
maxIntegerDigits, minFractionDigits,
and minIntegerDigits properties.currency, it is also possible
to configure the currency symbol to be used, using either the
currencyCode or currencySymbol properties.
If both are set, the value for currencyCode takes
precedence on a JDK 1.4 (or later) JVM; otherwise, the value
for currencySymbol takes precedence.| Modifier and Type | Field and Description |
|---|---|
| public static final String | CONVERTER_ID
The standard converter id for this converter. |
| public static final String | CURRENCY_ID
The message identifier of the |
| private static Class | |
| private String | |
| private String | |
| private static final Class | |
| private Boolean | |
| private boolean | |
| private Boolean | |
| private Locale | |
| private Integer | |
| private Integer | |
| private Integer | |
| private Integer | |
| private static final String | |
| public static final String | NUMBER_ID
The message identifier of the |
| private String | |
| public static final String | PATTERN_ID
The message identifier of the |
| public static final String | PERCENT_ID
The message identifier of the |
| public static final String | STRING_ID
The message identifier of the |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clearInitialState()
Implements javax. Reset the PartialStateHolder to a non-delta tracking state. |
| private void | configureCurrency(NumberFormat
The formatter)NumberFormatter to be configuredOverride the formatting locale's default currency symbol with the specified currency code (specified via the "currencyCode" attribute) or currency symbol (specified via the "currencySymbol" attribute). |
| private void | configureFormatter(NumberFormat
The formatter)NumberFormat instance to configureConfigure the specified |
| public Object | getAsObject(FacesContext
FacesContext for the request being processedUIComponent with which this model object
value is associatedString value to be converted (may be value)null)Implements javax. Convert the specified string value, which is associated with
the specified |
| public String | getAsString(FacesContext
FacesContext for the request being processedUIComponent with which this model object
value is associatedModel object value to be converted
(may be value)null)Implements javax. Convert the specified model object value, which is associated with
the specified |
| public String | Returns: the currency codeReturn the ISO 4217 currency code used by |
| public String | Returns: the currency symbolReturn the currency symbol used by |
| public Locale | |
| private Locale | getLocale(FacesContext
The context)FacesContext for the current requestReturn the |
| public int | Returns: the maximum fraction digitsReturn the maximum number of digits |
| public int | Returns: the max integer digitsReturn the maximum number of digits |
| public int | Returns: the min fraction digitsReturn the minimum number of digits |
| public int | Returns: the minimum integer digitsReturn the minimum number of digits |
| private NumberFormat | getNumberFormat(Locale
The locale)Locale used to select formatting
and parsing conventionsReturn a |
| public String | Returns: the patternReturn the format pattern to be used when formatting and parsing numbers. |
| public String | |
| public boolean | initialStateMarked()
Implements javax.
Return |
| public boolean | Returns: whether or not grouping is usedReturn |
| public boolean | Returns: whether or not this is integer onlyReturn |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| public boolean | isTransient()
Implements javax. If true, the Object implementing this interface must not participate in state saving or restoring. |
| public void | markInitialState()
Implements javax.
The runtime must ensure that the |
| public void | restoreState(FacesContext
the Faces context. context, Object the state. state)Implements javax. Perform any processing required to restore the state from the entries in the state Object. |
| public Object | saveState(FacesContext
the Faces context. context)Implements javax. Gets the state of the instance as a
|
| public void | setCurrencyCode(String
The new currency code currencyCode)Set the ISO 4217 currency code used by |
| public void | setCurrencySymbol(String
The new currency symbol currencySymbol)Set the currency symbol used by |
| public void | setGroupingUsed(boolean
The new grouping used flag groupingUsed)Set the flag indicating whether |
| public void | setIntegerOnly(boolean
The new integer-only flag integerOnly)Set to |
| public void | |
| public void | setMaxFractionDigits(int
The new limit maxFractionDigits)Set the maximum number of digits |
| public void | setMaxIntegerDigits(int
The new limit maxIntegerDigits)Set the maximum number of digits |
| public void | setMinFractionDigits(int
The new limit minFractionDigits)Set the minimum number of digits |
| public void | setMinIntegerDigits(int
The new limit minIntegerDigits)Set the minimum number of digits |
| public void | setPattern(String
The new format pattern pattern)Set the format pattern to be used when formatting and parsing numbers. |
| public void | setTransient(boolean
boolean pass transientFlag)true if this
Object will not
participate in state saving or restoring, otherwise pass
false.Implements javax. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
| public void |
| CONVERTER_ID | back to summary |
|---|---|
| public static final String CONVERTER_ID The standard converter id for this converter. | |
| CURRENCY_ID | back to summary |
|---|---|
| public static final String CURRENCY_ID The message identifier of the
| |
| currencyClass | back to summary |
|---|---|
| private static Class<T> currencyClass | |
| currencyCode | back to summary |
|---|---|
| private String currencyCode | |
| currencySymbol | back to summary |
|---|---|
| private String currencySymbol | |
| GET_INSTANCE_PARAM_TYPES | back to summary |
|---|---|
| private static final Class<T>[] GET_INSTANCE_PARAM_TYPES | |
| groupingUsed | back to summary |
|---|---|
| private Boolean groupingUsed | |
| initialState | back to summary |
|---|---|
| private boolean initialState | |
| integerOnly | back to summary |
|---|---|
| private Boolean integerOnly | |
| locale | back to summary |
|---|---|
| private Locale locale | |
| maxFractionDigits | back to summary |
|---|---|
| private Integer maxFractionDigits | |
| maxIntegerDigits | back to summary |
|---|---|
| private Integer maxIntegerDigits | |
| minFractionDigits | back to summary |
|---|---|
| private Integer minFractionDigits | |
| minIntegerDigits | back to summary |
|---|---|
| private Integer minIntegerDigits | |
| NBSP | back to summary |
|---|---|
| private static final String NBSP | |
| NUMBER_ID | back to summary |
|---|---|
| public static final String NUMBER_ID The message identifier of the
| |
| pattern | back to summary |
|---|---|
| private String pattern | |
| PATTERN_ID | back to summary |
|---|---|
| public static final String PATTERN_ID The message identifier of the
| |
| PERCENT_ID | back to summary |
|---|---|
| public static final String PERCENT_ID The message identifier of the
| |
| STRING_ID | back to summary |
|---|---|
| public static final String STRING_ID The message identifier of the
| |
| transientFlag | back to summary |
|---|---|
| private boolean transientFlag | |
| type | back to summary |
|---|---|
| private String type | |
| NumberConverter | back to summary |
|---|---|
| public NumberConverter() | |
| clearInitialState | back to summary |
|---|---|
| public void clearInitialState() Implements javax. Doc from javax. Reset the PartialStateHolder to a non-delta tracking state.
| |
| configureCurrency | back to summary |
|---|---|
| private void configureCurrency(NumberFormat formatter) throws Exception Override the formatting locale's default currency symbol with the specified currency code (specified via the "currencyCode" attribute) or currency symbol (specified via the "currencySymbol" attribute).
If both "currencyCode" and "currencySymbol" are present, "currencyCode" takes precedence over "currencySymbol" if the java.util.Currency class is defined in the container's runtime (that is, if the container's runtime is J2SE 1.4 or greater), and "currencySymbol" takes precendence over "currencyCode" otherwise.
If only "currencyCode" is given, it is used as a currency symbol if java.util.Currency is not defined. Example:
| |
| configureFormatter | back to summary |
|---|---|
| private void configureFormatter(NumberFormat formatter) Configure the specified
| |
| getAsObject | back to summary |
|---|---|
| public Object getAsObject(FacesContext context, UIComponent component, String value) Implements javax. Doc from javax. Convert the specified string value, which is associated with
the specified
| |
| getAsString | back to summary |
|---|---|
| public String getAsString(FacesContext context, UIComponent component, Object value) Implements javax. Doc from javax. Convert the specified model object value, which is associated with
the specified
| |
| getCurrencyCode | back to summary |
|---|---|
| public String getCurrencyCode() Return the ISO 4217 currency code used by
| |
| getCurrencySymbol | back to summary |
|---|---|
| public String getCurrencySymbol() Return the currency symbol used by
| |
| getLocale | back to summary |
|---|---|
| public Locale getLocale() Return the
| |
| getLocale | back to summary |
|---|---|
| private Locale getLocale(FacesContext context) Return the
| |
| getMaxFractionDigits | back to summary |
|---|---|
| public int getMaxFractionDigits() Return the maximum number of digits
| |
| getMaxIntegerDigits | back to summary |
|---|---|
| public int getMaxIntegerDigits() Return the maximum number of digits
| |
| getMinFractionDigits | back to summary |
|---|---|
| public int getMinFractionDigits() Return the minimum number of digits
| |
| getMinIntegerDigits | back to summary |
|---|---|
| public int getMinIntegerDigits() Return the minimum number of digits
| |
| getNumberFormat | back to summary |
|---|---|
| private NumberFormat getNumberFormat(Locale locale) Return a
| |
| getPattern | back to summary |
|---|---|
| public String getPattern() Return the format pattern to be used when formatting and parsing numbers.
| |
| getType | back to summary |
|---|---|
| public String getType() Return the number type to be used when formatting and parsing numbers.
If not modified, the default type is
| |
| initialStateMarked | back to summary |
|---|---|
| public boolean initialStateMarked() Implements javax. Doc from javax.
Return
| |
| isGroupingUsed | back to summary |
|---|---|
| public boolean isGroupingUsed() Return
| |
| isIntegerOnly | back to summary |
|---|---|
| public boolean isIntegerOnly() Return
| |
| isMaxFractionDigitsSet | back to summary |
|---|---|
| private boolean isMaxFractionDigitsSet() | |
| isMaxIntegerDigitsSet | back to summary |
|---|---|
| private boolean isMaxIntegerDigitsSet() | |
| isMinFractionDigitsSet | back to summary |
|---|---|
| private boolean isMinFractionDigitsSet() | |
| isMinIntegerDigitsSet | back to summary |
|---|---|
| private boolean isMinIntegerDigitsSet() | |
| isTransient | back to summary |
|---|---|
| public boolean isTransient() Implements javax. Doc from javax. If true, the Object implementing this interface must not participate in state saving or restoring.
| |
| markInitialState | back to summary |
|---|---|
| public void markInitialState() Implements javax. Doc from javax.
The runtime must ensure that the
| |
| restoreState | back to summary |
|---|---|
| public void restoreState(FacesContext context, Object state) Implements javax. Doc from javax. Perform any processing required to restore the state from the entries in the state Object. If the class that implements this interface has references to
instances that also implement StateHolder (such as a
If the
| |
| saveState | back to summary |
|---|---|
| public Object saveState(FacesContext context) Implements javax. Doc from javax. Gets the state of the instance as a
If the class that implements this interface has references to
instances that implement StateHolder (such as a
This method must not alter the state of the implementing object. In other words, after executing this code:
The return from this method must be
| |
| setCurrencyCode | back to summary |
|---|---|
| public void setCurrencyCode(String currencyCode) Set the ISO 4217 currency code used by
| |
| setCurrencySymbol | back to summary |
|---|---|
| public void setCurrencySymbol(String currencySymbol) Set the currency symbol used by
| |
| setGroupingUsed | back to summary |
|---|---|
| public void setGroupingUsed(boolean groupingUsed) Set the flag indicating whether
| |
| setIntegerOnly | back to summary |
|---|---|
| public void setIntegerOnly(boolean integerOnly) Set to
| |
| setLocale | back to summary |
|---|---|
| public void setLocale(Locale locale) Set the
| |
| setMaxFractionDigits | back to summary |
|---|---|
| public void setMaxFractionDigits(int maxFractionDigits) Set the maximum number of digits
| |
| setMaxIntegerDigits | back to summary |
|---|---|
| public void setMaxIntegerDigits(int maxIntegerDigits) Set the maximum number of digits
| |
| setMinFractionDigits | back to summary |
|---|---|
| public void setMinFractionDigits(int minFractionDigits) Set the minimum number of digits
| |
| setMinIntegerDigits | back to summary |
|---|---|
| public void setMinIntegerDigits(int minIntegerDigits) Set the minimum number of digits
| |
| setPattern | back to summary |
|---|---|
| public void setPattern(String pattern) Set the format pattern to be used when formatting and parsing
numbers. Valid values are those supported by
| |
| setTransient | back to summary |
|---|---|
| public void setTransient(boolean transientFlag) Implements javax. Doc from javax. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
| |
| setType | back to summary |
|---|---|
| public void setType(String type) Set the number type to be used when formatting and parsing numbers.
Valid values are
| |