MCPcopy Index your code
hub / github.com/beanshell/beanshell / ScriptContext

Interface ScriptContext

engine/javax-src/javax/script/ScriptContext.java:24–185  ·  view source on GitHub ↗

The interface whose implementing classes are used to connect Script Engines with objects, such as scoped Bindings, in hosting applications. Each scope is a set of named attributes whose values can be set and retrieved using the ScriptContext methods. ScriptContexts also expose Readers

Source from the content-addressed store, hash-verified

22 * @since 1.6
23 */
24public interface ScriptContext {
25
26
27 /**
28 * EngineScope attributes are visible during the lifetime of a single
29 * <code>ScriptEngine</code> and a set of attributes is maintained for each
30 * engine.
31 */
32 public static final int ENGINE_SCOPE = 100;
33
34 /**
35 * GlobalScope attributes are visible to all engines created by same ScriptEngineFactory.
36 */
37 public static final int GLOBAL_SCOPE = 200;
38
39
40 /**
41 * Associates a <code>Bindings</code> instance with a particular scope in this
42 * <code>ScriptContext</code>. Calls to the <code>getAttribute</code> and
43 * <code>setAttribute</code> methods must map to the <code>put</code> and
44 * <code>get</code> methods of the <code>Bindings</code> for the specified scope.
45 *
46 * @param bindings The <code>Bindings</code> to associate with the given scope
47 * @param scope The scope
48 *
49 * @throws <code>IllegalArgumentException</code> If no <code>Bindings</code> is defined for the
50 * specified scope value in ScriptContexts of this type.
51 * @throws <code>NullPointerException</code> if value of scope is <code>ENGINE_SCOPE</code> and
52 * the specified <code>Bindings</code> is null.
53 *
54 */
55 public void setBindings(Bindings bindings, int scope);
56
57 /**
58 * Gets the <code>Bindings</code> associated with the given scope in this
59 * <code>ScriptContext</code>.
60 *
61 * @return The associated <code>Bindings</code>. Returns <code>null</code> if it has not
62 * been set.
63 *
64 * @throws IllegalArgumentException If no <code>Bindings</code> is defined for the
65 * specified scope value in <code>ScriptContext</code> of this type.
66 */
67 public Bindings getBindings(int scope);
68
69 /**
70 * Sets the value of an attribute in a given scope.
71 *
72 * @param name The name of the attribute to set.
73 * @param scope The scope in which to set the attribute
74 *
75 * @throws <code>IllegalArgumentException</code> if the scope
76 * is invalid.
77 * @throws <code>NullPointerException</code> if the name is null.
78 * @throws <code>ClassCastException</code> if the name is not a String.
79 */
80 public void setAttribute(String name, Object value, int scope);
81

Callers 28

evalMethod · 0.95
putMethod · 0.65
getEngineNameSpaceMethod · 0.65
mainMethod · 0.65
getMethod · 0.65
putMethod · 0.65
removeMethod · 0.65
getEngineNameSpaceMethod · 0.65
removeMethod · 0.65
containsKeyMethod · 0.65
evalMethod · 0.95
evalSourceMethod · 0.65

Implementers 1

SimpleScriptContextengine/javax-src/javax/script/SimpleSc

Calls

no outgoing calls

Tested by

no test coverage detected