org.mozilla.javascript
Class Delegator
java.lang.Objectorg.mozilla.javascript.Delegator
- Callable, Function, Scriptable
public class Delegator
extends java.lang.Object
This is a helper class for implementing wrappers around Scriptable
objects. It implements the Function interface and delegates all
invocations to a delegee Scriptable object. The normal use of this
class involves creating a sub-class and overriding one or more of
the methods.
A useful application is the implementation of interceptors,
pre/post conditions, debugging.
Delegator()- Create a Delegator prototype.
|
Delegator(Scriptable obj)- Create a new Delegator that forwards requests to a delegee
Scriptable object.
|
Object | call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
|
Scriptable | construct(Context cx, Scriptable scope, Object[] args)- Note that if the
delegee is null,
this method creates a new instance of the Delegator itself
rathert than forwarding the call to the
delegee.
|
void | delete(String name)
|
void | delete(int index)
|
Object | get(String name, Scriptable start)
|
Object | get(int index, Scriptable start)
|
String | getClassName()
|
Object | getDefaultValue(Class hint)- Note that this method does not get forwarded to the delegee if
the
hint parameter is null,
ScriptRuntime.ScriptableClass or
ScriptRuntime.FunctionClass.
|
Scriptable | getDelegee()- Retrieve the delegee.
|
Object[] | getIds()
|
Scriptable | getParentScope()
|
Scriptable | getPrototype()
|
boolean | has(String name, Scriptable start)
|
boolean | has(int index, Scriptable start)
|
boolean | hasInstance(Scriptable instance)
|
protected Delegator | newInstance()- Crete new Delegator instance.
|
void | put(String name, Scriptable start, Object value)
|
void | put(int index, Scriptable start, Object value)
|
void | setDelegee(Scriptable obj)- Set the delegee.
|
void | setParentScope(Scriptable parent)
|
void | setPrototype(Scriptable prototype)
|
Delegator
public Delegator()
Create a Delegator prototype.
This constructor should only be used for creating prototype
objects of Delegator.
Delegator
public Delegator(Scriptable obj)
Create a new Delegator that forwards requests to a delegee
Scriptable object.
construct
public Scriptable construct(Context cx,
Scriptable scope,
Object[] args) Note that if the delegee is null,
this method creates a new instance of the Delegator itself
rathert than forwarding the call to the
delegee. This permits the use of Delegator
prototypes.
- construct in interface Function
cx - the current Context for this threadscope - an enclosing scope of the caller except
when the function is called from a closure.args - the array of arguments
getDefaultValue
public Object getDefaultValue(Class hint)
Note that this method does not get forwarded to the delegee if
the hint parameter is null,
ScriptRuntime.ScriptableClass or
ScriptRuntime.FunctionClass. Instead the object
itself is returned.
- getDefaultValue in interface Scriptable
getDelegee
public Scriptable getDelegee()
Retrieve the delegee.
newInstance
protected Delegator newInstance()
Crete new Delegator instance.
The default implementation calls this.getClass().newInstance().
construct(Context cx, Scriptable scope, Object[] args)
setDelegee
public void setDelegee(Scriptable obj)
Set the delegee.