java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.Storage
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
JavaScript host object for
Storage.- Author:
- Ahmed Ashour, Marc Guillemot, Ronald Brill, Kanoko Yamamoto
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, LEGACY_CONST, PERMANENT, READONLY, STRICTLY_READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionStorage()Default constructor for prototype instantiation only.Creates a newStorageinstance backed by the given store.Creates a newStorageinstance backed by the given store. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all items from this storage.voidOverridden to support the removal of stored items viadelete.Gets a named property from the object.protected Object[]getIds(org.htmlunit.corejs.javascript.CompoundOperationMap<org.htmlunit.corejs.javascript.Scriptable> map, boolean getNonEnumerable, boolean getSymbols) Overridden to enumerate the stored items as own properties (Object.keys(), Object.getOwnPropertyNames(), for...in, ...).Returns the value associated with the given key.intReturns the number of items in the storage.protected org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfogetOwnPropertyDescriptor(org.htmlunit.corejs.javascript.Context cx, Object id) Overridden to provide property descriptors for the stored items.booleanOverridden to make the stored items visible as own properties.voidCreates an instance of this object.static ObjectjsGetItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functiongetItem(key).static StringjsKey(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionkey(index).static voidjsRemoveItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionremoveItem(key).static voidjsSetItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionsetItem(key, value).key(int index) Returns the key at the specified index.voidvoidremoveItem(String key) Removes the item with the specified key.voidSets the value for the given key.Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, createDOMException, equivalentValues, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getIndexedPropertyCount, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, isIndexedPropertyWritable, makeScriptableFor, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
Storage
public Storage()Default constructor for prototype instantiation only. -
Storage
Creates a newStorageinstance backed by the given store. No storage events are fired for changes made through this instance.- Parameters:
window- the parent scopestore- the backing map for this storage
-
Storage
Creates a newStorageinstance backed by the given store.- Parameters:
window- the parent scopestore- the backing map for this storagetype- the type of this storage, used to fire storage events in other windows; ifnullno events are fired
-
-
Method Details
-
jsConstructor
public void jsConstructor()Creates an instance of this object. -
put
- Specified by:
putin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
putin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
putin classHtmlUnitScriptable
-
get
Gets a named property from the object. Normally HtmlUnit objects don't need to overwrite this method as properties are defined on the prototypes. In some cases where "content" of object has priority compared to the properties consider using utilityHtmlUnitScriptable.getWithPreemption(String).- Specified by:
getin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
getin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getin classHtmlUnitScriptable
-
has
Overridden to make the stored items visible as own properties.- Specified by:
hasin interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
hasin interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
hasin classorg.htmlunit.corejs.javascript.ScriptableObject
-
delete
Overridden to support the removal of stored items viadelete.- Specified by:
deletein interfaceorg.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>- Specified by:
deletein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
deletein classorg.htmlunit.corejs.javascript.ScriptableObject
-
getIds
protected Object[] getIds(org.htmlunit.corejs.javascript.CompoundOperationMap<org.htmlunit.corejs.javascript.Scriptable> map, boolean getNonEnumerable, boolean getSymbols) Overridden to enumerate the stored items as own properties (Object.keys(), Object.getOwnPropertyNames(), for...in, ...). Overridden to list the indexed properties (seeHtmlUnitScriptable.getIndexedPropertyCount()) in front of the other own properties.- Overrides:
getIdsin classHtmlUnitScriptable
-
getOwnPropertyDescriptor
protected org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo getOwnPropertyDescriptor(org.htmlunit.corejs.javascript.Context cx, Object id) Overridden to provide property descriptors for the stored items. Overridden to provide property descriptors for the indexed properties (seeHtmlUnitScriptable.getIndexedPropertyCount()).- Overrides:
getOwnPropertyDescriptorin classHtmlUnitScriptable
-
getLength
public int getLength()Returns the number of items in the storage.- Returns:
- the number of items
-
removeItem
Removes the item with the specified key.- Parameters:
key- the key of the item to remove
-
jsRemoveItem
public static void jsRemoveItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionremoveItem(key).- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
key
Returns the key at the specified index.- Parameters:
index- the index of the key to retrieve- Returns:
- the key at the given index, or
nullif out of range
-
jsKey
public static String jsKey(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionkey(index).- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function- Returns:
- the key at the given index, or
nullif out of range
-
getItem
Returns the value associated with the given key.- Parameters:
key- the key of the item to retrieve- Returns:
- the value for the given key, or
nullif not found
-
jsGetItem
public static Object jsGetItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functiongetItem(key).- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function- Returns:
- the value for the given key, or
nullif not found
-
setItem
Sets the value for the given key. The quota is shared by allStorageobjects using the same store and counts the length of the keys and of the values.- Parameters:
key- the key of the item to setdata- the new value
-
jsSetItem
public static void jsSetItem(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Implementation of the JavaScript functionsetItem(key, value).- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
clear
public void clear()Removes all items from this storage.
-