Class ResourceArrayPropertyEditor
java.lang.Object
java.beans.PropertyEditorSupport
org.springframework.core.io.support.ResourceArrayPropertyEditor
- All Implemented Interfaces:
PropertyEditor
Editor for
Resource
arrays, to
automatically convert String
location patterns
(e.g. "file:C:/my*.txt"
or "classpath*:myfile.txt"
)
to Resource
array properties. Can also translate a collection
or array of location patterns into a merged Resource array.
A path may contain ${...}
placeholders, to be
resolved as Environment
properties:
e.g. ${user.dir}
. Unresolvable placeholders are ignored by default.
Delegates to a ResourcePatternResolver
,
by default using a PathMatchingResourcePatternResolver
.
- Since:
- 1.1.2
- Author:
- Juergen Hoeller, Chris Beams, Yanming Zhou, Stephane Nicoll
- See Also:
-
Constructor Summary
ConstructorDescriptionCreate a new ResourceArrayPropertyEditor with a defaultPathMatchingResourcePatternResolver
andStandardEnvironment
.ResourceArrayPropertyEditor
(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolver
andPropertyResolver
(typically anEnvironment
).ResourceArrayPropertyEditor
(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolver
andPropertyResolver
(typically anEnvironment
). -
Method Summary
Modifier and TypeMethodDescriptionprotected String
resolvePath
(String path) Resolve the given path, replacing placeholders with corresponding system property values if necessary.void
Treat the given text as a location pattern or comma delimited location patterns and convert it to a Resource array.void
Treat the given value as a collection or array and convert it to a Resource array.Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getAsText, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, supportsCustomEditor
-
Constructor Details
-
ResourceArrayPropertyEditor
public ResourceArrayPropertyEditor()Create a new ResourceArrayPropertyEditor with a defaultPathMatchingResourcePatternResolver
andStandardEnvironment
. -
ResourceArrayPropertyEditor
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, @Nullable PropertyResolver propertyResolver) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolver
andPropertyResolver
(typically anEnvironment
).- Parameters:
resourcePatternResolver
- the ResourcePatternResolver to usepropertyResolver
- the PropertyResolver to use
-
ResourceArrayPropertyEditor
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, @Nullable PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolver
andPropertyResolver
(typically anEnvironment
).- Parameters:
resourcePatternResolver
- the ResourcePatternResolver to usepropertyResolver
- the PropertyResolver to useignoreUnresolvablePlaceholders
- whether to ignore unresolvable placeholders if no corresponding system property could be found
-
-
Method Details
-
setAsText
Treat the given text as a location pattern or comma delimited location patterns and convert it to a Resource array.- Specified by:
setAsText
in interfacePropertyEditor
- Overrides:
setAsText
in classPropertyEditorSupport
-
setValue
Treat the given value as a collection or array and convert it to a Resource array.Considers String elements as location patterns and takes Resource elements as-is.
- Specified by:
setValue
in interfacePropertyEditor
- Overrides:
setValue
in classPropertyEditorSupport
- Throws:
IllegalArgumentException
-
resolvePath
Resolve the given path, replacing placeholders with corresponding system property values if necessary.- Parameters:
path
- the original file path- Returns:
- the resolved file path
- See Also:
-