public class CachedScript extends Pnuts
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
encoding |
protected long |
parsedTime |
protected Pnuts |
script |
protected java.net.URL |
scriptURL |
pnuts_version, prompt, scriptSource, startNodes
Constructor and Description |
---|
CachedScript(java.net.URL scriptURL)
Constructor
|
CachedScript(java.net.URL scriptURL,
java.lang.String encoding,
Context context)
Constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
accept(Visitor v,
Context c)
traverse the parsed tree with the specified Visitor and Context
|
protected Compiler |
getCompiler()
Returns a compiler.
|
protected boolean |
needToUpdate()
Determin if the script should be recompiled
|
java.lang.Object |
run(Context c)
Executes a Pnuts object with the specified Context
|
java.lang.String |
unparse()
Obtain the script code from a parsed object
|
protected void |
update(Context context)
Parse/compile the script and update the timestamp.
|
accept, createClassLoader, createClassLoader, eval, evalDepth, format, get, get, getDefaults, getResource, getScriptSource, isJava2, isVerbose, load, load, load, load, load, load, loadClass, loadFile, parse, parse, parse, parse, parse, parse, require, require, set, set, setDefaults, setPrompt, setScriptSource, setVerbose, unparse
protected java.net.URL scriptURL
protected long parsedTime
protected Pnuts script
protected java.lang.String encoding
public CachedScript(java.net.URL scriptURL) throws java.io.IOException, ParseException
scriptURL
- the URL of the scriptjava.io.IOException
ParseException
public CachedScript(java.net.URL scriptURL, java.lang.String encoding, Context context) throws java.io.IOException, ParseException
scriptURL
- the URL of the scriptencoding
- the character encoding of the script. If null, the default encoding is used.context
- the context in which the script is first parsed/compiled.java.io.IOException
ParseException
public java.lang.String unparse()
Pnuts
public java.lang.Object run(Context c)
Pnuts
run
in interface Executable
run
in class Pnuts
c
- the Contextpublic java.lang.Object accept(Visitor v, Context c)
Pnuts
protected boolean needToUpdate()
protected Compiler getCompiler()
protected void update(Context context) throws java.io.IOException, ParseException
context
- the context in which the script is compiled.java.io.IOException
ParseException