|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.classwrap.ClassWrapGen
The classwrap
package is used to generate a "wrapper" for
a java class. A wrapper is just a subclass of a given java class, where
for each public non-final, non-static method, a wrapper method and an
"orig" method are generated. The wrapper method looks up a property
with the same name in the script object, and if it exists, and is a
function that takes a compatible number of arguments, calls it,
otherwise it calls the same method in the parent (original) java class.
The orig method simply calls the same method in the parent class.
The "wrapper" class is used any place where a script objects extends a java class (ie. java class, java interface, or builtin-type). The purpose is to allow the script object to override methods in a java class, or implement methods in a java interface.
The "wrapper" class is generated using the Byte Code Engineering Library (BCEL.jar).
Method Summary | |
static boolean |
canMakeWrapperClass(java.lang.Class origClass)
Check if we can make a wrapper class for the specified class... |
static java.lang.Class |
getNonWrapperClass(java.lang.Class javaClass)
Given a java class that may or may not be a wrapper class, return a java class that is the closest super-class that is not a wrapper class. |
static java.lang.String |
getOrigMethodName(java.lang.Object javaObj,
java.lang.String methodName)
Because the wrapper method looks to the script object first, before calling the wrapped method, there are times when we want to call the original method directly. |
static java.lang.String |
getOrigMethodName(java.lang.String methodName)
|
static Value |
getScriptObject(java.lang.Object javaObj)
Given a java object, which may be linked to a script object, return the linked script object. |
static boolean |
isWrapperInstance(java.lang.Object javaObj)
Is the specified object an instance of a wrapper class? |
static void |
linkObjects(java.lang.Object javaObj,
Scope scriptObj)
Link the specified java object and script object. |
static java.lang.Class |
makeWrapperClass(java.lang.Class origClass)
Make the wrapper class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean canMakeWrapperClass(java.lang.Class origClass)
origClass
- the original class
true
if we can make a wrapper (ie. class isn't
final, etc)public static java.lang.Class makeWrapperClass(java.lang.Class origClass)
origClass
- the original class
origClass
. This should never return
null
.public static java.lang.String getOrigMethodName(java.lang.Object javaObj, java.lang.String methodName)
javaObj
- the java objectmethodName
- the name of the method in the parent class
public static java.lang.String getOrigMethodName(java.lang.String methodName)
public static boolean isWrapperInstance(java.lang.Object javaObj)
javaObj
- the java object to test
true
if instance of auto-generated wrapper classpublic static void linkObjects(java.lang.Object javaObj, Scope scriptObj)
makeWrapperClass
method.
javaObj
- the java objectscriptObj
- the script objectpublic static Value getScriptObject(java.lang.Object javaObj)
javaObj
- the java object
null
public static final java.lang.Class getNonWrapperClass(java.lang.Class javaClass)
javaClass
- a java class that might be a wrapper class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |