org.mozilla.javascript

Class NativeJavaObject

public class NativeJavaObject extends Object implements Scriptable, Wrapper, Serializable

This class reflects non-Array Java objects into the JavaScript environment. It reflect fields directly, and uses NativeJavaMethod objects to reflect (possibly overloaded) methods.

Author: Mike Shaver

See Also: NativeJavaArray NativeJavaPackage NativeJavaClass

Field Summary
protected ObjectjavaObject
protected JavaMembersmembers
protected Scriptableparent
The parent scope of this object.
protected Scriptableprototype
The prototype of this object.
protected ClassstaticType
Constructor Summary
NativeJavaObject()
NativeJavaObject(Scriptable scope, Object javaObject, Class staticType)
Method Summary
static booleancanConvert(Object fromObj, Class to)
Determine whether we can/should convert between the given type and the desired one.
static ObjectcoerceType(Class type, Object value)
Not intended for public use.
voiddelete(String name)
voiddelete(int index)
Objectget(String name, Scriptable start)
Objectget(int index, Scriptable start)
StringgetClassName()
ObjectgetDefaultValue(Class hint)
Object[]getIds()
ScriptablegetParentScope()
Returns the parent (enclosing) scope of the object.
ScriptablegetPrototype()
booleanhas(String name, Scriptable start)
booleanhas(int index, Scriptable start)
booleanhasInstance(Scriptable value)
protected voidinitMembers()
voidput(String name, Scriptable start, Object value)
voidput(int index, Scriptable start, Object value)
voidsetParentScope(Scriptable m)
Sets the parent (enclosing) scope of the object.
voidsetPrototype(Scriptable m)
Sets the prototype of the object.
Objectunwrap()
static Objectwrap(Scriptable scope, Object obj, Class staticType)

Field Detail

javaObject

protected transient Object javaObject

members

protected transient JavaMembers members

parent

protected Scriptable parent
The parent scope of this object.

prototype

protected Scriptable prototype
The prototype of this object.

staticType

protected transient Class staticType

Constructor Detail

NativeJavaObject

public NativeJavaObject()

NativeJavaObject

public NativeJavaObject(Scriptable scope, Object javaObject, Class staticType)

Method Detail

canConvert

public static boolean canConvert(Object fromObj, Class to)
Determine whether we can/should convert between the given type and the desired one. This should be superceded by a conversion-cost calculation function, but for now I'll hide behind precedent.

coerceType

public static Object coerceType(Class type, Object value)

Deprecated: as of 1.5 Release 4

Not intended for public use. Callers should use the public API Context.toType.

See Also: .

delete

public void delete(String name)

delete

public void delete(int index)

get

public Object get(String name, Scriptable start)

get

public Object get(int index, Scriptable start)

getClassName

public String getClassName()

getDefaultValue

public Object getDefaultValue(Class hint)

getIds

public Object[] getIds()

getParentScope

public Scriptable getParentScope()
Returns the parent (enclosing) scope of the object.

getPrototype

public Scriptable getPrototype()

has

public boolean has(String name, Scriptable start)

has

public boolean has(int index, Scriptable start)

hasInstance

public boolean hasInstance(Scriptable value)

initMembers

protected void initMembers()

put

public void put(String name, Scriptable start, Object value)

put

public void put(int index, Scriptable start, Object value)

setParentScope

public void setParentScope(Scriptable m)
Sets the parent (enclosing) scope of the object.

setPrototype

public void setPrototype(Scriptable m)
Sets the prototype of the object.

unwrap

public Object unwrap()

wrap

public static Object wrap(Scriptable scope, Object obj, Class staticType)

Deprecated: Use {@link Context#getWrapFactory()} together with calling {@link WrapFactory#wrap(Context cx, Scriptable scope, Object obj, Class)}