|
|||||||||
| Home >> All >> [ bsh overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
bsh
Class This

java.lang.Objectbsh.This
- All Implemented Interfaces:
- java.lang.Runnable, java.io.Serializable
- public class This
- extends java.lang.Object
- implements java.io.Serializable, java.lang.Runnable
- extends java.lang.Object
'This' is the type of bsh scripted objects. A 'This' object is a bsh scripted object context. It holds a namespace reference and implements event listeners and various other interfaces. This holds a reference to the declaring interpreter for callbacks from outside of bsh.
| Field Summary | |
(package private) Interpreter |
declaringInterpreter
This is the interpreter running when the This ref was created. |
(package private) NameSpace |
namespace
The namespace that this This reference wraps. |
| Constructor Summary | |
protected |
This(NameSpace namespace,
Interpreter declaringInterpreter)
|
| Method Summary | |
static void |
bind(This ths,
NameSpace namespace,
Interpreter declaringInterpreter)
Bind a This reference to a parent's namespace with the specified declaring interpreter. |
java.lang.Object |
getInterface(java.lang.Class clas)
Get a version of this scripted object implementing the specified interface. |
java.lang.Object |
getInterface(java.lang.Class[] ca)
Get a version of this scripted object implementing the specified interfaces. |
NameSpace |
getNameSpace()
|
(package private) static This |
getThis(NameSpace namespace,
Interpreter declaringInterpreter)
getThis() is a factory for bsh.This type references. |
java.lang.Object |
invokeMethod(java.lang.String name,
java.lang.Object[] args)
Invoke specified method as from outside java code, using the declaring interpreter and current namespace. |
java.lang.Object |
invokeMethod(java.lang.String methodName,
java.lang.Object[] args,
Interpreter interpreter,
CallStack callstack,
SimpleNode callerInfo)
Invoke a method in this namespace with the specified args, interpreter reference, callstack, and caller info. |
void |
run()
This method will be called by whoever wishes to run your class implementing Runnable. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
namespace
NameSpace namespace
- The namespace that this This reference wraps.
declaringInterpreter
transient Interpreter declaringInterpreter
- This is the interpreter running when the This ref was created.
It's used as a default interpreter for callback through the This
where there is no current interpreter instance
e.g. interface proxy or event call backs from outside of bsh.
| Constructor Detail |
This
protected This(NameSpace namespace, Interpreter declaringInterpreter)
| Method Detail |
getThis
static This getThis(NameSpace namespace, Interpreter declaringInterpreter)
- getThis() is a factory for bsh.This type references. The capabilities
of ".this" references in bsh are version dependent up until jdk1.3.
The version dependence was to support different default interface
implementations. i.e. different sets of listener interfaces which
scripted objects were capable of implementing. In jdk1.3 the
reflection proxy mechanism was introduced which allowed us to
implement arbitrary interfaces. This is fantastic.
A This object is a thin layer over a namespace, comprising a bsh object
context. We create it here only if needed for the namespace.
Note: this method could be considered slow because of the way it
dynamically factories objects. However I've also done tests where
I hard-code the factory to return JThis and see no change in the
rough test suite time. This references are also cached in NameSpace.
getInterface
public java.lang.Object getInterface(java.lang.Class clas) throws UtilEvalError
- Get a version of this scripted object implementing the specified
interface.
getInterface
public java.lang.Object getInterface(java.lang.Class[] ca) throws UtilEvalError
- Get a version of this scripted object implementing the specified
interfaces.
getNameSpace
public NameSpace getNameSpace()
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
run
public void run()
- Description copied from interface:
java.lang.Runnable - This method will be called by whoever wishes to run your class
implementing Runnable. Note that there are no restrictions on what
you are allowed to do in the run method, except that you cannot
throw a checked exception.
- Specified by:
runin interfacejava.lang.Runnable
invokeMethod
public java.lang.Object invokeMethod(java.lang.String name, java.lang.Object[] args) throws EvalError
- Invoke specified method as from outside java code, using the
declaring interpreter and current namespace.
The call stack will indicate that the method is being invoked from
outside of bsh in native java code.
Note: you must still wrap/unwrap args/return values using
Primitive/Primitive.unwrap() for use outside of BeanShell.
invokeMethod
public java.lang.Object invokeMethod(java.lang.String methodName, java.lang.Object[] args, Interpreter interpreter, CallStack callstack, SimpleNode callerInfo) throws EvalError
- Invoke a method in this namespace with the specified args,
interpreter reference, callstack, and caller info.
Note: If you use this method outside of the bsh package and wish to use variables with primitive values you will have to wrap them using bsh.Primitive. Consider using This getInterface() to make a true Java interface for invoking your scripted methods.
This method also implements the default object protocol of toString(), hashCode() and equals() and the invoke() meta-method handling as a last resort.
Note: the invoke() method will not catch the object method (toString, ...). If you want to override them you have to script them directly.
bind
public static void bind(This ths, NameSpace namespace, Interpreter declaringInterpreter)
- Bind a This reference to a parent's namespace with the specified
declaring interpreter. Also re-init the callstack. It's necessary
to bind a This reference before it can be used after deserialization.
This is used by the bsh load() command.
This is a static utility method because it's used by a bsh command bind() and the interpreter doesn't currently allow access to direct methods of This objects (small hack)
|
|||||||||
| Home >> All >> [ bsh overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
bsh.This