/** * Wraps some objects used by HtmlUnit (like {@link NodeList}), or delegates directly to the parent class. * {@inheritDoc} * @see WrapFactory#wrapAsJavaObject(Context, Scriptable, Object, Class) */ @Override public Scriptable wrapAsJavaObject(final Context context, final Scriptable scope, final Object javaObject, final Class<?> staticType) { // TODO: should depend on the js configuration file final Scriptable resp; if (NodeList.class.equals(staticType) || NamedNodeMap.class.equals(staticType)) { resp = new ScriptableWrapper(scope, javaObject, staticType); } else { resp = super.wrapAsJavaObject(context, scope, javaObject, staticType); } return resp; } }
/** * Wrap an object newly created by a constructor call. * @param cx the current Context for this thread * @param scope the scope of the executing script * @param obj the object to be wrapped * @return the wrapped value. */ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
/** * Wraps some objects used by HtmlUnit (like {@link NodeList}), or delegates directly to the parent class. * {@inheritDoc} * @see WrapFactory#wrapAsJavaObject(Context, Scriptable, Object, Class) */ @Override public Scriptable wrapAsJavaObject(final Context context, final Scriptable scope, final Object javaObject, final Class<?> staticType) { // TODO: should depend on the js configuration file final Scriptable resp; if (NodeList.class.equals(staticType) || NamedNodeMap.class.equals(staticType)) { resp = new ScriptableWrapper(scope, javaObject, staticType); } else { resp = super.wrapAsJavaObject(context, scope, javaObject, staticType); } return resp; } }
/** * Wraps some objects used by HtmlUnit (like {@link NodeList}), or delegates directly to the parent class. * {@inheritDoc} * @see WrapFactory#wrapAsJavaObject(Context, Scriptable, Object, Class) */ @Override public Scriptable wrapAsJavaObject(final Context context, final Scriptable scope, final Object javaObject, final Class< ? > staticType) { // TODO: should depend on the js configuration file final Scriptable resp; if (NodeList.class.equals(staticType) || NamedNodeMap.class.equals(staticType)) { resp = new ScriptableWrapper(scope, javaObject, staticType); } else { resp = super.wrapAsJavaObject(context, scope, javaObject, staticType); } return resp; } }
/** * Wraps some objects used by HtmlUnit (like {@link NodeList}), or delegates directly to the parent class. * {@inheritDoc} * @see WrapFactory#wrapAsJavaObject(Context, Scriptable, Object, Class) */ @Override public Scriptable wrapAsJavaObject(final Context context, final Scriptable scope, final Object javaObject, final Class< ? > staticType) { // TODO: should depend on the js configuration file final Scriptable resp; if (NodeList.class.equals(staticType) || NamedNodeMap.class.equals(staticType)) { resp = new ScriptableWrapper(scope, javaObject, staticType); } else { resp = super.wrapAsJavaObject(context, scope, javaObject, staticType); } return resp; } }
/** * Wraps some objects used by HtmlUnit (like {@link NodeList}), or delegates directly to the parent class. * {@inheritDoc} * @see WrapFactory#wrapAsJavaObject(Context, Scriptable, Object, Class) */ @Override public Scriptable wrapAsJavaObject(final Context context, final Scriptable scope, final Object javaObject, final Class< ? > staticType) { // TODO: should depend on the js configuration file final Scriptable resp; if (NodeList.class.equals(staticType) || NamedNodeMap.class.equals(staticType)) { resp = new ScriptableWrapper(scope, javaObject, staticType); } else { resp = super.wrapAsJavaObject(context, scope, javaObject, staticType); } return resp; } }
return NativeJavaArray.wrap(scope, obj); return wrapAsJavaObject(cx, scope, obj, staticType);