| java.lang.Object oscript.classwrap.ClassWrapGen
ClassWrapGen | public class ClassWrapGen (Code) | | 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).
author: Rob Clark (rob@ti.com) author: version: 1.34 |
canMakeWrapperClass | public static boolean canMakeWrapperClass(Class origClass)(Code) | | Check if we can make a wrapper class for the specified class... this
is needed by JavaClassWrapper, which needs to know if it can construct
a wrapper class... but it wants to defer the act of actually making
the wrapper class.
Parameters: origClass - the original class true if we can make a wrapper (ie. class isn'tfinal, etc) |
getNonWrapperClass | final public static Class getNonWrapperClass(Class javaClass)(Code) | | 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.
Parameters: javaClass - a java class that might be a wrapper class a java class that is not a wrapper class |
getOrigMethodName | public static String getOrigMethodName(Object javaObj, String methodName)(Code) | | 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. To do this, you call the "orig" method.
To hide the naming convention, other code should use this method
to get the name of the "orig" method for the named method.
Parameters: javaObj - the java object Parameters: methodName - the name of the method in the parent class the mangled name of the method that calls the requestedmethod in the parent class, ie. the "orig" method. |
getScriptObject | public static Value getScriptObject(Object javaObj)(Code) | | Given a java object, which may be linked to a script object, return
the linked script object.
Parameters: javaObj - the java object the script object, or null |
isWrapperInstance | public static boolean isWrapperInstance(Object javaObj)(Code) | | Is the specified object an instance of a wrapper class?
Parameters: javaObj - the java object to test true if instance of auto-generated wrapper class |
linkObjects | public static void linkObjects(Object javaObj, Scope scriptObj)(Code) | | Link the specified java object and script object. The java object
should be an instance of a wrapper class generated by the
makeWrapperClass method.
Parameters: javaObj - the java object Parameters: scriptObj - the script object |
makeWrapperClass | public static synchronized Class makeWrapperClass(Class origClass)(Code) | | Make the wrapper class. Wrap all public non-final instance methods.
Parameters: origClass - the original class the auto-generated wrapper class, or if a wrapper class cannotbe generated, the origClass . This should never returnnull . |
|
|