本文整理了Java中org.mozilla.javascript.WrapFactory
类的一些代码示例,展示了WrapFactory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WrapFactory
类的具体详情如下:
包路径:org.mozilla.javascript.WrapFactory
类名称: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.
[中]希望为Java对象提供自己的自定义包装的嵌入可以扩展该类,并在为给定上下文启用该类的实例或该类的扩展(通过在该上下文上调用setWrapFactory)后调用Context#setWrapFactory(WrapFactory),每当Rhino需要包装调用Java方法或访问Java字段产生的值时,它就会调用此类的方法。
代码示例来源:origin: rhq-project/rhq
/**
* This behaves exactly the same as the super class' method except the fact that
* the ConsString is considered "primitive" and is not wrapped in any manner.
* <p>
* This is then consistent with the rest of Rhino that expects ConsString as a possible
* implementation of the string.
*/
@Override
public Object wrap(Context cx, Scriptable scope, Object obj, Class<?> staticType) {
if (obj instanceof ConsString) {
return obj;
}
return super.wrap(cx, scope, obj, staticType);
}
}
代码示例来源:origin: org.alfresco/alfresco-repository
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType)
{
if (javaObject instanceof Map && !(javaObject instanceof ScriptableHashMap))
{
return new NativeMap(scope, (Map)javaObject);
}
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
}
}
代码示例来源:origin: rhino/js
/**
* Return the current WrapFactory, or null if none is defined.
* @see WrapFactory
* @since 1.5 Release 4
*/
public final WrapFactory getWrapFactory()
{
if (wrapFactory == null) {
wrapFactory = new WrapFactory();
}
return wrapFactory;
}
代码示例来源:origin: rhino/js
return obj;
if (!isJavaPrimitiveWrap()) {
if (obj instanceof String || obj instanceof Number
|| obj instanceof Boolean)
return NativeJavaArray.wrap(scope, obj);
return wrapAsJavaObject(cx, scope, obj, staticType);
代码示例来源:origin: geogebra/geogebra
args[i] = wf.wrap(cx, topScope, arg, null);
Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
代码示例来源:origin: geogebra/geogebra
return wrapFactory.wrap(cx, scope, javaObject,
ScriptRuntime.ClassClass);
Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope,
nestedClass);
nestedValue.setParentScope(this);
代码示例来源:origin: ro.isdc.wro4j/rhino
static Scriptable constructSpecific(Context cx, Scriptable scope,
Object[] args, MemberBox ctor)
{
Object instance = constructInternal(args, ctor);
// we need to force this to be wrapped, because construct _has_
// to return a scriptable
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
return cx.getWrapFactory().wrapNewObject(cx, topLevel, instance);
}
代码示例来源:origin: geogebra/geogebra
newValue = wrapFactory.wrapJavaClass(cx, getTopLevelScope(this), cl);
newValue.setPrototype(getPrototype());
代码示例来源:origin: io.apigee/rhino
args[i] = wf.wrap(cx, topScope, arg, null);
Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
代码示例来源:origin: io.apigee/rhino
return obj;
if (!isJavaPrimitiveWrap()) {
if (obj instanceof String || obj instanceof Number
|| obj instanceof Boolean)
return NativeJavaArray.wrap(scope, obj);
return wrapAsJavaObject(cx, scope, obj, staticType);
代码示例来源:origin: ro.isdc.wro4j/rhino
return wrapFactory.wrap(cx, scope, javaObject,
ScriptRuntime.ClassClass);
Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope,
nestedClass);
nestedValue.setParentScope(this);
代码示例来源:origin: geogebra/geogebra
static Scriptable constructSpecific(Context cx, Scriptable scope,
Object[] args, MemberBox ctor)
{
Object instance = constructInternal(args, ctor);
// we need to force this to be wrapped, because construct _has_
// to return a scriptable
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
return cx.getWrapFactory().wrapNewObject(cx, topLevel, instance);
}
代码示例来源:origin: com.github.tntim96/rhino
newValue = wrapFactory.wrapJavaClass(cx, getTopLevelScope(this), cl);
newValue.setPrototype(getPrototype());
代码示例来源:origin: RPTools/maptool
@SuppressWarnings("rawtypes")
@Override
public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
if (obj instanceof String || obj instanceof Number || obj instanceof Boolean) {
return obj;
} else if (obj instanceof Character) {
char[] a = { ((Character) obj).charValue() };
return new String(a);
}
return super.wrap(cx, scope, obj, staticType);
}
}
代码示例来源:origin: Alfresco/alfresco-repository
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType)
{
if (javaObject instanceof Map && !(javaObject instanceof ScriptableHashMap))
{
return new NativeMap(scope, (Map)javaObject);
}
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
}
}
代码示例来源:origin: com.github.tntim96/rhino
args[i] = wf.wrap(cx, topScope, arg, null);
Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
代码示例来源:origin: ro.isdc.wro4j/rhino
return obj;
if (!isJavaPrimitiveWrap()) {
if (obj instanceof String || obj instanceof Number
|| obj instanceof Boolean)
return NativeJavaArray.wrap(scope, obj);
return wrapAsJavaObject(cx, scope, obj, staticType);
代码示例来源:origin: com.github.tntim96/rhino
return wrapFactory.wrap(cx, scope, javaObject,
ScriptRuntime.ClassClass);
Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope,
nestedClass);
nestedValue.setParentScope(this);
代码示例来源:origin: geogebra/geogebra
/**
* Return the current WrapFactory, or null if none is defined.
* @see WrapFactory
* @since 1.5 Release 4
*/
public final WrapFactory getWrapFactory()
{
if (wrapFactory == null) {
wrapFactory = new WrapFactory();
}
return wrapFactory;
}
代码示例来源:origin: io.apigee/rhino
static Scriptable constructSpecific(Context cx, Scriptable scope,
Object[] args, MemberBox ctor)
{
Object instance = constructInternal(args, ctor);
// we need to force this to be wrapped, because construct _has_
// to return a scriptable
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
return cx.getWrapFactory().wrapNewObject(cx, topLevel, instance);
}
内容来源于网络,如有侵权,请联系作者删除!