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

public Class StringArrayPropertyEditor

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

Custom java.beans.PropertyEditor for String arrays.

Strings must be in CSV format, with a customizable separator. By default, values in the result are trimmed of whitespace.

Authors
Rod Johnson, Juergen Hoeller, Dave Syer
See Also
org.springframework.util.StringUtils#delimitedListToStringArray, org.springframework.util.StringUtils#arrayToDelimitedString

Field Summary

Modifier and TypeField and Description
private final String
public static final String
DEFAULT_SEPARATOR

Default separator for splitting a String: a comma (",").

private final boolean
private final String
private final boolean

Constructor Summary

AccessConstructor and Description
public
StringArrayPropertyEditor()

Create a new StringArrayPropertyEditor with the default separator (a comma).

public
StringArrayPropertyEditor(String
the separator to use for splitting a String
separator
)

Create a new StringArrayPropertyEditor with the given separator.

public
StringArrayPropertyEditor(String
the separator to use for splitting a String
separator
,
boolean
true if an empty String array is to be transformed into null
emptyArrayAsNull
)

Create a new StringArrayPropertyEditor with the given separator.

public
StringArrayPropertyEditor(String
the separator to use for splitting a String
separator
,
boolean
true if an empty String array is to be transformed into null
emptyArrayAsNull
,
boolean
true if the values in the parsed arrays are to be trimmed of whitespace (default is true)
trimValues
)

Create a new StringArrayPropertyEditor with the given separator.

public
StringArrayPropertyEditor(String
the separator to use for splitting a String
separator
,
String
a set of characters to delete, in addition to trimming an input String. Useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String.
charsToDelete
,
boolean
true if an empty String array is to be transformed into null
emptyArrayAsNull
)

Create a new StringArrayPropertyEditor with the given separator.

public
StringArrayPropertyEditor(String
the separator to use for splitting a String
separator
,
String
a set of characters to delete, in addition to trimming an input String. Useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String.
charsToDelete
,
boolean
true if an empty String array is to be transformed into null
emptyArrayAsNull
,
boolean
true if the values in the parsed arrays are to be trimmed of whitespace (default is true)
trimValues
)

Create a new StringArrayPropertyEditor with the given separator.

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.
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.
Inherited from java.beans.PropertyEditorSupport:
addPropertyChangeListenerfirePropertyChangegetCustomEditorgetJavaInitializationStringgetSourcegetTagsgetValueisPaintablepaintValueremovePropertyChangeListenersetSourcesetValuesupportsCustomEditor

Field Detail

charsToDeleteback to summary
private final String charsToDelete
Annotations
@Nullable
DEFAULT_SEPARATORback to summary
public static final String DEFAULT_SEPARATOR

Default separator for splitting a String: a comma (",").

emptyArrayAsNullback to summary
private final boolean emptyArrayAsNull
separatorback to summary
private final String separator
trimValuesback to summary
private final boolean trimValues

Constructor Detail

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor()

Create a new StringArrayPropertyEditor with the default separator (a comma).

An empty text (without elements) will be turned into an empty array.

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor(String separator)

Create a new StringArrayPropertyEditor with the given separator.

An empty text (without elements) will be turned into an empty array.

Parameters
separator:String

the separator to use for splitting a String

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull)

Create a new StringArrayPropertyEditor with the given separator.

Parameters
separator:String

the separator to use for splitting a String

emptyArrayAsNull:boolean

true if an empty String array is to be transformed into null

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull, boolean trimValues)

Create a new StringArrayPropertyEditor with the given separator.

Parameters
separator:String

the separator to use for splitting a String

emptyArrayAsNull:boolean

true if an empty String array is to be transformed into null

trimValues:boolean

true if the values in the parsed arrays are to be trimmed of whitespace (default is true)

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor(String separator, String charsToDelete, boolean emptyArrayAsNull)

Create a new StringArrayPropertyEditor with the given separator.

Parameters
separator:String

the separator to use for splitting a String

charsToDelete:String

a set of characters to delete, in addition to trimming an input String. Useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String.

emptyArrayAsNull:boolean

true if an empty String array is to be transformed into null

StringArrayPropertyEditorback to summary
public StringArrayPropertyEditor(String separator, String charsToDelete, boolean emptyArrayAsNull, boolean trimValues)

Create a new StringArrayPropertyEditor with the given separator.

Parameters
separator:String

the separator to use for splitting a String

charsToDelete:String

a set of characters to delete, in addition to trimming an input String. Useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String.

emptyArrayAsNull:boolean

true if an empty String array is to be transformed into null

trimValues:boolean

true if the values in the parsed arrays are to be trimmed of whitespace (default is true)

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
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