org.springframework.core.io
Class ResourceEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.springframework.core.io.ResourceEditor
All Implemented Interfaces:
PropertyEditor

public class ResourceEditor
extends PropertyEditorSupport

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 system properties: e.g. ${user.dir}.

Delegates to a ResourceLoader, by default a DefaultResourceLoader.

Since:
28.12.2003
Author:
Juergen Hoeller
See Also:
Resource, ResourceLoader, DefaultResourceLoader, SystemPropertyUtils.resolvePlaceholders(java.lang.String), System.getProperty(String)

Constructor Summary
ResourceEditor()
          Create a new ResourceEditor with a DefaultResourceLoader.
ResourceEditor(ResourceLoader resourceLoader)
          Create a new ResourceEditor with the given ResourceLoader.
 
Method Summary
protected  String resolvePath(String path)
          Resolve the given path, replacing placeholders with corresponding system property values if necessary.
 void setAsText(String text)
           
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getAsText, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceEditor

public ResourceEditor()
Create a new ResourceEditor with a DefaultResourceLoader.

See Also:
DefaultResourceLoader

ResourceEditor

public ResourceEditor(ResourceLoader resourceLoader)
Create a new ResourceEditor with the given ResourceLoader.

Parameters:
resourceLoader - the ResourceLoader to use
Method Detail

setAsText

public void setAsText(String text)
Specified by:
setAsText in interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport

resolvePath

protected String resolvePath(String path)
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:
SystemPropertyUtils.resolvePlaceholders(java.lang.String)


Copyright (c) 2002-2007 The Spring Framework Project.