Class IdScriptableObject
- java.lang.Object
- 
- org.mozilla.javascript.ScriptableObject
- 
- org.mozilla.javascript.IdScriptableObject
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- ConstProperties,- DebuggableObject,- IdFunctionCall,- Scriptable,- SymbolScriptable
 - Direct Known Subclasses:
- BaseFunction,- ES6Generator,- ES6Iterator,- NativeArray,- NativeArrayBuffer,- NativeArrayBufferView,- NativeCall,- NativeCallSite,- NativeConsole,- NativeContinuation,- NativeGenerator,- NativeIterator,- NativeMap,- NativeObject,- NativeRegExp,- NativeSet,- NativeSymbol,- NativeWeakMap,- NativeWeakSet,- TopLevel,- XMLObject
 
 public abstract class IdScriptableObject extends ScriptableObject implements IdFunctionCall Base class for native object implementation that uses IdFunctionObject to export its methods to script via <class-name>.prototype object.Any descendant should implement at least the following methods: findInstanceIdInfo getInstanceIdName execIdCall methodArity To define non-function properties, the descendant should override getInstanceIdValue setInstanceIdValue to get/set property value and provide its default attributes. To customize initialization of constructor and prototype objects, descendant may override scopeInit or fillConstructorProperties methods. - See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObjectScriptableObject.KeyComparator
 
- 
 - 
Field Summary- 
Fields inherited from class org.mozilla.javascript.ScriptableObjectCONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 - 
Fields inherited from interface org.mozilla.javascript.ScriptableNOT_FOUND
 
- 
 - 
Constructor SummaryConstructors Constructor Description IdScriptableObject()IdScriptableObject(Scriptable scope, Scriptable prototype)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivatePrototypeMap(int maxPrototypeId)protected voidaddIdFunctionProperty(Scriptable obj, java.lang.Object tag, int id, java.lang.String name, int arity)protected java.lang.ObjectdefaultGet(java.lang.String name)protected booleandefaultHas(java.lang.String name)protected voiddefaultPut(java.lang.String name, java.lang.Object value)protected voiddefineOwnProperty(Context cx, java.lang.Object key, ScriptableObject desc, boolean checkValid)Defines a property on an object.voiddelete(java.lang.String name)Removes a named property from the object.voiddelete(Symbol key)Removes an object like the others, but using a Symbol as the key.protected static <T> TensureType(java.lang.Object obj, java.lang.Class<T> clazz, IdFunctionObject f)Utility method to check the type and do the cast or throw an incompatible call error.java.lang.ObjectexecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.IdFunctionObjectexportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)protected voidfillConstructorProperties(IdFunctionObject ctor)protected intfindInstanceIdInfo(java.lang.String name)Map name to id of instance property.protected intfindInstanceIdInfo(Symbol key)Map name to id of instance property.protected intfindPrototypeId(java.lang.String name)protected intfindPrototypeId(Symbol key)java.lang.Objectget(java.lang.String name, Scriptable start)Returns the value of the named property or NOT_FOUND.java.lang.Objectget(Symbol key, Scriptable start)Another version of Get that supports Symbol keyed properties.intgetAttributes(java.lang.String name)Get the attributes of a named property.intgetAttributes(Symbol key)protected java.lang.StringgetInstanceIdName(int id)Map id back to property name it defines.protected java.lang.ObjectgetInstanceIdValue(int id)Get id value.protected intgetMaxInstanceId()Get maximum id findInstanceIdInfo can generate.protected ScriptableObjectgetOwnPropertyDescriptor(Context cx, java.lang.Object id)booleanhas(java.lang.String name, Scriptable start)Returns true if the named property is defined.booleanhas(Symbol key, Scriptable start)A version of "has" that supports symbols.booleanhasPrototypeMap()voidinitPrototypeConstructor(IdFunctionObject f)protected voidinitPrototypeId(int id)IdFunctionObjectinitPrototypeMethod(java.lang.Object tag, int id, java.lang.String name, int arity)IdFunctionObjectinitPrototypeMethod(java.lang.Object tag, int id, java.lang.String propertyName, java.lang.String functionName, int arity)IdFunctionObjectinitPrototypeMethod(java.lang.Object tag, int id, Symbol key, java.lang.String functionName, int arity)voidinitPrototypeValue(int id, java.lang.String name, java.lang.Object value, int attributes)voidinitPrototypeValue(int id, Symbol key, java.lang.Object value, int attributes)protected static intinstanceIdInfo(int attributes, int id)voidput(java.lang.String name, Scriptable start, java.lang.Object value)Sets the value of the named property, creating it if need be.voidput(Symbol key, Scriptable start, java.lang.Object value)Implementation of put required by SymbolScriptable objects.voidsetAttributes(java.lang.String name, int attributes)Set the attributes of a named property.protected voidsetInstanceIdAttributes(int id, int attr)Update the attributes of the given instance property.protected voidsetInstanceIdValue(int id, java.lang.Object value)Set or delete id value.- 
Methods inherited from class org.mozilla.javascript.ScriptableObjectapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
 
