public class RhinoInterpreter extends java.lang.Object implements Interpreter
Interpreter
interface to use
Rhino ECMAScript interpreter.Modifier and Type | Class and Description |
---|---|
static interface |
RhinoInterpreter.ArgumentsBuilder
To build an argument list.
|
protected static class |
RhinoInterpreter.Entry
Class to store cached compiled scripts.
|
protected class |
RhinoInterpreter.Factory
Factory for Context objects.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BIND_NAME_WINDOW
Name of the "window" object when referenced by scripts
|
protected org.mozilla.javascript.ClassShutter |
classShutter
Class shutter.
|
protected java.util.LinkedList |
compiledScripts
List of cached compiled scripts.
|
protected org.mozilla.javascript.ContextFactory |
contextFactory
Factory object for creating Contexts.
|
protected static java.util.List |
contexts
Context vector, to make sure we are not
setting the security context too many times
|
protected org.mozilla.javascript.Context |
defaultContext
Default Context for scripts.
|
protected org.mozilla.javascript.ScriptableObject |
globalObject
The global object.
|
protected RhinoClassLoader |
rhinoClassLoader
The Rhino 'security domain'.
|
protected org.mozilla.javascript.SecurityController |
securityController
The SecurityController implementation for Batik,
which ensures scripts have access to the
server they were downloaded from
|
static java.lang.String |
SOURCE_NAME_SVG
Constant used to describe an SVG source
|
protected Window |
window
The window object.
|
protected org.mozilla.javascript.WrapFactory |
wrapFactory
Factory for Java wrapper objects.
|
Constructor and Description |
---|
RhinoInterpreter(java.net.URL documentURL)
Build a
Interpreter for ECMAScript using Rhino. |
RhinoInterpreter(java.net.URL documentURL,
ImportInfo imports)
Build a
Interpreter for ECMAScript using Rhino. |
Modifier and Type | Method and Description |
---|---|
void |
bindObject(java.lang.String name,
java.lang.Object object)
This method registers a particular Java
Object in
the environment of the interpreter. |
protected org.mozilla.javascript.ScriptableObject |
createGlobalObject(org.mozilla.javascript.Context ctx)
Creates the global object.
|
protected void |
defineGlobalWrapperClass(org.mozilla.javascript.Scriptable global)
Defines the class for the global object.
|
void |
dispose()
For
RhinoInterpreter this method flushes the
Rhino caches to avoid memory leaks. |
java.lang.Object |
evaluate(java.io.Reader scriptreader)
This method evaluates a piece of ECMAScript.
|
java.lang.Object |
evaluate(java.io.Reader scriptReader,
java.lang.String description)
This method evaluates a piece of ECMAScript.
|
java.lang.Object |
evaluate(java.lang.String scriptStr)
This method evaluates a piece of ECMA script.
|
java.lang.String |
formatMessage(java.lang.String key,
java.lang.Object[] args)
Creates and returns a localized message, given the key of the message, 0, data.length
in the resource bundle and the message parameters.
|
java.security.AccessControlContext |
getAccessControlContext()
Returns the AccessControlContext associated with this Interpreter.
|
org.mozilla.javascript.ContextFactory |
getContextFactory()
Returns the ContextFactory for this interpreter.
|
protected org.mozilla.javascript.ScriptableObject |
getGlobalObject()
This method returns the ECMAScript global object used by this
interpreter.
|
java.util.Locale |
getLocale()
Returns the current locale or null if the locale currently used is
the default one.
|
java.lang.String[] |
getMimeTypes()
Returns the content types of the scripting languages this interpreter
handles.
|
Window |
getWindow()
Returns the window object for this interpreter.
|
protected void |
init(java.net.URL documentURL,
ImportInfo imports) |
void |
setLocale(java.util.Locale locale)
Provides a way to the user to specify a locale which override the
default one.
|
void |
setOut(java.io.Writer out)
By default Rhino has no output method in its language.
|
public static final java.lang.String SOURCE_NAME_SVG
public static final java.lang.String BIND_NAME_WINDOW
protected static java.util.List contexts
protected Window window
protected org.mozilla.javascript.ScriptableObject globalObject
protected java.util.LinkedList compiledScripts
protected org.mozilla.javascript.WrapFactory wrapFactory
protected org.mozilla.javascript.ClassShutter classShutter
protected RhinoClassLoader rhinoClassLoader
protected org.mozilla.javascript.SecurityController securityController
protected org.mozilla.javascript.ContextFactory contextFactory
protected org.mozilla.javascript.Context defaultContext
public RhinoInterpreter(java.net.URL documentURL)
Interpreter
for ECMAScript using Rhino.documentURL
- the URL for the document which referencesInterpreter
,
InterpreterPool
public RhinoInterpreter(java.net.URL documentURL, ImportInfo imports)
Interpreter
for ECMAScript using Rhino.documentURL
- the URL for the document which referencesimports
- the set of Java classes/packages to import
into the scripting enviornment.Interpreter
,
InterpreterPool
protected void init(java.net.URL documentURL, ImportInfo imports)
public java.lang.String[] getMimeTypes()
getMimeTypes
in interface Interpreter
public Window getWindow()
public org.mozilla.javascript.ContextFactory getContextFactory()
protected void defineGlobalWrapperClass(org.mozilla.javascript.Scriptable global)
protected org.mozilla.javascript.ScriptableObject createGlobalObject(org.mozilla.javascript.Context ctx)
public java.security.AccessControlContext getAccessControlContext()
RhinoClassLoader
protected org.mozilla.javascript.ScriptableObject getGlobalObject()
public java.lang.Object evaluate(java.io.Reader scriptreader) throws java.io.IOException
evaluate
in interface Interpreter
scriptreader
- a java.io.Reader
on the piece of scriptjava.io.IOException
public java.lang.Object evaluate(java.io.Reader scriptReader, java.lang.String description) throws java.io.IOException
evaluate
in interface Interpreter
scriptReader
- a java.io.Reader
on the piece of scriptdescription
- description which can be later used (e.g., for error
messages).java.io.IOException
public java.lang.Object evaluate(java.lang.String scriptStr)
evaluate
in interface Interpreter
scriptStr
- the piece of scriptpublic void dispose()
RhinoInterpreter
this method flushes the
Rhino caches to avoid memory leaks.dispose
in interface Interpreter
public void bindObject(java.lang.String name, java.lang.Object object)
Object
in
the environment of the interpreter.bindObject
in interface Interpreter
name
- the name of the script object to createobject
- the Java objectpublic void setOut(java.io.Writer out)
setOut
in interface Interpreter
out
- the new out Writer
.public java.util.Locale getLocale()
getLocale
in interface Localizable
public void setLocale(java.util.Locale locale)
setLocale
in interface Localizable
locale
- The locale to set.public java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args)
formatMessage
in interface Localizable
key
- The key used to retreive the message from the resource
bundle.args
- The objects that compose the message.java.util.MissingResourceException
- if the key is not in the bundle.Copyright © 2022 Apache Software Foundation. All Rights Reserved.