public class

ResourceScriptSource

extends Object
implements ScriptSource
java.lang.Object
   ↳ org.springframework.scripting.support.ResourceScriptSource

Class Overview

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).

Summary

Fields
protected final Log logger Logger available to subclasses
Public Constructors
ResourceScriptSource(Resource resource)
Create a new ResourceScriptSource for the given resource.
Public Methods
final Resource getResource()
Return the Resource to load the script from.
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 getScriptAsString() was called.
void setEncoding(String encoding)
Sets the encoding used for reading the script resource.
String suggestedClassName()
Determine a class name for the underlying script.
String toString()
Protected Methods
long retrieveLastModifiedTime()
Retrieve the current last-modified timestamp of the underlying resource.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.scripting.ScriptSource

Fields

protected final Log logger

Logger available to subclasses

Public Constructors

public ResourceScriptSource (Resource resource)

Create a new ResourceScriptSource for the given resource.

Parameters
resource the Resource to load the script from

Public Methods

public final Resource getResource ()

Return the Resource to load the script from.

public String getScriptAsString ()

Retrieve the current script source text as String.

Returns
  • the script text
Throws
IOException

public boolean isModified ()

Indicate whether the underlying script data has been modified since the last time getScriptAsString() was called. Returns true if the script has not been read yet.

Returns
  • whether the script data has been modified

public void setEncoding (String encoding)

Sets the encoding used for reading the script resource. The default value is "UTF-8". A null value, implies the platform default.

Parameters
encoding charset encoding used for reading the script.

public String suggestedClassName ()

Determine a class name for the underlying script.

Returns
  • the suggested class name, or null if none available

public String toString ()

Protected Methods

protected long retrieveLastModifiedTime ()

Retrieve the current last-modified timestamp of the underlying resource.

Returns
  • the current timestamp, or 0 if not determinable