/** * 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); } }
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); } }
/** * 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; }
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);
args[i] = wf.wrap(cx, topScope, arg, null); Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
return wrapFactory.wrap(cx, scope, javaObject, ScriptRuntime.ClassClass); Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope, nestedClass); nestedValue.setParentScope(this);
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); }
newValue = wrapFactory.wrapJavaClass(cx, getTopLevelScope(this), cl); newValue.setPrototype(getPrototype());
args[i] = wf.wrap(cx, topScope, arg, null); Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
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);
return wrapFactory.wrap(cx, scope, javaObject, ScriptRuntime.ClassClass); Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope, nestedClass); nestedValue.setParentScope(this);
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); }
newValue = wrapFactory.wrapJavaClass(cx, getTopLevelScope(this), cl); newValue.setPrototype(getPrototype());
@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); } }
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); } }
args[i] = wf.wrap(cx, topScope, arg, null); Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null);
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);
return wrapFactory.wrap(cx, scope, javaObject, ScriptRuntime.ClassClass); Scriptable nestedValue = wrapFactory.wrapJavaClass(cx, scope, nestedClass); nestedValue.setParentScope(this);
/** * 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; }
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); }