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
ConstructorDescriptionCreate a new instance of theResourceEditor
class using aDefaultResourceLoader
andStandardEnvironment
.ResourceEditor
(ResourceLoader resourceLoader, PropertyResolver propertyResolver) Create a new instance of theResourceEditor
class using the givenResourceLoader
andPropertyResolver
.ResourceEditor
(ResourceLoader resourceLoader, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new instance of theResourceEditor
class 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 theResourceEditor
class using aDefaultResourceLoader
andStandardEnvironment
. -
ResourceEditor
Create a new instance of theResourceEditor
class using the givenResourceLoader
andPropertyResolver
.- Parameters:
resourceLoader
- theResourceLoader
to usepropertyResolver
- thePropertyResolver
to use
-
ResourceEditor
public ResourceEditor(ResourceLoader resourceLoader, @Nullable PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new instance of theResourceEditor
class using the givenResourceLoader
.- Parameters:
resourceLoader
- theResourceLoader
to usepropertyResolver
- thePropertyResolver
to useignoreUnresolvablePlaceholders
- whether to ignore unresolvable placeholders if no corresponding property could be found in the givenpropertyResolver
-
-
Method Details
-
setAsText
- Specified by:
setAsText
in interfacePropertyEditor
- Overrides:
setAsText
in classPropertyEditorSupport
-
resolvePath
Resolve the given path, replacing placeholders with corresponding property values from theenvironment
if necessary.- Parameters:
path
- the original file path- Returns:
- the resolved file path
- See Also:
-
getAsText
- Specified by:
getAsText
in interfacePropertyEditor
- Overrides:
getAsText
in classPropertyEditorSupport
-