/** * Call a method of an object. * @param obj the JavaScript object * @param methodName the name of the function property * @param args the arguments for the call * * @see Context#getCurrentContext() */ public static Object callMethod(Scriptable obj, String methodName, Object[] args) { return callMethod(null, obj, methodName, args); }
@Override public short acceptNode(final Node n) { final Object response = ScriptableObject.callMethod(filter, "acceptNode", new Object[] {n}); return (short) Context.toNumber(response); } };
@Override public short acceptNode(final Node n) { final Object response = ScriptableObject.callMethod(filter, "acceptNode", new Object[] {n}); return (short) Context.toNumber(response); } };
@Override public short acceptNode(final Node n) { final Object response = ScriptableObject.callMethod(filter, "acceptNode", new Object[] {n}); return (short) Context.toNumber(response); } };
/** * Calls a JavaScript method. * Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript. * * @param methodName the name of the JavaScript method to be invoked * @param args an array of Java object to be passed as arguments to the method * @return result result of the method * @throws JSException in case or error */ public Object call(final String methodName, final Object[] args) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject call '" + methodName + "(" + Arrays.toString(args) + ")'"); } final Object jsResult = ScriptableObject.callMethod(scriptableObject_, methodName, args); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; }
/** * Calls a JavaScript method. * Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript. * * @param methodName the name of the JavaScript method to be invoked * @param args an array of Java object to be passed as arguments to the method * @return result result of the method * @throws JSException in case or error */ public Object call(final String methodName, final Object[] args) throws JSException { if (LOG.isInfoEnabled()) { LOG.info("JSObject call '" + methodName + "(" + Arrays.toString(args) + ")'"); } final Object jsResult = ScriptableObject.callMethod(scriptableObject_, methodName, args); if (jsResult instanceof ScriptableObject) { return new JSObject((ScriptableObject) jsResult); } if (jsResult instanceof ConsString) { return ((ConsString) jsResult).toString(); } return jsResult; }
if (ScriptableObject.hasProperty(scriptable, "getProperty")) { final Object selectionNS = ScriptableObject.callMethod(scriptable, "getProperty", new Object[]{"SelectionNamespaces"}); if (selectionNS != null && !selectionNS.toString().isEmpty()) { final Map<String, String> namespaces = parseSelectionNamespaces(selectionNS.toString());
if (ScriptableObject.hasProperty(scriptable, "getProperty")) { final Object selectionNS = ScriptableObject.callMethod(scriptable, "getProperty", new Object[]{"SelectionNamespaces"}); if (selectionNS != null && !selectionNS.toString().isEmpty()) { final Map<String, String> namespaces = parseSelectionNamespaces(selectionNS.toString());
@Override public short acceptNode(final org.w3c.dom.Node n) { final Object[] args = new Object[] {((DomNode) n).getScriptableObject()}; final Object response; if (filter instanceof Callable) { response = ((Callable) filter).call(Context.getCurrentContext(), filter, filter, args); } else { if (filterFunctionOnly) { throw Context.reportRuntimeError("only a function is allowed as filter"); } response = ScriptableObject.callMethod(filter, "acceptNode", args); } return (short) Context.toNumber(response); } };
@Override public short acceptNode(final org.w3c.dom.Node n) { final Object[] args = new Object[] {((DomNode) n).getScriptableObject()}; final Object response; if (filter instanceof Callable) { response = ((Callable) filter).call(Context.getCurrentContext(), filter, filter, args); } else { if (filterFunctionOnly) { throw Context.reportRuntimeError("only a function is allowed as filter"); } response = ScriptableObject.callMethod(filter, "acceptNode", args); } return (short) Context.toNumber(response); } };
ScriptableObject next = (ScriptableObject) ScriptableObject.callMethod(scriptable, "next", null); boolean done = (boolean) next.get(ES6Iterator.DONE_PROPERTY); Object value = next.get(ES6Iterator.VALUE_PROPERTY); processor.accept(value); next = (ScriptableObject) ScriptableObject.callMethod(scriptable, "next", null); done = (boolean) next.get(ES6Iterator.DONE_PROPERTY); value = next.get(ES6Iterator.VALUE_PROPERTY);
ScriptableObject next = (ScriptableObject) ScriptableObject.callMethod(scriptable, "next", null); boolean done = (boolean) next.get(ES6Iterator.DONE_PROPERTY); Object value = next.get(ES6Iterator.VALUE_PROPERTY); processor.accept(value); next = (ScriptableObject) ScriptableObject.callMethod(scriptable, "next", null); done = (boolean) next.get(ES6Iterator.DONE_PROPERTY); value = next.get(ES6Iterator.VALUE_PROPERTY);