org.mozilla.javascript

Class NativeJavaClass

Implemented Interfaces:
Callable, Function, Scriptable, Serializable, Wrapper

public class NativeJavaClass
extends NativeJavaObject
implements Function

This class reflects Java classes into the JavaScript environment, mainly for constructors and static members. We lazily reflect properties, and currently do not guarantee that a single j.l.Class is only reflected once into the JS environment, although we should. The only known case where multiple reflections are possible occurs when a j.l.Class is wrapped as part of a method return or property access, rather than by walking the Packages/java tree.
Author:
Mike Shaver
See Also:
NativeJavaArray, NativeJavaObject, NativeJavaPackage

Field Summary

Fields inherited from class org.mozilla.javascript.NativeJavaObject

javaObject, members, parent, prototype, staticType

Fields inherited from interface org.mozilla.javascript.Scriptable

NOT_FOUND

Constructor Summary

NativeJavaClass()
NativeJavaClass(Scriptable scope, Class cl)

Method Summary

Object
call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
Perform the call.
Scriptable
construct(Context cx, Scriptable scope, Object[] args)
Object
get(String name, Scriptable start)
String
getClassName()
Class
getClassObject()
Object
getDefaultValue(Class hint)
Object[]
getIds()
boolean
has(String name, Scriptable start)
boolean
hasInstance(Scriptable value)
Determines if prototype is a wrapped Java object and performs a Java "instanceof".
protected void
initMembers()
void
put(String name, Scriptable start, Object value)
String
toString()

Methods inherited from class org.mozilla.javascript.NativeJavaObject

canConvert, coerceType, delete, delete, get, get, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, has, hasInstance, initMembers, put, put, setParentScope, setPrototype, unwrap, wrap

Constructor Details

NativeJavaClass

public NativeJavaClass()

NativeJavaClass

public NativeJavaClass(Scriptable scope,
                       Class cl)

Method Details

call

public Object call(Context cx,
                   Scriptable scope,
                   Scriptable thisObj,
                   Object[] args)
Perform the call.
Specified by:
call in interface Function
call in interface Callable
Parameters:
cx - the current Context for this thread
scope - the scope to use to resolve properties.
thisObj - the JavaScript this object
args - the array of arguments
Returns:
the result of the call

construct

public Scriptable construct(Context cx,
                            Scriptable scope,
                            Object[] args)
Specified by:
construct in interface Function

get

public Object get(String name,
                  Scriptable start)
Specified by:
get in interface Scriptable
Overrides:
get in interface NativeJavaObject

getClassName

public String getClassName()
Specified by:
getClassName in interface Scriptable
Overrides:
getClassName in interface NativeJavaObject

getClassObject

public Class getClassObject()

getDefaultValue

public Object getDefaultValue(Class hint)
Specified by:
getDefaultValue in interface Scriptable
Overrides:
getDefaultValue in interface NativeJavaObject

getIds

public Object[] getIds()
Specified by:
getIds in interface Scriptable
Overrides:
getIds in interface NativeJavaObject

has

public boolean has(String name,
                   Scriptable start)
Specified by:
has in interface Scriptable
Overrides:
has in interface NativeJavaObject

hasInstance

public boolean hasInstance(Scriptable value)
Determines if prototype is a wrapped Java object and performs a Java "instanceof". Exception: if value is an instance of NativeJavaClass, it isn't considered an instance of the Java class; this forestalls any name conflicts between java.lang.Class's methods and the static methods exposed by a JavaNativeClass.
Specified by:
hasInstance in interface Scriptable
Overrides:
hasInstance in interface NativeJavaObject

initMembers

protected void initMembers()
Overrides:
initMembers in interface NativeJavaObject

put

public void put(String name,
                Scriptable start,
                Object value)
Specified by:
put in interface Scriptable
Overrides:
put in interface NativeJavaObject

toString

public String toString()