|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.tinyjee.maven.dim.utils.JavaScriptFacade
public class JavaScriptFacade
Is a common base class for script facades.
Note: Non of the facades is thread safe nor sharable between threads.
Field Summary | |
---|---|
protected org.mozilla.javascript.Context |
context
|
protected org.mozilla.javascript.ScriptableObject |
scope
|
protected static Charset |
SCRIPT_ENCODING
|
Constructor Summary | |
---|---|
protected |
JavaScriptFacade()
Constructs a new JavaScriptFacade hosing a thread-bound script Context. |
Method Summary | |
---|---|
protected void |
close()
|
protected org.mozilla.javascript.Script |
compileScript(String name,
InputStream in,
boolean close)
Compiles the given JS script contained in the stream and returns the compiled version. |
protected void |
compileScript(URL resource,
List<org.mozilla.javascript.Script> scripts)
Compiles the given script or script bundle. |
protected void |
compileScripts(ZipInputStream zIn,
List<org.mozilla.javascript.Script> scripts)
Compiles all JS scripts contained in the given ZIP file. |
protected org.mozilla.javascript.Scriptable |
createObject(Map<String,Object> values)
Creates a JavaScript object. |
protected Object |
execute(org.mozilla.javascript.Script script)
Executes the script. |
protected Object |
getFromScope(String name)
Returns the object from the current scope. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Charset SCRIPT_ENCODING
protected final org.mozilla.javascript.Context context
protected final org.mozilla.javascript.ScriptableObject scope
Constructor Detail |
---|
protected JavaScriptFacade()
Method Detail |
---|
protected void close()
protected org.mozilla.javascript.Scriptable createObject(Map<String,Object> values)
values
- the key, value pairs forming the JavaScript object.
protected void compileScript(URL resource, List<org.mozilla.javascript.Script> scripts) throws IOException
resource
- an URL pointing to the JS or ZIP file.scripts
- the list of scripts to add the compiled scripts to.
IOException
- in case of reading the URL content failed.protected void compileScripts(ZipInputStream zIn, List<org.mozilla.javascript.Script> scripts) throws IOException
zIn
- the ZipInputStream containing the scripts.scripts
- the list of scripts to add the compiled scripts to.
IOException
- in case of reading the ZIP content failed.protected org.mozilla.javascript.Script compileScript(String name, InputStream in, boolean close) throws IOException
name
- the name of the script source (used when compile errors are contained).in
- the input stream containing the script.close
- whether the stream is closed or not at the end.
IOException
- In case of reading the stream failed.protected Object execute(org.mozilla.javascript.Script script)
script
- the script to execute.
protected Object getFromScope(String name)
name
- the name of the object to retrieve.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |