|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mozilla.javascript.WrapFactory
Embeddings that wish to provide their own custom wrappings for Java
objects may extend this class and call
Context.setWrapFactory(WrapFactory)
Once an instance of this class or an extension of this class is enabled
for a given context (by calling setWrapFactory on that context), Rhino
will call the methods of this class whenever it needs to wrap a value
resulting from a call to a Java method or an access to a Java field.
Context.setWrapFactory(WrapFactory)
Constructor Summary | |
---|---|
WrapFactory()
|
Method Summary | |
---|---|
boolean |
isJavaPrimitiveWrap()
Return false if result of Java method, which is instance of
String |
void |
setJavaPrimitiveWrap(boolean value)
|
java.lang.Object |
wrap(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
java.lang.Object obj,
java.lang.Class staticType)
Wrap the object. |
org.mozilla.javascript.Scriptable |
wrapNewObject(org.mozilla.javascript.Context cx,
org.mozilla.javascript.Scriptable scope,
java.lang.Object obj)
Wrap an object newly created by a constructor call. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WrapFactory()
Method Detail |
public java.lang.Object wrap(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.Object obj, java.lang.Class staticType)
The value returned must be one of
cx
- the current Context for this threadscope
- the scope of the executing scriptobj
- the object to be wrapped. Note it can be null.
public org.mozilla.javascript.Scriptable wrapNewObject(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.Object obj)
cx
- the current Context for this threadscope
- the scope of the executing scriptobj
- the object to be wrapped
public final boolean isJavaPrimitiveWrap()
false
if result of Java method, which is instance of
String, Number, Boolean and
Character, should be used directly as JavaScript primitive
type.
By default the method returns true to indicate that instances of
String, Number, Boolean and
Character should be wrapped as any other Java object and
scripts can access any Java method available in these objects.
Use setJavaPrimitiveWrap(boolean)
to change this.
public final void setJavaPrimitiveWrap(boolean value)
isJavaPrimitiveWrap()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |