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

public Class FileEditor

extends PropertyEditorSupport
Class Inheritance
Imports
java.beans.PropertyEditorSupport, java.io.File, .IOException, org.springframework.core.io.Resource, .ResourceEditor, org.springframework.util.Assert, .ResourceUtils, .StringUtils

Editor for java.io.File, to directly populate a File property from a Spring resource location.

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL.

Note

The behavior of this editor has changed in Spring 2.0. Previously, it created a File instance directly from a filename. As of Spring 2.0, it takes a standard Spring resource location as input; this is consistent with URLEditor and InputStreamEditor now.

Note

In Spring 2.5 the following modification was made. If a file name is specified without a URL prefix or without an absolute path then we try to locate the file using standard ResourceLoader semantics. If the file was not found, then a File instance is created assuming the file name refers to a relative file location.

Authors
Juergen Hoeller, Thomas Risberg
Since
09.12.2003
See Also
java.io.File, org.springframework.core.io.ResourceEditor, org.springframework.core.io.ResourceLoader, URLEditor, InputStreamEditor

Field Summary

Modifier and TypeField and Description
private final ResourceEditor

Constructor Summary

AccessConstructor and Description
public
FileEditor()

Create a new FileEditor, using a default ResourceEditor underneath.

public
FileEditor(ResourceEditor
the ResourceEditor to use
resourceEditor
)

Create a new FileEditor, using the given ResourceEditor underneath.

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

resourceEditorback to summary
private final ResourceEditor resourceEditor

Constructor Detail

FileEditorback to summary
public FileEditor()

Create a new FileEditor, using a default ResourceEditor underneath.

FileEditorback to summary
public FileEditor(ResourceEditor resourceEditor)

Create a new FileEditor, using the given ResourceEditor underneath.

Parameters
resourceEditor:ResourceEditor

the ResourceEditor to use

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