org.springframework.beans.propertyeditors
public class: PropertiesEditor [javadoc |
source]
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.beans.propertyeditors.PropertiesEditor
All Implemented Interfaces:
PropertyEditor
Custom
java.beans.PropertyEditor for
Properties objects.
Handles conversion from content String to Properties object.
Also handles Map to Properties conversion, for populating
a Properties object via XML "map" entries.
The required format is defined in the standard Properties
documentation. Each property must be on a new line.
Also see:
- java.util.Properties#load
- author:
Rod - Johnson
- author:
Juergen - Hoeller
| Method from org.springframework.beans.propertyeditors.PropertiesEditor Summary: |
|---|
|
setAsText, setValue |
| Methods from java.beans.PropertyEditorSupport: |
|---|
|
addPropertyChangeListener, firePropertyChange, getAsText, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setAsText, setSource, setValue, supportsCustomEditor |
| Method from org.springframework.beans.propertyeditors.PropertiesEditor Detail: |
public void setAsText(String text) throws IllegalArgumentException {
Properties props = new Properties();
if (text != null) {
try {
// Must use the ISO-8859-1 encoding because Properties.load(stream) expects it.
props.load(new ByteArrayInputStream(text.getBytes("ISO-8859-1")));
}
catch (IOException ex) {
// Should never happen.
throw new IllegalArgumentException(
"Failed to parse [" + text + "] into Properties: " + ex.getMessage());
}
}
setValue(props);
}
|
public void setValue(Object value) {
if (!(value instanceof Properties) && value instanceof Map) {
Properties props = new Properties();
props.putAll((Map) value);
super.setValue(props);
}
else {
super.setValue(value);
}
}
|