Module org.htmlunit

Class Storage

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

public class Storage extends HtmlUnitScriptable
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, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for prototype instantiation only.
    Storage(Window window, Map<String,String> store)
    Creates a new Storage instance backed by the given store.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all items from this storage.
    get(String name, org.htmlunit.corejs.javascript.Scriptable start)
    Gets a named property from the object.
    Returns the value associated with the given key.
    int
    Returns the number of items in the storage.
    void
    Creates an instance of this object.
    key(int index)
    Returns the key at the specified index.
    void
    put(String name, org.htmlunit.corejs.javascript.Scriptable start, Object value)
    void
    Removes the item with the specified key.
    void
    setItem(String key, String data)
    Sets the value for the given key.

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, 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, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, 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, size

    Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • Storage

      public Storage()
      Default constructor for prototype instantiation only.
    • Storage

      public Storage(Window window, Map<String,String> store)
      Creates a new Storage instance backed by the given store.
      Parameters:
      window - the parent scope
      store - the backing map for this storage
  • Method Details

    • jsConstructor

      public void jsConstructor()
      Creates an instance of this object.
    • put

      public void put(String name, org.htmlunit.corejs.javascript.Scriptable start, Object value)
      Specified by:
      put in interface org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>
      Specified by:
      put in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      put in class HtmlUnitScriptable
    • get

      public Object get(String name, org.htmlunit.corejs.javascript.Scriptable start)
      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 utility HtmlUnitScriptable.getWithPreemption(String).
      Specified by:
      get in interface org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>
      Specified by:
      get in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      get in class HtmlUnitScriptable
    • getLength

      public int getLength()
      Returns the number of items in the storage.
      Returns:
      the number of items
    • removeItem

      public void removeItem(String key)
      Removes the item with the specified key.
      Parameters:
      key - the key of the item to remove
    • key

      public String key(int index)
      Returns the key at the specified index.
      Parameters:
      index - the index of the key to retrieve
      Returns:
      the key at the given index, or null if out of range
    • getItem

      public Object getItem(String key)
      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 null if not found
    • setItem

      public void setItem(String key, String data)
      Sets the value for the given key.
      Parameters:
      key - the key of the item to set
      data - the new value
    • clear

      public void clear()
      Removes all items from this storage.