decode / valueOf / toString methods.
This is not meant to be used as system PropertyEditor but rather as locale-specific number editor within custom controller code, parsing user-entered number strings into Number properties of beans and rendering them in the UI form.
In web MVC code, this editor will typically be registered with
binder.registerCustomEditor calls.
Number, java.text.NumberFormat , org.springframework.validation.DataBinder#registerCustomEditor
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Class | |
| private final NumberFormat |
| Access | Constructor and Description |
|---|---|
| public | CustomNumberEditor(Class<? extends Number>
the Number subclass to generate numberClass, boolean if empty strings should be allowed allowEmpty)Create a new CustomNumberEditor instance, using the default
|
| public | CustomNumberEditor(Class<? extends Number>
the Number subclass to generate numberClass, NumberFormat the NumberFormat to use for parsing and rendering numberFormat, boolean if empty strings should be allowed allowEmpty)Create a new CustomNumberEditor instance, using the given NumberFormat for parsing and rendering. |
| Modifier and Type | Method and Description |
|---|---|
| public String | getAsText()
Overrides java. Implements java. Format the Number as String, using the specified NumberFormat. |
| public void | setAsText(String
The string to be parsed. text)Overrides java. Implements java. Parse the Number from the given text, using the specified NumberFormat. |
| public void | setValue(Object
The new target object to be edited. Note that this
object should not be modified by the PropertyEditor, rather
the PropertyEditor should create a new object to hold any
modified value. value)Overrides java. Implements java. Coerce a Number value into the required target class, if necessary. |
| allowEmpty | back to summary |
|---|---|
| private final boolean allowEmpty | |
| numberClass | back to summary |
|---|---|
| private final Class<? extends Number> numberClass | |
| numberFormat | back to summary |
|---|---|
| private final NumberFormat numberFormat
| |
| CustomNumberEditor | back to summary |
|---|---|
| public CustomNumberEditor(Class<? extends Number> numberClass, boolean allowEmpty) throws IllegalArgumentException Create a new CustomNumberEditor instance, using the default
The "allowEmpty" parameter states if an empty String should
be allowed for parsing, i.e. get interpreted as
| |
| CustomNumberEditor | back to summary |
|---|---|
| public CustomNumberEditor(Class<? extends Number> numberClass, NumberFormat numberFormat, boolean allowEmpty) throws IllegalArgumentException Create a new CustomNumberEditor instance, using the given NumberFormat for parsing and rendering. The allowEmpty parameter states if an empty String should
be allowed for parsing, i.e. get interpreted as
| |
| getAsText | back to summary |
|---|---|
| public String getAsText() Overrides java. Implements java. Format the Number as String, using the specified NumberFormat.
| |
| setAsText | back to summary |
|---|---|
| public void setAsText(String text) throws IllegalArgumentException Overrides java. Implements java. Parse the Number from the given text, using the specified NumberFormat.
| |
| setValue | back to summary |
|---|---|
| public void setValue(Object value) Overrides java. Implements java. Coerce a Number value into the required target class, if necessary.
| |