/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#getClassName */ public String getClassName() { return obj.getClassName(); } /**
static String defaultObjectToString(Scriptable obj) { return "[object " + obj.getClassName() + ']'; }
if(val instanceof Integer) { Integer valInt = (Integer) val; System.out.println(valInt); } else if(val instanceof Scriptable) { //Rhino class embedes any js value Scriptable s = (Scriptable) val; String className = s.getClassName();// ECMA class name System.out.println(className); if(className.toLowerCase().equals("number")) { System.out.println(Context.toNumber(val)); } }
/** * Returns the JavaScript class name. * @return the JavaScript class name */ @Override public String getClassName() { if (className_ != null) { return className_; } if (getPrototype() != null) { return getPrototype().getClassName(); } String className = getClass().getSimpleName(); if (className.isEmpty()) { // for anonymous class className = getClass().getSuperclass().getSimpleName(); } return className; }
/** * Returns the JavaScript class name. * @return the JavaScript class name */ @Override public String getClassName() { if (className_ != null) { return className_; } if (getPrototype() != null) { return getPrototype().getClassName(); } String className = getClass().getSimpleName(); if (className.isEmpty()) { // for anonymous class className = getClass().getSuperclass().getSimpleName(); } return className; }
@Override String decompile(int indent, int flags) { StringBuffer sb = new StringBuffer(); boolean justbody = (0 != (flags & Decompiler.ONLY_BODY_FLAG)); if (!justbody) { sb.append("function "); sb.append(getFunctionName()); sb.append("() { "); } sb.append("[native code for "); if (idcall instanceof Scriptable) { Scriptable sobj = (Scriptable)idcall; sb.append(sobj.getClassName()); sb.append('.'); } sb.append(getFunctionName()); sb.append(", arity="); sb.append(getArity()); sb.append(justbody ? "]\n" : "] }\n"); return sb.toString(); }
LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName());
LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName());
/** * Define this function as a JavaScript constructor. * <p> * Sets up the "prototype" and "constructor" properties. Also * calls setParent and setPrototype with appropriate values. * Then adds the function object as a property of the given scope, using * <code>prototype.getClassName()</code> * as the name of the property. * * @param scope the scope in which to define the constructor (typically * the global object) * @param prototype the prototype object * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#setParentScope * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#setPrototype * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#getClassName */ public void addAsConstructor(Scriptable scope, Scriptable prototype) { initAsConstructor(scope, prototype); defineProperty(scope, prototype.getClassName(), this, ScriptableObject.DONTENUM); }
if (level == 0) { sb.append("[object "); sb.append(((Delegator) val).getDelegee().getClassName()); sb.append("]");
if (level == 0) { sb.append("[object "); sb.append(((Delegator) val).getDelegee().getClassName()); sb.append(']');
private static String formatToString(final Object o) { if (o == null) { return "null"; } else if (o instanceof NativeFunction) { return ((NativeFunction) o).toString(); } else if (o instanceof BaseFunction) { return "function " + ((BaseFunction) o).getFunctionName() + "\n" + " [native code]\n" + "}"; } else if (o instanceof NativeArray) { // If an array is embedded inside another array, just return // "[object Object]" return "[object Object]"; } else if (o instanceof Delegator) { return "[object " + ((Delegator) o).getDelegee().getClassName() + "]"; } else if (o instanceof NativeObject) { return "[object " + ((NativeObject) o).getClassName() + "]"; } else if (o instanceof SimpleScriptable) { return "[object " + ((SimpleScriptable) o).getClassName() + "]"; } else { return o.toString(); } }
private static String formatToString(final Object o) { if (o == null) { return "null"; } else if (o instanceof NativeFunction) { return ((NativeFunction) o).toString(); } else if (o instanceof BaseFunction) { return "function " + ((BaseFunction) o).getFunctionName() + "\n" + " [native code]\n" + "}"; } else if (o instanceof NativeArray) { // If an array is embedded inside another array, just return // "[object Object]" return "[object Object]"; } else if (o instanceof Delegator) { return "[object " + ((Delegator) o).getDelegee().getClassName() + "]"; } else if (o instanceof NativeObject) { return "[object " + ((NativeObject) o).getClassName() + "]"; } else if (o instanceof SimpleScriptable) { return "[object " + ((SimpleScriptable) o).getClassName() + "]"; } else { return o.toString(); } }
if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name;
String className = proto.getClassName();
|| "Image".equals(hostClassSimpleName) || "Option".equals(hostClassSimpleName)) { final Object prototypeProperty = ScriptableObject.getProperty(window, prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); if (!hostClassSimpleName.equals(prototype.getClassName())) { if (prototypeProperty == UniqueTag.NOT_FOUND) { ScriptableObject.deleteProperty(window, prototype.getClassName()); ScriptableObject.defineProperty(window, prototype.getClassName(), prototypeProperty, ScriptableObject.DONTENUM); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName());
|| "Image".equals(hostClassSimpleName) || "Option".equals(hostClassSimpleName)) { final Object prototypeProperty = ScriptableObject.getProperty(window, prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); if (!hostClassSimpleName.equals(prototype.getClassName())) { if (prototypeProperty == UniqueTag.NOT_FOUND) { ScriptableObject.deleteProperty(window, prototype.getClassName()); ScriptableObject.defineProperty(window, prototype.getClassName(), prototypeProperty, ScriptableObject.DONTENUM); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName()); LOG.warn("Error during JavaScriptEngine.init(WebWindow, Context)" + newline + e.getMessage() + newline + "prototype: " + prototype.getClassName());