org.mozilla.javascript
public class WrapFactory extends Object
Since: 1.5 Release 4
See Also: setWrapFactory
Method Summary | |
---|---|
boolean | isJavaPrimitiveWrap()
Return false if result of Java method, which is instance of
String , Number , Boolean and
Character , should be used directly as JavaScript primitive
type.
|
void | setJavaPrimitiveWrap(boolean value) |
Object | wrap(Context cx, Scriptable scope, Object obj, Class staticType)
Wrap the object.
|
Scriptable | wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType)
Wrap Java object as Scriptable instance to allow full access to its
methods and fields from JavaScript.
|
Scriptable | wrapNewObject(Context cx, Scriptable scope, Object obj)
Wrap an object newly created by a constructor call. |
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 WrapFactory to change this.See Also: isJavaPrimitiveWrap
The value returned must be one of
Parameters: cx the current Context for this thread scope the scope of the executing script obj the object to be wrapped. Note it can be null. staticType type hint. If security restrictions prevent to wrap object based on its class, staticType will be used instead.
Returns: the wrapped value.
WrapFactory and WrapFactory call this method when they can not convert javaObject to JavaScript primitive value or JavaScript array.
Subclasses can override the method to provide custom wrappers for Java objects.
Parameters: cx the current Context for this thread scope the scope of the executing script javaObject the object to be wrapped staticType type hint. If security restrictions prevent to wrap object based on its class, staticType will be used instead.
Returns: the wrapped value which shall not be null
Parameters: cx the current Context for this thread scope the scope of the executing script obj the object to be wrapped
Returns: the wrapped value.