| java.lang.Object org.mozilla.javascript.ScriptableObject org.mozilla.javascript.IdScriptableObject org.mozilla.javascript.BaseFunction org.mozilla.javascript.FunctionObject
Constructor Summary | |
public | FunctionObject(String name, Member methodOrConstructor, Scriptable scope) Create a JavaScript function object from a Java method.
The member argument must be either a java.lang.reflect.Method
or a java.lang.reflect.Constructor and must match one of two forms.
The first form is a member with zero or more parameters
of the following types: Object, String, boolean, Scriptable,
int, or double. |
Method Summary | |
public void | addAsConstructor(Scriptable scope, Scriptable prototype) Define this function as a JavaScript constructor.
Sets up the "prototype" and "constructor" properties. | public Object | call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) Performs conversions on argument types if needed and
invokes the underlying Java method or constructor. | public static Object | convertArg(Context cx, Scriptable scope, Object arg, int typeTag) | public static Object | convertArg(Context cx, Scriptable scope, Object arg, Class desired) | public Scriptable | createObject(Context cx, Scriptable scope) Return new
Scriptable instance using the default
constructor for the class of the underlying Java method. | static Method | findSingleMethod(Method[] methods, String name) | public int | getArity() Return the value defined by the method used to construct the object
(number of parameters of the method, or 1 if the method is a "varargs"
form). | public String | getFunctionName() | public int | getLength() Return the same value as
FunctionObject.getArity() . | static Method[] | getMethodList(Class clazz) Returns all public methods declared by the specified class. | public Member | getMethodOrConstructor() Get Java method or constructor this function represent. | public static int | getTypeTag(Class type) | void | initAsConstructor(Scriptable scope, Scriptable prototype) | boolean | isVarArgsConstructor() | boolean | isVarArgsMethod() |
JAVA_BOOLEAN_TYPE | final public static int JAVA_BOOLEAN_TYPE(Code) | | |
JAVA_DOUBLE_TYPE | final public static int JAVA_DOUBLE_TYPE(Code) | | |
JAVA_INT_TYPE | final public static int JAVA_INT_TYPE(Code) | | |
JAVA_OBJECT_TYPE | final public static int JAVA_OBJECT_TYPE(Code) | | |
JAVA_SCRIPTABLE_TYPE | final public static int JAVA_SCRIPTABLE_TYPE(Code) | | |
JAVA_STRING_TYPE | final public static int JAVA_STRING_TYPE(Code) | | |
JAVA_UNSUPPORTED_TYPE | final public static int JAVA_UNSUPPORTED_TYPE(Code) | | |
serialVersionUID | final static long serialVersionUID(Code) | | |
FunctionObject | public FunctionObject(String name, Member methodOrConstructor, Scriptable scope)(Code) | | Create a JavaScript function object from a Java method.
The member argument must be either a java.lang.reflect.Method
or a java.lang.reflect.Constructor and must match one of two forms.
The first form is a member with zero or more parameters
of the following types: Object, String, boolean, Scriptable,
int, or double. The Long type is not supported
because the double representation of a long (which is the
EMCA-mandated storage type for Numbers) may lose precision.
If the member is a Method, the return value must be void or one
of the types allowed for parameters.
The runtime will perform appropriate conversions based
upon the type of the parameter. A parameter type of
Object specifies that no conversions are to be done. A parameter
of type String will use Context.toString to convert arguments.
Similarly, parameters of type double, boolean, and Scriptable
will cause Context.toNumber, Context.toBoolean, and
Context.toObject, respectively, to be called.
If the method is not static, the Java 'this' value will
correspond to the JavaScript 'this' value. Any attempt
to call the function with a 'this' value that is not
of the right Java type will result in an error.
The second form is the variable arguments (or "varargs")
form. If the FunctionObject will be used as a constructor,
the member must have the following parameters
(Context cx, Object[] args, Function ctorObj,
boolean inNewExpr)
and if it is a Method, be static and return an Object result.
Otherwise, if the FunctionObject will not be used to define a
constructor, the member must be a static Method with parameters
(Context cx, Scriptable thisObj, Object[] args,
Function funObj)
and an Object result.
When the function varargs form is called as part of a function call,
the args parameter contains the
arguments, with thisObj
set to the JavaScript 'this' value. funObj
is the function object for the invoked function.
When the constructor varargs form is called or invoked while evaluating
a new expression, args contains the
arguments, ctorObj refers to this FunctionObject, and
inNewExpr is true if and only if a new
expression caused the call. This supports defining a function that
has different behavior when called as a constructor than when
invoked as a normal function call. (For example, the Boolean
constructor, when called as a function,
will convert to boolean rather than creating a new object.)
Parameters: name - the name of the function Parameters: methodOrConstructor - a java.lang.reflect.Method or a java.lang.reflect.Constructorthat defines the object Parameters: scope - enclosing scope of function See Also: org.mozilla.javascript.Scriptable |
createObject | public Scriptable createObject(Context cx, Scriptable scope)(Code) | | Return new
Scriptable instance using the default
constructor for the class of the underlying Java method.
Return null to indicate that the call method should be used to create
new objects.
|
getArity | public int getArity()(Code) | | Return the value defined by the method used to construct the object
(number of parameters of the method, or 1 if the method is a "varargs"
form).
|
getMethodList | static Method[] getMethodList(Class clazz)(Code) | | Returns all public methods declared by the specified class. This excludes
inherited methods.
Parameters: clazz - the class from which to pull public declared methods the public methods declared in the specified class See Also: Class.getDeclaredMethods |
getMethodOrConstructor | public Member getMethodOrConstructor()(Code) | | Get Java method or constructor this function represent.
|
isVarArgsConstructor | boolean isVarArgsConstructor()(Code) | | |
isVarArgsMethod | boolean isVarArgsMethod()(Code) | | |
Fields inherited from org.mozilla.javascript.BaseFunction | final static long serialVersionUID(Code)(Java Doc)
|
Methods inherited from org.mozilla.javascript.BaseFunction | public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)(Code)(Java Doc) public Scriptable construct(Context cx, Scriptable scope, Object[] args)(Code)(Java Doc) public Scriptable createObject(Context cx, Scriptable scope)(Code)(Java Doc) String decompile(int indent, int flags)(Code)(Java Doc) public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)(Code)(Java Doc) protected void fillConstructorProperties(IdFunctionObject ctor)(Code)(Java Doc) protected int findInstanceIdInfo(String s)(Code)(Java Doc) protected int findPrototypeId(String s)(Code)(Java Doc) public int getArity()(Code)(Java Doc) public String getClassName()(Code)(Java Doc) protected Scriptable getClassPrototype()(Code)(Java Doc) public String getFunctionName()(Code)(Java Doc) protected String getInstanceIdName(int id)(Code)(Java Doc) protected Object getInstanceIdValue(int id)(Code)(Java Doc) public int getLength()(Code)(Java Doc) protected int getMaxInstanceId()(Code)(Java Doc) final Object getPrototypeProperty()(Code)(Java Doc) public boolean hasInstance(Scriptable instance)(Code)(Java Doc) static void init(Scriptable scope, boolean sealed)(Code)(Java Doc) protected void initPrototypeId(int id)(Code)(Java Doc) static boolean isApply(IdFunctionObject f)(Code)(Java Doc) static boolean isApplyOrCall(IdFunctionObject f)(Code)(Java Doc) public void setImmunePrototypeProperty(Object value)(Code)(Java Doc) protected void setInstanceIdValue(int id, Object value)(Code)(Java Doc)
|
Methods inherited from org.mozilla.javascript.IdScriptableObject | final public void activatePrototypeMap(int maxPrototypeId)(Code)(Java Doc) protected void addIdFunctionProperty(Scriptable obj, Object tag, int id, String name, int arity)(Code)(Java Doc) final protected Object defaultGet(String name)(Code)(Java Doc) final protected void defaultPut(String name, Object value)(Code)(Java Doc) public void delete(String name)(Code)(Java Doc) public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)(Code)(Java Doc) final public IdFunctionObject exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)(Code)(Java Doc) protected void fillConstructorProperties(IdFunctionObject ctor)(Code)(Java Doc) protected int findInstanceIdInfo(String name)(Code)(Java Doc) protected int findPrototypeId(String name)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public int getAttributes(String name)(Code)(Java Doc) Object[] getIds(boolean getAll)(Code)(Java Doc) protected String getInstanceIdName(int id)(Code)(Java Doc) protected Object getInstanceIdValue(int id)(Code)(Java Doc) protected int getMaxInstanceId()(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) final public boolean hasPrototypeMap()(Code)(Java Doc) protected static EcmaError incompatibleCallError(IdFunctionObject f)(Code)(Java Doc) final public void initPrototypeConstructor(IdFunctionObject f)(Code)(Java Doc) protected void initPrototypeId(int id)(Code)(Java Doc) final public void initPrototypeMethod(Object tag, int id, String name, int arity)(Code)(Java Doc) final public void initPrototypeValue(int id, String name, Object value, int attributes)(Code)(Java Doc) protected static int instanceIdInfo(int attributes, int id)(Code)(Java Doc) public void put(String name, Scriptable start, Object value)(Code)(Java Doc) public void setAttributes(String name, int attributes)(Code)(Java Doc) protected void setInstanceIdValue(int id, Object value)(Code)(Java Doc)
|
Methods inherited from org.mozilla.javascript.ScriptableObject | void addLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes)(Code)(Java Doc) final public Object associateValue(Object key, Object value)(Code)(Java Doc) public boolean avoidObjectDetection()(Code)(Java Doc) static BaseFunction buildClassCtor(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static Object callMethod(Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args)(Code)(Java Doc) static void checkValidAttributes(int attributes)(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static void defineClass(Scriptable scope, Class clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public static String defineClass(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)(Java Doc) public void defineConst(String name, Scriptable start)(Code)(Java Doc) public static void defineConstProperty(Scriptable destination, String propertyName)(Code)(Java Doc) public void defineFunctionProperties(String[] names, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object value, int attributes)(Code)(Java Doc) public static void defineProperty(Scriptable destination, String propertyName, Object value, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Class clazz, int attributes)(Code)(Java Doc) public void defineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes)(Code)(Java Doc) public void delete(String name)(Code)(Java Doc) public void delete(int index)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean deleteProperty(Scriptable obj, int index)(Code)(Java Doc) protected Object equivalentValues(Object value)(Code)(Java Doc) public Object get(String name, Scriptable start)(Code)(Java Doc) public Object get(int index, Scriptable start)(Code)(Java Doc) public Object[] getAllIds()(Code)(Java Doc) final public Object getAssociatedValue(Object key)(Code)(Java Doc) final public int getAttributes(String name, Scriptable start)(Code)(Java Doc) final public int getAttributes(int index, Scriptable start)(Code)(Java Doc) public int getAttributes(String name)(Code)(Java Doc) public int getAttributes(int index)(Code)(Java Doc) abstract public String getClassName()(Code)(Java Doc) public static Scriptable getClassPrototype(Scriptable scope, String className)(Code)(Java Doc) public Object getDefaultValue(Class typeHint)(Code)(Java Doc) public static Object getDefaultValue(Scriptable object, Class typeHint)(Code)(Java Doc) public static Scriptable getFunctionPrototype(Scriptable scope)(Code)(Java Doc) public Object getGetterOrSetter(String name, int index, boolean isSetter)(Code)(Java Doc) public Object[] getIds()(Code)(Java Doc) Object[] getIds(boolean getAll)(Code)(Java Doc) public static Scriptable getObjectPrototype(Scriptable scope)(Code)(Java Doc) public Scriptable getParentScope()(Code)(Java Doc) public static Object getProperty(Scriptable obj, String name)(Code)(Java Doc) public static Object getProperty(Scriptable obj, int index)(Code)(Java Doc) public static Object[] getPropertyIds(Scriptable obj)(Code)(Java Doc) public Scriptable getPrototype()(Code)(Java Doc) public static Scriptable getTopLevelScope(Scriptable obj)(Code)(Java Doc) public static Object getTopScopeValue(Scriptable scope, Object key)(Code)(Java Doc) public boolean has(String name, Scriptable start)(Code)(Java Doc) public boolean has(int index, Scriptable start)(Code)(Java Doc) public boolean hasInstance(Scriptable instance)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, String name)(Code)(Java Doc) public static boolean hasProperty(Scriptable obj, int index)(Code)(Java Doc) public boolean isConst(String name)(Code)(Java Doc) protected boolean isGetterOrSetter(String name, int index, boolean setter)(Code)(Java Doc) final public boolean isSealed()(Code)(Java Doc) public void put(String name, Scriptable start, Object value)(Code)(Java Doc) public void put(int index, Scriptable start, Object value)(Code)(Java Doc) public void putConst(String name, Scriptable start, Object value)(Code)(Java Doc) public static void putConstProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, String name, Object value)(Code)(Java Doc) public static void putProperty(Scriptable obj, int index, Object value)(Code)(Java Doc) public static void redefineProperty(Scriptable obj, String name, boolean isConst)(Code)(Java Doc) public synchronized void sealObject()(Code)(Java Doc) final public void setAttributes(String name, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(int index, Scriptable start, int attributes)(Code)(Java Doc) public void setAttributes(String name, int attributes)(Code)(Java Doc) public void setAttributes(int index, int attributes)(Code)(Java Doc) public void setGetterOrSetter(String name, int index, Callable getterOrSeter, boolean isSetter)(Code)(Java Doc) public void setParentScope(Scriptable m)(Code)(Java Doc) public void setPrototype(Scriptable m)(Code)(Java Doc)
|
|
|