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
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new ResourceArrayPropertyEditor with a defaultPathMatchingResourcePatternResolverandStandardEnvironment.ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolverandPropertyResolver(typically anEnvironment).ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolverandPropertyResolver(typically anEnvironment). -
Method Summary
Modifier and TypeMethodDescriptionprotected StringresolvePath(String path) Resolve the given path, replacing placeholders with corresponding system property values if necessary.voidTreat the given text as a location pattern and convert it to a Resource array.voidTreat 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 defaultPathMatchingResourcePatternResolverandStandardEnvironment. -
ResourceArrayPropertyEditor
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, @Nullable PropertyResolver propertyResolver) Create a new ResourceArrayPropertyEditor with the givenResourcePatternResolverandPropertyResolver(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 givenResourcePatternResolverandPropertyResolver(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 and convert it to a Resource array.- Specified by:
setAsTextin interfacePropertyEditor- Overrides:
setAsTextin 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:
setValuein interfacePropertyEditor- Overrides:
setValuein 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:
-