public class ResourceScriptSource extends java.lang.Object implements 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).InputStreamSource.getInputStream(),
Resource.getFile(),
ResourceLoader| Modifier and Type | Field and Description |
|---|---|
protected Log |
logger
Logger available to subclasses
|
| Constructor and Description |
|---|
ResourceScriptSource(org.springframework.core.io.support.EncodedResource resource)
Create a new ResourceScriptSource for the given resource.
|
ResourceScriptSource(org.springframework.core.io.Resource resource)
Create a new ResourceScriptSource for the given resource.
|
| Modifier and Type | Method and Description |
|---|---|
org.springframework.core.io.Resource |
getResource()
Return the
Resource to load the
script from. |
java.lang.String |
getScriptAsString()
Retrieve the current script source text as String.
|
boolean |
isModified()
Indicate whether the underlying script data has been modified since
the last time
ScriptSource.getScriptAsString() was called. |
protected long |
retrieveLastModifiedTime()
Retrieve the current last-modified timestamp of the underlying resource.
|
void |
setEncoding(java.lang.String encoding)
Set the encoding used for reading the script resource.
|
java.lang.String |
suggestedClassName()
Determine a class name for the underlying script.
|
java.lang.String |
toString() |
protected final Log logger
public ResourceScriptSource(org.springframework.core.io.support.EncodedResource resource)
resource - the EncodedResource to load the script frompublic ResourceScriptSource(org.springframework.core.io.Resource resource)
resource - the Resource to load the script from (using UTF-8 encoding)public final org.springframework.core.io.Resource getResource()
Resource to load the
script from.public void setEncoding(java.lang.String encoding)
The default value for regular Resources is "UTF-8".
A null value implies the platform default.
public java.lang.String getScriptAsString()
throws java.io.IOException
ScriptSourcegetScriptAsString in interface ScriptSourcejava.io.IOException - if script retrieval failedpublic boolean isModified()
ScriptSourceScriptSource.getScriptAsString() was called.
Returns true if the script has not been read yet.isModified in interface ScriptSourceprotected long retrieveLastModifiedTime()
public java.lang.String suggestedClassName()
ScriptSourcesuggestedClassName in interface ScriptSourcenull if none availablepublic java.lang.String toString()
toString in class java.lang.Object