private static Object getRawElem(Scriptable target, long index) { if (index > Integer.MAX_VALUE) { return ScriptableObject.getProperty(target, Long.toString(index)); } else { return ScriptableObject.getProperty(target, (int) index); } }
public NativeErrorException() { super(ScriptableObject.getProperty(NativeError.this, "message").toString()); }
static Object lookupQualifiedName(Scriptable scope, String qualifiedName) { StringTokenizer st = new StringTokenizer(qualifiedName, "."); Object result = scope; while (st.hasMoreTokens()) { String s = st.nextToken(); result = ScriptableObject.getProperty((Scriptable)result, s); if (result == null || !(result instanceof Scriptable)) break; } return result; }
private static Object topScopeName(Context cx, Scriptable scope, String name) { if (cx.useDynamicScope) { scope = checkDynamicScope(cx.topCallScope, scope); } return ScriptableObject.getProperty(scope, name); }
private static String getString(Scriptable obj, String id) { Object value = ScriptableObject.getProperty(obj, id); if (value == NOT_FOUND) return ""; return ScriptRuntime.toString(value); }
public static Object getTopLevelProp(Scriptable scope, String id) { scope = ScriptableObject.getTopLevelScope(scope); return ScriptableObject.getProperty(scope, id); }
public static Object getObjectIndex(Scriptable obj, int index, Context cx) { if (obj instanceof XMLObject) { XMLObject xmlObject = (XMLObject)obj; return xmlObject.ecmaGet(cx, Integer.valueOf(index)); } Object result = ScriptableObject.getProperty(obj, index); if (result == Scriptable.NOT_FOUND) { result = Undefined.instance; } return result; }
/** * Replacement of {@link NativeArray#toArray()}. */ private static Object[] toArray(final NativeArray narray) { final long longLen = narray.getLength(); if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; final Object[] arr = new Object[len]; for (int i = 0; i < len; i++) { arr[i] = ScriptableObject.getProperty(narray, i); } return arr; }
/** * Replacement of {@link NativeArray#toArray()}. */ private static Object[] toArray(final NativeArray narray) { final long longLen = narray.getLength(); if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } final int len = (int) longLen; final Object[] arr = new Object[len]; for (int i = 0; i < len; i++) { arr[i] = ScriptableObject.getProperty(narray, i); } return arr; }
public static Function getFunction(Scriptable obj, String functionName) { Object x = ScriptableObject.getProperty(obj, functionName); if (x == Scriptable.NOT_FOUND) { // This method used to swallow the exception from calling // an undefined method. People have come to depend on this // somewhat dubious behavior. It allows people to avoid // implementing listener methods that they don't care about, // for instance. return null; } if (!(x instanceof Function)) throw ScriptRuntime.notFunctionError(x, functionName); return (Function)x; }
/** * {@inheritDoc} */ @Override public Object get(final Symbol key, final Scriptable start) { if (SymbolKey.ITERATOR.equals(key)) { return ScriptableObject.getProperty(start, "values"); } return super.get(key, start); }
/** * {@inheritDoc} */ @Override public Object get(final Symbol key, final Scriptable start) { if (SymbolKey.ITERATOR.equals(key)) { return ScriptableObject.getProperty(start, "entries"); } return super.get(key, start); }
public static XMLLib extractFromScopeOrNull(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // If library is not yet initialized, return null return null; } // Ensure lazily initialization of real XML library instance // which is done on first access to XML property ScriptableObject.getProperty(so, "XML"); return (XMLLib)so.getAssociatedValue(XML_LIB_KEY); }
/** * This is set after the make method is called, so we can't do this eagerly. */ public Throwable getCause() { Object javaException = ScriptableObject.getProperty(NativeError.this, "javaException"); if (javaException instanceof NativeJavaObject) { NativeJavaObject njo = (NativeJavaObject) javaException; return (Throwable)njo.unwrap(); } return super.getCause(); } }
static Function getExistingCtor(Context cx, Scriptable scope, String constructorName) { Object ctorVal = ScriptableObject.getProperty(scope, constructorName); if (ctorVal instanceof Function) { return (Function)ctorVal; } if (ctorVal == Scriptable.NOT_FOUND) { throw Context.reportRuntimeError1( "msg.ctor.not.found", constructorName); } else { throw Context.reportRuntimeError1( "msg.not.ctor", constructorName); } }
/** * Create a JavaScript exception wrapping the given JavaScript value * * @param value the JavaScript value thrown. */ public JavaScriptException(Object value, String sourceName, int lineNumber) { recordErrorOrigin(sourceName, lineNumber, null, 0); this.value = value; // if JavaScriptException is caused by a NativeError, link that as a nested exception if (value instanceof NativeError) { Object src = ScriptableObject.getProperty((NativeError) value, "at"); if (src instanceof Throwable) initCause((Throwable) src); } }
/** * <p>This method delegates the call to the parent select element.</p> * * <p>See {@link #put(String, Scriptable, Object)} for the corresponding setter behavior.</p> * * @param name {@inheritDoc} * @return {@inheritDoc} */ public Object getWithFallback(final String name) { if (!getBrowserVersion().isIE() && name.equals("childNodes")) { return NOT_FOUND; } // If the name was NOT_FOUND on the prototype, then just drop through // to search on the select element for IE only AND FF. final HTMLSelectElement select = (HTMLSelectElement) htmlSelect_.getScriptObject(); return ScriptableObject.getProperty(select, name); }
/** * <p>This method delegates the call to the parent select element.</p> * * <p>See {@link #put(String, Scriptable, Object)} for the corresponding setter behavior.</p> * * @param name {@inheritDoc} * @return {@inheritDoc} */ public Object getWithFallback(final String name) { if (!getBrowserVersion().isIE() && name.equals("childNodes")) { return NOT_FOUND; } // If the name was NOT_FOUND on the prototype, then just drop through // to search on the select element for IE only AND FF. final HTMLSelectElement select = (HTMLSelectElement) htmlSelect_.getScriptObject(); return ScriptableObject.getProperty(select, name); }
/** * <p>This method delegates the call to the parent select element.</p> * * <p>See {@link #put(String, Scriptable, Object)} for the corresponding setter behavior.</p> * * @param name {@inheritDoc} * @return {@inheritDoc} */ public Object getWithFallback(final String name) { if (!getBrowserVersion().isIE() && name.equals("childNodes")) { return NOT_FOUND; } // If the name was NOT_FOUND on the prototype, then just drop through // to search on the select element for IE only AND FF. final HTMLSelectElement select = (HTMLSelectElement) htmlSelect_.getScriptObject(); return ScriptableObject.getProperty(select, name); }
public static Object getObjectPropNoWarn(Object obj, String property, Context cx) { Scriptable sobj = toObjectOrNull(cx, obj); if (sobj == null) { throw undefReadError(obj, property); } if (obj instanceof XMLObject) { // TODO: fix as mentioned in note in method above getObjectProp(sobj, property, cx); } Object result = ScriptableObject.getProperty(sobj, property); if (result == Scriptable.NOT_FOUND) { return Undefined.instance; } return result; }