protected boolean isDataDescriptor(ScriptableObject desc) { return hasProperty(desc, "value") || hasProperty(desc, "writable"); }
protected boolean isAccessorDescriptor(ScriptableObject desc) { return hasProperty(desc, "get") || hasProperty(desc, "set"); }
/** * The static Reflect.has() method works like the in operator as a function. * * @param target The target object in which to look for the property. * @param propertyKey The name of the property to check. * @return true or false */ @JsxStaticFunction public boolean has(final Scriptable target, final String propertyKey) { return ScriptableObject.hasProperty(target, propertyKey); } }
/** * The static Reflect.has() method works like the in operator as a function. * * @param target The target object in which to look for the property. * @param propertyKey The name of the property to check. * @return true or false */ @JsxStaticFunction public boolean has(final Scriptable target, final String propertyKey) { return ScriptableObject.hasProperty(target, propertyKey); } }
@Override public Object get(String id, Scriptable start) { if (id.equals("length")) return Integer.valueOf(length); Object result = super.get(id, start); if (result == NOT_FOUND && !ScriptableObject.hasProperty(getPrototype(), id)) { throw Context.reportRuntimeError2( "msg.java.member.not.found", array.getClass().getName(), id); } return result; }
public static boolean hasObjectElem(Scriptable target, Object elem, Context cx) { boolean result; if (target instanceof XMLObject) { XMLObject xmlObject = (XMLObject)target; result = xmlObject.ecmaHas(cx, elem); } else { String s = toStringIdOrIndex(cx, elem); if (s == null) { int index = lastIndexResult(cx); result = ScriptableObject.hasProperty(target, index); } else { result = ScriptableObject.hasProperty(target, s); } } return result; }
/** * Returns {@code true} if the attribute is a custom property. * @return {@code true} if the attribute is a custom property */ @JsxGetter(IE) public boolean isExpando() { final Object owner = getOwnerElement(); if (null == owner) { return false; } return !ScriptableObject.hasProperty((Scriptable) owner, getName()); }
/** * Returns {@code true} if the attribute is a custom property. * @return {@code true} if the attribute is a custom property */ @JsxGetter(IE) public boolean isExpando() { final Object owner = getOwnerElement(); if (null == owner) { return false; } return !ScriptableObject.hasProperty((Scriptable) owner, getName()); }
public String[] getPrompts(Context cx) { if (ScriptableObject.hasProperty(this, "prompts")) { Object promptsJS = ScriptableObject.getProperty(this, "prompts"); if (promptsJS instanceof Scriptable) { Scriptable s = (Scriptable) promptsJS; if (ScriptableObject.hasProperty(s, 0) && ScriptableObject.hasProperty(s, 1)) { Object elem0 = ScriptableObject.getProperty(s, 0); if (elem0 instanceof Function) { elem0 = ((Function) elem0).call(cx, this, s, new Object[0]); } prompts[0] = Context.toString(elem0); Object elem1 = ScriptableObject.getProperty(s, 1); if (elem1 instanceof Function) { elem1 = ((Function) elem1).call(cx, this, s, new Object[0]); } prompts[1] = Context.toString(elem1); } } } return prompts; }
/** * An IE-only method which clears all custom attributes. */ @JsxFunction(IE) public void clearAttributes() { final HtmlElement node = getDomNodeOrDie(); // Remove custom attributes defined directly in HTML. final List<String> removals = new ArrayList<>(); for (final String attributeName : node.getAttributesMap().keySet()) { // Quick hack to figure out what's a "custom" attribute, and what isn't. // May not be 100% correct. if (!ScriptableObject.hasProperty(getPrototype(), attributeName)) { removals.add(attributeName); } } for (final String attributeName : removals) { node.removeAttribute(attributeName); } // Remove custom attributes defined at runtime via JavaScript. for (final Object id : getAllIds()) { if (id instanceof Integer) { final int i = ((Integer) id).intValue(); delete(i); } else if (id instanceof String) { delete((String) id); } } }
/** * An IE-only method which clears all custom attributes. */ public void jsxFunction_clearAttributes() { final HtmlElement node = getDomNodeOrDie(); // Remove custom attributes defined directly in HTML. final List<String> removals = new ArrayList<String>(); for (final String attributeName : node.getAttributesMap().keySet()) { // Quick hack to figure out what's a "custom" attribute, and what isn't. // May not be 100% correct. if (!ScriptableObject.hasProperty(getPrototype(), attributeName)) { removals.add(attributeName); } } for (final String attributeName : removals) { node.removeAttribute(attributeName); } // Remove custom attributes defined at runtime via JavaScript. for (final Object id : this.getAllIds()) { if (id instanceof Integer) { delete((Integer) id); } else if (id instanceof String) { delete((String) id); } } }
/** * An IE-only method which clears all custom attributes. */ @JsxFunction(IE) public void clearAttributes() { final HtmlElement node = getDomNodeOrDie(); // Remove custom attributes defined directly in HTML. final List<String> removals = new ArrayList<>(); for (final String attributeName : node.getAttributesMap().keySet()) { // Quick hack to figure out what's a "custom" attribute, and what isn't. // May not be 100% correct. if (!ScriptableObject.hasProperty(getPrototype(), attributeName)) { removals.add(attributeName); } } for (final String attributeName : removals) { node.removeAttribute(attributeName); } // Remove custom attributes defined at runtime via JavaScript. for (final Object id : getAllIds()) { if (id instanceof Integer) { final int i = ((Integer) id).intValue(); delete(i); } else if (id instanceof String) { delete((String) id); } } }
/** * An IE-only method which clears all custom attributes. */ public void jsxFunction_clearAttributes() { final HtmlElement node = getDomNodeOrDie(); // Remove custom attributes defined directly in HTML. final List<String> removals = new ArrayList<String>(); for (final String attributeName : node.getAttributesMap().keySet()) { // Quick hack to figure out what's a "custom" attribute, and what isn't. // May not be 100% correct. if (!ScriptableObject.hasProperty(getPrototype(), attributeName)) { removals.add(attributeName); } } for (final String attributeName : removals) { node.removeAttribute(attributeName); } // Remove custom attributes defined at runtime via JavaScript. for (final Object id : this.getAllIds()) { if (id instanceof Integer) { delete((Integer) id); } else if (id instanceof String) { delete((String) id); } } }
/** * An IE-only method which clears all custom attributes. */ public void jsxFunction_clearAttributes() { final HtmlElement node = getDomNodeOrDie(); // Remove custom attributes defined directly in HTML. final List<String> removals = new ArrayList<String>(); for (final String attributeName : node.getAttributesMap().keySet()) { // Quick hack to figure out what's a "custom" attribute, and what isn't. // May not be 100% correct. if (!ScriptableObject.hasProperty(getPrototype(), attributeName)) { removals.add(attributeName); } } for (final String attributeName : removals) { node.removeAttribute(attributeName); } // Remove custom attributes defined at runtime via JavaScript. for (final Object id : this.getAllIds()) { if (id instanceof Integer) { delete((Integer) id); } else if (id instanceof String) { delete((String) id); } } }
public static Scriptable toIterator(Context cx, Scriptable scope, Scriptable obj, boolean keyOnly) { if (ScriptableObject.hasProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME)) { Object v = ScriptableObject.getProperty(obj, NativeIterator.ITERATOR_PROPERTY_NAME); if (!(v instanceof Callable)) { throw typeError0("msg.invalid.iterator"); } Callable f = (Callable) v; Object[] args = new Object[] { keyOnly ? Boolean.TRUE : Boolean.FALSE }; v = f.call(cx, scope, obj, args); if (!(v instanceof Scriptable)) { throw typeError0("msg.iterator.primitive"); } return (Scriptable) v; } return null; }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = htmlSelect_.getScriptableObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = htmlSelect_.getScriptableObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }
/** * <p>If IE is emulated, and this class does not have the specified property, and the owning * select *does* have the specified property, this method delegates the call to the parent * select element.</p> * * <p>See {@link #getWithFallback(String)} for the corresponding getter behavior.</p> * * @param name {@inheritDoc} * @param start {@inheritDoc} * @param value {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { if (htmlSelect_ == null) { // This object hasn't been initialized; it's probably being used as a prototype. // Just pretend we didn't even see this invocation and let Rhino handle it. super.put(name, start, value); return; } final HTMLSelectElement parent = (HTMLSelectElement) htmlSelect_.getScriptObject(); if (!has(name, start) && ScriptableObject.hasProperty(parent, name)) { ScriptableObject.putProperty(parent, name, value); } else { super.put(name, start, value); } }