Top Description Fields Constructors Methods
org.springframework.beans.propertyeditors

public Class CharacterEditor

extends PropertyEditorSupport
Class Inheritance
Imports
java.beans.PropertyEditorSupport, org.springframework.lang.Nullable, org.springframework.util.StringUtils

Editor for a 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! org.springframework.beans.BeanWrapperImpl will register this editor by default.

Also supports conversion from a Unicode character sequence; e.g. u0041 ('A').

Authors
Juergen Hoeller, Rob Harrop, Rick Evans
Since
1.2
See Also
Character, org.springframework.beans.BeanWrapperImpl

Field Summary

Modifier and TypeField and Description
private final boolean
private static final int
UNICODE_LENGTH

The length of a Unicode character sequence.

private static final String
UNICODE_PREFIX

The prefix that identifies a string as being a Unicode character sequence.

Constructor Summary

AccessConstructor and Description
public
CharacterEditor(boolean
if empty strings are to be allowed
allowEmpty
)

Create a new CharacterEditor instance.

Method Summary

Modifier and TypeMethod and Description
public String
getAsText()

Overrides java.beans.PropertyEditorSupport.getAsText.

Implements java.beans.PropertyEditor.getAsText.

Gets the property value as a string suitable for presentation to a human to edit.
private boolean
public void
setAsText(String
The string to be parsed.
text
)

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Sets the property value by parsing a given String.
private void
Inherited from java.beans.PropertyEditorSupport:
addPropertyChangeListenerfirePropertyChangegetCustomEditorgetJavaInitializationStringgetSourcegetTagsgetValueisPaintablepaintValueremovePropertyChangeListenersetSourcesetValuesupportsCustomEditor

Field Detail

allowEmptyback to summary
private final boolean allowEmpty
UNICODE_LENGTHback to summary
private static final int UNICODE_LENGTH

The length of a Unicode character sequence.

UNICODE_PREFIXback to summary
private static final String UNICODE_PREFIX

The prefix that identifies a string as being a Unicode character sequence.

Constructor Detail

CharacterEditorback to summary
public CharacterEditor(boolean allowEmpty)

Create a new CharacterEditor instance.

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.

Parameters
allowEmpty:boolean

if empty strings are to be allowed

Method Detail

getAsTextback to summary
public String getAsText()

Overrides java.beans.PropertyEditorSupport.getAsText.

Implements java.beans.PropertyEditor.getAsText.

Doc from java.beans.PropertyEditorSupport.getAsText.

Gets the property value as a string suitable for presentation to a human to edit.

Returns:String

The property value as a string suitable for presentation to a human to edit.

Returns null if the value can't be expressed as a string.

If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().

Annotations
@Override
isUnicodeCharacterSequenceback to summary
private boolean isUnicodeCharacterSequence(String sequence)
setAsTextback to summary
public void setAsText(String text) throws IllegalArgumentException

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Doc from java.beans.PropertyEditorSupport.setAsText.

Sets the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Parameters
text:String

The string to be parsed.

Annotations
@Override
setAsUnicodeback to summary
private void setAsUnicode(String text)