Class ResourceScriptSource
java.lang.Object
org.springframework.scripting.support.ResourceScriptSource
- All Implemented Interfaces:
- ScriptSource
ScriptSource implementation
 based on Spring's Resource
 abstraction. Loads the script text from the underlying Resource's
 File or
 InputStream,
 and tracks the last-modified timestamp of the file (if possible).- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogLogger available to subclasses.
- 
Constructor SummaryConstructorsConstructorDescriptionResourceScriptSource(Resource resource) Create a new ResourceScriptSource for the given resource.ResourceScriptSource(EncodedResource resource) Create a new ResourceScriptSource for the given resource.
- 
Method SummaryModifier and TypeMethodDescriptionfinal ResourceReturn theResourceto load the script from.Retrieve the current script source text as String.booleanIndicate whether the underlying script data has been modified since the last timeScriptSource.getScriptAsString()was called.protected longRetrieve the current last-modified timestamp of the underlying resource.voidsetEncoding(@Nullable String encoding) Set the encoding used for reading the script resource.Determine a class name for the underlying script.toString()
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log loggerLogger available to subclasses.
 
- 
- 
Constructor Details- 
ResourceScriptSourceCreate a new ResourceScriptSource for the given resource.- Parameters:
- resource- the EncodedResource to load the script from
 
- 
ResourceScriptSourceCreate a new ResourceScriptSource for the given resource.- Parameters:
- resource- the Resource to load the script from (using UTF-8 encoding)
 
 
- 
- 
Method Details- 
getResourceReturn theResourceto load the script from.
- 
setEncodingSet the encoding used for reading the script resource.The default value for regular Resources is "UTF-8". A nullvalue implies the platform default.
- 
getScriptAsStringDescription copied from interface:ScriptSourceRetrieve the current script source text as String.- Specified by:
- getScriptAsStringin interface- ScriptSource
- Returns:
- the script text
- Throws:
- IOException- if script retrieval failed
 
- 
isModifiedpublic boolean isModified()Description copied from interface:ScriptSourceIndicate whether the underlying script data has been modified since the last timeScriptSource.getScriptAsString()was called. Returnstrueif the script has not been read yet.- Specified by:
- isModifiedin interface- ScriptSource
- Returns:
- whether the script data has been modified
 
- 
retrieveLastModifiedTimeprotected long retrieveLastModifiedTime()Retrieve the current last-modified timestamp of the underlying resource.- Returns:
- the current timestamp, or 0 if not determinable
 
- 
suggestedClassNameDescription copied from interface:ScriptSourceDetermine a class name for the underlying script.- Specified by:
- suggestedClassNamein interface- ScriptSource
- Returns:
- the suggested class name, or nullif none available
 
- 
toString
 
-