- 
 
- 
- 
- 
Constructor Detail- 
IdScriptableObjectpublic IdScriptableObject() 
 - 
IdScriptableObjectpublic IdScriptableObject(Scriptable scope, Scriptable prototype) 
 
- 
 - 
Method Detail- 
defaultHasprotected final boolean defaultHas(java.lang.String name) 
 - 
defaultGetprotected final java.lang.Object defaultGet(java.lang.String name) 
 - 
defaultPutprotected final void defaultPut(java.lang.String name, java.lang.Object value)
 - 
haspublic boolean has(java.lang.String name, Scriptable start)Description copied from class:ScriptableObjectReturns true if the named property is defined.- Specified by:
- hasin interface- Scriptable
- Overrides:
- hasin class- ScriptableObject
- Parameters:
- name- the name of the property
- start- the object in which the lookup began
- Returns:
- true if and only if the property was found in the object
- See Also:
- Scriptable.get(String, Scriptable),- ScriptableObject.getProperty(Scriptable, String)
 
 - 
haspublic boolean has(Symbol key, Scriptable start) Description copied from class:ScriptableObjectA version of "has" that supports symbols.- Specified by:
- hasin interface- SymbolScriptable
- Overrides:
- hasin class- ScriptableObject
 
 - 
getpublic java.lang.Object get(java.lang.String name, Scriptable start)Description copied from class:ScriptableObjectReturns the value of the named property or NOT_FOUND.If the property was created using defineProperty, the appropriate getter method is called. - Specified by:
- getin interface- Scriptable
- Overrides:
- getin class- ScriptableObject
- Parameters:
- name- the name of the property
- start- the object in which the lookup began
- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
- Context.getUndefinedValue()
 
 - 
getpublic java.lang.Object get(Symbol key, Scriptable start) Description copied from class:ScriptableObjectAnother version of Get that supports Symbol keyed properties.- Specified by:
- getin interface- SymbolScriptable
- Overrides:
- getin class- ScriptableObject
 
 - 
putpublic void put(java.lang.String name, Scriptable start, java.lang.Object value)Description copied from class:ScriptableObjectSets the value of the named property, creating it if need be.If the property was created using defineProperty, the appropriate setter method is called. If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object. - Specified by:
- putin interface- Scriptable
- Overrides:
- putin class- ScriptableObject
- Parameters:
- name- the name of the property
- start- the object whose property is being set
- value- value to set the property to
- See Also:
- Scriptable.has(String, Scriptable),- Scriptable.get(String, Scriptable),- ScriptableObject.putProperty(Scriptable, String, Object),- Context.toObject(Object, Scriptable)
 
 - 
putpublic void put(Symbol key, Scriptable start, java.lang.Object value) Description copied from class:ScriptableObjectImplementation of put required by SymbolScriptable objects.- Specified by:
- putin interface- SymbolScriptable
- Overrides:
- putin class- ScriptableObject
 
 - 
deletepublic void delete(java.lang.String name) Description copied from class:ScriptableObjectRemoves a named property from the object.If the property is not found, or it has the PERMANENT attribute, no action is taken. - Specified by:
- deletein interface- Scriptable
- Overrides:
- deletein class- ScriptableObject
- Parameters:
- name- the name of the property
- See Also:
- Scriptable.get(String, Scriptable),- ScriptableObject.deleteProperty(Scriptable, String)
 
 - 
deletepublic void delete(Symbol key) Description copied from class:ScriptableObjectRemoves an object like the others, but using a Symbol as the key.- Specified by:
- deletein interface- SymbolScriptable
- Overrides:
- deletein class- ScriptableObject
 
 - 
getAttributespublic int getAttributes(java.lang.String name) Description copied from class:ScriptableObjectGet the attributes of a named property.The property is specified by nameas defined forhas.- Overrides:
- getAttributesin class- ScriptableObject
- Parameters:
- name- the identifier for the property
- Returns:
- the bitset of attributes
- See Also:
- ScriptableObject.has(String, Scriptable),- ScriptableObject.READONLY,- ScriptableObject.DONTENUM,- ScriptableObject.PERMANENT,- ScriptableObject.EMPTY
 
 - 
getAttributespublic int getAttributes(Symbol key) - Overrides:
- getAttributesin class- ScriptableObject
 
 - 
