Package org.springframework.core.io
Class ResourceEditor
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.core.io.ResourceEditor
- All Implemented Interfaces:
PropertyEditor
Editor for Resource
descriptors, to automatically convert String locations
e.g. file:C:/myfile.txt or classpath:myfile.txt to
Resource properties instead of using a String location property.
The path may contain ${...} placeholders, to be
resolved as Environment properties:
e.g. ${user.dir}. Unresolvable placeholders are ignored by default.
Delegates to a ResourceLoader to do the heavy lifting,
by default using a DefaultResourceLoader.
- Since:
- 28.12.2003
- Author:
- Juergen Hoeller, Dave Syer, Chris Beams
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of theResourceEditorclass using aDefaultResourceLoaderandStandardEnvironment.ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver) Create a new instance of theResourceEditorclass using the givenResourceLoaderandPropertyResolver.ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new instance of theResourceEditorclass using the givenResourceLoader. -
Method Summary
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
-
Constructor Details
-
ResourceEditor
public ResourceEditor()Create a new instance of theResourceEditorclass using aDefaultResourceLoaderandStandardEnvironment. -
ResourceEditor
Create a new instance of theResourceEditorclass using the givenResourceLoaderandPropertyResolver.- Parameters:
resourceLoader- theResourceLoaderto usepropertyResolver- thePropertyResolverto use
-
ResourceEditor
public ResourceEditor(ResourceLoader resourceLoader, @Nullable PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new instance of theResourceEditorclass using the givenResourceLoader.- Parameters:
resourceLoader- theResourceLoaderto usepropertyResolver- thePropertyResolverto useignoreUnresolvablePlaceholders- whether to ignore unresolvable placeholders if no corresponding property could be found in the givenpropertyResolver
-
-
Method Details
-
setAsText
- Specified by:
setAsTextin interfacePropertyEditor- Overrides:
setAsTextin classPropertyEditorSupport
-
resolvePath
Resolve the given path, replacing placeholders with corresponding property values from theenvironmentif necessary.- Parameters:
path- the original file path- Returns:
- the resolved file path
- See Also:
-
getAsText
- Specified by:
getAsTextin interfacePropertyEditor- Overrides:
getAsTextin classPropertyEditorSupport
-