Class StaticScriptSource
- java.lang.Object
- org.springframework.scripting.support.StaticScriptSource
- All Implemented Interfaces:
ScriptSource
public class StaticScriptSource extends Object implements ScriptSource
Static implementation of theScriptSourceinterface, 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
Constructor Summary
Constructors Constructor Description StaticScriptSource(String script)Create a new StaticScriptSource for the given script.StaticScriptSource(String script, String className)Create a new StaticScriptSource for the given script.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetScriptAsString()Retrieve the current script source text as String.booleanisModified()Indicate whether the underlying script data has been modified since the last timeScriptSource.getScriptAsString()was called.voidsetScript(String script)Set a fresh script String, overriding the previous script.StringsuggestedClassName()Determine a class name for the underlying script.StringtoString()
Constructor Detail
StaticScriptSource
public StaticScriptSource(String script)
Create a new StaticScriptSource for the given script.- Parameters:
script- the script String
StaticScriptSource
public StaticScriptSource(String script, String className)
Create a new StaticScriptSource for the given script.- Parameters:
script- the script StringclassName- the suggested class name for the script (may benull)
Method Detail
setScript
public void setScript(String script)
Set a fresh script String, overriding the previous script.- Parameters:
script- the script String
getScriptAsString
public String getScriptAsString()
Description copied from interface:ScriptSourceRetrieve the current script source text as String.- Specified by:
getScriptAsStringin interfaceScriptSource- Returns:
- the script text
isModified
public 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 interfaceScriptSource- Returns:
- whether the script data has been modified
suggestedClassName
public String suggestedClassName()
Description copied from interface:ScriptSourceDetermine a class name for the underlying script.- Specified by:
suggestedClassNamein interfaceScriptSource- Returns:
- the suggested class name, or
nullif none available