setAttributespublic void setAttributes(java.lang.String name, int attributes)Description copied from class:ScriptableObjectSet the attributes of a named property.The property is specified by nameas defined forhas.The possible attributes are READONLY, DONTENUM, and PERMANENT. Combinations of attributes are expressed by the bitwise OR of attributes. EMPTY is the state of no attributes set. Any unused bits are reserved for future use. - Overrides:
- setAttributesin class- ScriptableObject
- Parameters:
- name- the name of the property
- attributes- the bitset of attributes
- See Also:
- Scriptable.has(String, Scriptable),- ScriptableObject.READONLY,- ScriptableObject.DONTENUM,- ScriptableObject.PERMANENT,- ScriptableObject.EMPTY
 
 - 
getMaxInstanceIdprotected int getMaxInstanceId() Get maximum id findInstanceIdInfo can generate.
 - 
instanceIdInfoprotected static int instanceIdInfo(int attributes, int id)
 - 
findInstanceIdInfoprotected int findInstanceIdInfo(java.lang.String name) Map name to id of instance property. Should return 0 if not found or the result ofinstanceIdInfo(int, int).
 - 
findInstanceIdInfoprotected int findInstanceIdInfo(Symbol key) Map name to id of instance property. Should return 0 if not found or the result ofinstanceIdInfo(int, int).
 - 
getInstanceIdNameprotected java.lang.String getInstanceIdName(int id) Map id back to property name it defines.
 - 
getInstanceIdValueprotected java.lang.Object getInstanceIdValue(int id) Get id value. * If id value is constant, descendant can call cacheIdValue to store * value in the permanent cache. * Default implementation creates IdFunctionObject instance for given id * and cache its value
 - 
setInstanceIdValueprotected void setInstanceIdValue(int id, java.lang.Object value)Set or delete id value. If value == NOT_FOUND , the implementation should make sure that the following getInstanceIdValue return NOT_FOUND.
 - 
setInstanceIdAttributesprotected void setInstanceIdAttributes(int id, int attr)Update the attributes of the given instance property. Classes which want to support changing property attributes via Object.defineProperty must override this method. The default implementation throws InternalError.- Parameters:
- id- the instance property id
- attr- the new attribute bitset
 
 - 
execIdCallpublic java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args) 'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.- Specified by:
- execIdCallin interface- IdFunctionCall
 
 - 
exportAsJSClasspublic final IdFunctionObject exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed) 
 - 
hasPrototypeMappublic final boolean hasPrototypeMap() 
 - 
activatePrototypeMappublic final void activatePrototypeMap(int maxPrototypeId) 
 - 
initPrototypeMethodpublic final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, java.lang.String name, int arity) 
 - 
initPrototypeMethodpublic final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, java.lang.String propertyName, java.lang.String functionName, int arity) 
 - 
initPrototypeMethodpublic final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, Symbol key, java.lang.String functionName, int arity) 
 - 
initPrototypeConstructorpublic final void initPrototypeConstructor(IdFunctionObject f) 
 - 
initPrototypeValuepublic final void initPrototypeValue(int id, java.lang.String name, java.lang.Object value, int attributes)
 - 
initPrototypeValuepublic final void initPrototypeValue(int id, Symbol key, java.lang.Object value, int attributes)
 - 
initPrototypeIdprotected void initPrototypeId(int id) 
 - 
findPrototypeIdprotected int findPrototypeId(java.lang.String name) 
 - 
findPrototypeIdprotected int findPrototypeId(Symbol key) 
 - 
fillConstructorPropertiesprotected void fillConstructorProperties(IdFunctionObject ctor) 
 - 
addIdFunctionPropertyprotected void addIdFunctionProperty(Scriptable obj, java.lang.Object tag, int id, java.lang.String name, int arity) 
 - 
ensureTypeprotected static <T> T ensureType(java.lang.Object obj, java.lang.Class<T> clazz, IdFunctionObject f)Utility method to check the type and do the cast or throw an incompatible call error. Possible usage would be to have a private function like realThis:private static NativeSomething realThis(Scriptable thisObj, IdFunctionObject f) { return ensureType(thisObj, NativeSomething.class, f); }- Parameters:
- obj- the object to check/cast
- clazz- the target type
- f- function that is attempting to convert 'this' object.
- Returns:
- obj casted to the target type
- Throws:
- EcmaError- if the cast failed.
 
 - 
defineOwnPropertyprotected void defineOwnProperty(Context cx, java.lang.Object key, ScriptableObject desc, boolean checkValid) Description copied from class:ScriptableObjectDefines a property on an object.Based on [[DefineOwnProperty]] from 8.12.10 of the spec. - Overrides:
- defineOwnPropertyin class- ScriptableObject
- Parameters:
- cx- the current Context
- key- the name/index of the property
- desc- the new property descriptor, as described in 8.6.1
- checkValid- whether to perform validity checks
 
 - 
getOwnPropertyDescriptorprotected ScriptableObject getOwnPropertyDescriptor(Context cx, java.lang.Object id) - Overrides:
- getOwnPropertyDescriptorin class- ScriptableObject
 
 
- 
 
-