org.springframework.scripting.support
Class StaticScriptSource

java.lang.Object
  extended by org.springframework.scripting.support.StaticScriptSource
All Implemented Interfaces:
ScriptSource

public class StaticScriptSource
extends java.lang.Object
implements ScriptSource

Static implementation of the ScriptSource interface, encapsulating a given String that contains the script source text. Supports programmatic updates of the script String.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller

Field Summary
private  java.lang.String className
           
private  boolean modified
           
private  java.lang.String script
           
 
Constructor Summary
StaticScriptSource(java.lang.String script)
          Create a new StaticScriptSource for the given script.
StaticScriptSource(java.lang.String script, java.lang.String className)
          Create a new StaticScriptSource for the given script.
 
Method Summary
 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.
 void setScript(java.lang.String script)
          Set a fresh script String, overriding the previous script.
 java.lang.String suggestedClassName()
          Determine a class name for the underlying script.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

script

private java.lang.String script

modified

private boolean modified

className

private java.lang.String className
Constructor Detail

StaticScriptSource

public StaticScriptSource(java.lang.String script)
Create a new StaticScriptSource for the given script.

Parameters:
script - the script String

StaticScriptSource

public StaticScriptSource(java.lang.String script,
                          java.lang.String className)
Create a new StaticScriptSource for the given script.

Parameters:
script - the script String
className - the suggested class name for the script (may be null)
Method Detail

setScript

public void setScript(java.lang.String script)
Set a fresh script String, overriding the previous script.

Parameters:
script - the script String

getScriptAsString

public java.lang.String getScriptAsString()
Description copied from interface: ScriptSource
Retrieve the current script source text as String.

Specified by:
getScriptAsString in interface ScriptSource
Returns:
the script text

isModified

public boolean isModified()
Description copied from interface: ScriptSource
Indicate whether the underlying script data has been modified since the last time ScriptSource.getScriptAsString() was called. Returns true if the script has not been read yet.

Specified by:
isModified in interface ScriptSource
Returns:
whether the script data has been modified

suggestedClassName

public java.lang.String suggestedClassName()
Description copied from interface: ScriptSource
Determine a class name for the underlying script.

Specified by:
suggestedClassName in interface ScriptSource
Returns:
the suggested class name, or null if none available

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object