/** * @deprecated EcmaError error instances should not be constructed * explicitly since they are generated by the engine. */ public EcmaError(Scriptable nativeError, String sourceName, int lineNumber, int columnNumber, String lineSource) { this("InternalError", ScriptRuntime.toString(nativeError), sourceName, lineNumber, lineSource, columnNumber); }
/** * Convert the value to a JavaScript String value. * <p> * See ECMA 9.8. * <p> * @param value a JavaScript value * @return the corresponding String value converted using * the ECMA rules */ public static String toString(Object value) { return ScriptRuntime.toString(value); }
public static String toString(Object[] args, int index) { return (index < args.length) ? toString(args[index]) : "undefined"; }
/** * If d is exact int value, return its value wrapped as Integer * and othewise return d converted to String. */ static Object getIndexObject(double d) { int i = (int)d; if (i == d) { return Integer.valueOf(i); } return toString(d); }
public static RuntimeException undefWriteError(Object object, Object id, Object value) { String idStr = (id == null) ? "null" : id.toString(); String valueStr = (value instanceof Scriptable) ? value.toString() : toString(value); return typeError3("msg.undef.prop.write", toString(object), idStr, valueStr); }
public static String add(Object val1, String val2) { return toString(val1).concat(val2); }
public static String add(String val1, Object val2) { return val1.concat(toString(val2)); }
public static RuntimeException undefReadError(Object object, Object id) { String idStr = (id == null) ? "null" : id.toString(); return typeError2("msg.undef.prop.read", toString(object), idStr); }
private static String getString(Scriptable obj, String id) { Object value = ScriptableObject.getProperty(obj, id); if (value == NOT_FOUND) return ""; return ScriptRuntime.toString(value); }
private static int js_lastIndexOf(String target, Object[] args) { String search = ScriptRuntime.toString(args, 0); double end = ScriptRuntime.toNumber(args, 1); if (end != end || end > target.length()) end = target.length(); else if (end < 0) end = 0; return target.lastIndexOf(search, (int)end); }
@Override public void put(String name, Scriptable start, Object value) { if (this == thePrototypeInstance) super.put(name, start, value); else System.getProperties().put(name, ScriptRuntime.toString(value)); }
private static int js_indexOf(String target, Object[] args) { String search = ScriptRuntime.toString(args, 0); double begin = ScriptRuntime.toInteger(args, 1); if (begin > target.length()) { return -1; } else { if (begin < 0) begin = 0; return target.indexOf(search, (int)begin); } }
public static RuntimeException undefCallError(Object object, Object id) { String idStr = (id == null) ? "null" : id.toString(); return typeError2("msg.undef.method.call", toString(object), idStr); }
private static RuntimeException notXmlError(Object value) { throw typeError1("msg.isnt.xml.object", toString(value)); }
public static Object getObjectIndex(Object obj, double dblIndex, Context cx) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw undefReadError(obj, toString(dblIndex)); } int index = (int)dblIndex; if (index == dblIndex) { return getObjectIndex(sobj, index, cx); } else { String s = toString(dblIndex); return getObjectProp(sobj, s, cx); } }
public static RuntimeException notFunctionError(Object obj, Object value, String propertyName) { // Use obj and value for better error reporting String objString = toString(obj); if (value == Scriptable.NOT_FOUND) { return typeError2("msg.function.not.found.in", propertyName, objString); } return typeError3("msg.isnt.function.in", propertyName, objString, typeof(value)); }
public void defineOwnProperties(Context cx, ScriptableObject props) { Object[] ids = props.getIds(); for (Object id : ids) { String name = ScriptRuntime.toString(id); Object descObj = props.get(id); ScriptableObject desc = ensureScriptableObject(descObj); checkValidPropertyDefinition(getSlot(name, 0, SLOT_QUERY), desc); } for (Object id : ids) { String name = ScriptRuntime.toString(id); ScriptableObject desc = (ScriptableObject) props.get(id); defineOwnProperty(cx, name, desc, false); } }
public static Scriptable enterWith(Object obj, Context cx, Scriptable scope) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw typeError1("msg.undef.with", toString(obj)); } if (sobj instanceof XMLObject) { XMLObject xmlObject = (XMLObject)sobj; return xmlObject.enterWith(scope); } return new NativeWith(scope, sobj); }
/** * @deprecated The method is only present for compatibility. */ public static Object call(Context cx, Object fun, Object thisArg, Object[] args, Scriptable scope) { if (!(fun instanceof Function)) { throw notFunctionError(toString(fun)); } Function function = (Function)fun; Scriptable thisObj = toObjectOrNull(cx, thisArg); if (thisObj == null) { throw undefCallError(thisObj, "function"); } return function.call(cx, scope, thisObj, args); }
@Override protected void setInstanceIdValue(int id, Object value) { int shifted = id - super.getMaxInstanceId(); switch (shifted) { case Id_multiline: case Id_STAR: getImpl().multiline = ScriptRuntime.toBoolean(value); return; case Id_input: case Id_UNDERSCORE: getImpl().input = ScriptRuntime.toString(value); return; } super.setInstanceIdValue(id, value); }