Top Description Fields Constructors Methods
org.springframework.core.io.support

public Class ResourceArrayPropertyEditor

extends PropertyEditorSupport
Class Inheritance
Imports
java.beans.PropertyEditorSupport, java.io.IOException, java.util.Arrays, .Collection, .Collections, .LinkedHashSet, .Set, org.apache.commons.logging.Log, .LogFactory, org.springframework.core.env.Environment, .PropertyResolver, .StandardEnvironment, org.springframework.core.io.Resource, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Editor for org.springframework.core.io.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 org.springframework.core.env.Environment properties: e.g. ${user.dir}. Unresolvable placeholders are ignored by default.

Delegates to a ResourcePatternResolver, by default using a PathMatchingResourcePatternResolver.

Authors
Juergen Hoeller, Chris Beams, Yanming Zhou, Stephane Nicoll
Since
1.1.2
See Also
org.springframework.core.io.Resource, ResourcePatternResolver, PathMatchingResourcePatternResolver

Field Summary

Modifier and TypeField and Description
private final boolean
private static final Log
private PropertyResolver
private final ResourcePatternResolver

Constructor Summary

AccessConstructor and Description
public
ResourceArrayPropertyEditor()

Create a new ResourceArrayPropertyEditor with a default PathMatchingResourcePatternResolver and StandardEnvironment.

public
ResourceArrayPropertyEditor(ResourcePatternResolver
the ResourcePatternResolver to use
resourcePatternResolver
,
PropertyResolver
the PropertyResolver to use
propertyResolver
)

Create a new ResourceArrayPropertyEditor with the given ResourcePatternResolver and PropertyResolver (typically an Environment).

public
ResourceArrayPropertyEditor(ResourcePatternResolver
the ResourcePatternResolver to use
resourcePatternResolver
,
PropertyResolver
the PropertyResolver to use
propertyResolver
,
boolean
whether to ignore unresolvable placeholders if no corresponding system property could be found
ignoreUnresolvablePlaceholders
)

Create a new ResourceArrayPropertyEditor with the given ResourcePatternResolver and PropertyResolver (typically an Environment).

Method Summary

Modifier and TypeMethod and Description
private Resource[]
getResources(String locationPattern)

protected String

Returns:

the resolved file path
resolvePath
(String
the original file path
path
)

Resolve the given path, replacing placeholders with corresponding system property values if necessary.

public void
setAsText(String
The string to be parsed.
text
)

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Treat the given text as a location pattern or comma delimited location patterns and convert it to a Resource array.

public void
setValue(Object
The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.
value
)

Overrides java.beans.PropertyEditorSupport.setValue.

Implements java.beans.PropertyEditor.setValue.

Treat the given value as a collection or array and convert it to a Resource array.

Inherited from java.beans.PropertyEditorSupport:
addPropertyChangeListenerfirePropertyChangegetAsTextgetCustomEditorgetJavaInitializationStringgetSourcegetTagsgetValueisPaintablepaintValueremovePropertyChangeListenersetSourcesupportsCustomEditor

Field Detail

ignoreUnresolvablePlaceholdersback to summary
private final boolean ignoreUnresolvablePlaceholders
loggerback to summary
private static final Log logger
propertyResolverback to summary
private PropertyResolver propertyResolver
Annotations
@Nullable
resourcePatternResolverback to summary
private final ResourcePatternResolver resourcePatternResolver

Constructor Detail

ResourceArrayPropertyEditorback to summary
public ResourceArrayPropertyEditor()

Create a new ResourceArrayPropertyEditor with a default PathMatchingResourcePatternResolver and StandardEnvironment.

See Also
PathMatchingResourcePatternResolver, Environment
ResourceArrayPropertyEditorback to summary
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver)

Create a new ResourceArrayPropertyEditor with the given ResourcePatternResolver and PropertyResolver (typically an Environment).

Parameters
resourcePatternResolver:ResourcePatternResolver

the ResourcePatternResolver to use

propertyResolver:PropertyResolver

the PropertyResolver to use

ResourceArrayPropertyEditorback to summary
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders)

Create a new ResourceArrayPropertyEditor with the given ResourcePatternResolver and PropertyResolver (typically an Environment).

Parameters
resourcePatternResolver:ResourcePatternResolver

the ResourcePatternResolver to use

propertyResolver:PropertyResolver

the PropertyResolver to use

ignoreUnresolvablePlaceholders:boolean

whether to ignore unresolvable placeholders if no corresponding system property could be found

Method Detail

getResourcesback to summary
private Resource[] getResources(String locationPattern)
resolvePathback to summary
protected String resolvePath(String path)

Resolve the given path, replacing placeholders with corresponding system property values if necessary.

Parameters
path:String

the original file path

Returns:String

the resolved file path

See Also
PropertyResolver#resolvePlaceholders, PropertyResolver#resolveRequiredPlaceholders(String)
setAsTextback to summary
public void setAsText(String text)

Overrides java.beans.PropertyEditorSupport.setAsText.

Implements java.beans.PropertyEditor.setAsText.

Treat the given text as a location pattern or comma delimited location patterns and convert it to a Resource array.

Parameters
text:String

Doc from java.beans.PropertyEditorSupport.setAsText.

The string to be parsed.

Annotations
@Override
setValueback to summary
public void setValue(Object value) throws IllegalArgumentException

Overrides java.beans.PropertyEditorSupport.setValue.

Implements java.beans.PropertyEditor.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.

Parameters
value:Object

Doc from java.beans.PropertyEditorSupport.setValue.

The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.

Annotations
@Override