org.springframework.beans.propertyeditors
public class: URLEditor [javadoc |
source]
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.beans.propertyeditors.URLEditor
All Implemented Interfaces:
PropertyEditor
Editor for
java.net.URL, to directly populate a URL property
instead of using a String property as bridge.
Supports Spring-style URL notation: any fully qualified standard URL
("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL,
as well as Spring's context-specific relative file paths.
Note: A URL must specify a valid protocol, else it will be rejected
upfront. However, the target resource does not necessarily have to exist
at the time of URL creation; this depends on the specific resource type.
| Method from org.springframework.beans.propertyeditors.URLEditor Summary: |
|---|
|
getAsText, setAsText |
| 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.URLEditor Detail: |
public String getAsText() {
URL value = (URL) getValue();
return (value != null ? value.toExternalForm() : "");
}
|
public void setAsText(String text) throws IllegalArgumentException {
this.resourceEditor.setAsText(text);
Resource resource = (Resource) this.resourceEditor.getValue();
try {
setValue(resource != null ? resource.getURL() : null);
}
catch (IOException ex) {
throw new IllegalArgumentException("Could not retrieve URL for " + resource + ": " + ex.getMessage());
}
}
|