public class CharacterEditor
extends java.beans.PropertyEditorSupport
Character
, to populate a property
of type Character
or char
from a String value.
Note that the JDK does not contain a default
property editor
for char
!
BeanWrapperImpl
will register this
editor by default.
Also supports conversion from a Unicode character sequence; e.g.
u0041
('A').
Character
,
BeanWrapperImpl
Modifier and Type | Field and Description |
---|---|
private boolean |
allowEmpty |
private static int |
UNICODE_LENGTH
The length of a Unicode character sequence.
|
private static java.lang.String |
UNICODE_PREFIX
The prefix that identifies a string as being a Unicode character sequence.
|
Constructor and Description |
---|
CharacterEditor(boolean allowEmpty)
Create a new CharacterEditor instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAsText() |
private boolean |
isUnicodeCharacterSequence(java.lang.String sequence) |
void |
setAsText(java.lang.String text) |
private void |
setAsUnicode(java.lang.String text) |
private static final java.lang.String UNICODE_PREFIX
private static final int UNICODE_LENGTH
private final boolean allowEmpty
public CharacterEditor(boolean allowEmpty)
The "allowEmpty" parameter controls whether an empty String is
to be allowed in parsing, i.e. be interpreted as the null
value when text is being converted
. If
false
, an IllegalArgumentException
will be thrown
at that time.
allowEmpty
- if empty strings are to be allowedpublic void setAsText(java.lang.String text) throws java.lang.IllegalArgumentException
setAsText
in interface java.beans.PropertyEditor
setAsText
in class java.beans.PropertyEditorSupport
java.lang.IllegalArgumentException
public java.lang.String getAsText()
getAsText
in interface java.beans.PropertyEditor
getAsText
in class java.beans.PropertyEditorSupport
private boolean isUnicodeCharacterSequence(java.lang.String sequence)
private void setAsUnicode(java.lang.String text)