Module org.htmlunit

Class DOMTokenList

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.dom.DOMTokenList
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 DOMTokenList extends HtmlUnitScriptable
A JavaScript object for DOMTokenList.
Author:
Ahmed Ashour, Ronald Brill, Marek Gawlicki, Markus Winter
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
    Creates an instance.
    DOMTokenList(Node node, String attributeName)
    Creates an instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    add(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)
    Adds the given tokens to the list, omitting any that are already present.
    boolean
    Checks if the specified token is contained in the underlying string.
    org.htmlunit.corejs.javascript.Scriptable
    Returns an Iterator allowing to go through all key/value pairs contained in this object.
    void
    forEach(Object callback)
    Calls the callback given in parameter once for each value in the list.
    get(int index, org.htmlunit.corejs.javascript.Scriptable start)
    Returns the JavaScript default value of this object.
    .
    int
    Returns the length property.
     
    item(int index)
    Returns the item at the specified index.
    void
    JavaScript constructor.
    org.htmlunit.corejs.javascript.Scriptable
    Returns an Iterator allowing to go through all keys contained in this object.
    static void
    remove(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)
    Removes the specified tokens from the underlying string.
    boolean
    replace(String oldToken, String newToken)
    Replaces an existing token with a new token.
    void
     
    boolean
    toggle(String token)
    Toggle the token, by adding or removing.
    org.htmlunit.corejs.javascript.Scriptable
    Returns an Iterator allowing to go through all keys contained in this object.

    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, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, 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, 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, has, has

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

    get, has
  • Constructor Details

    • DOMTokenList

      public DOMTokenList()
      Creates an instance.
    • DOMTokenList

      public DOMTokenList(Node node, String attributeName)
      Creates an instance.
      Parameters:
      node - the node which contains the underlying string
      attributeName - the attribute name of the DomElement of the specified node
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
    • getValue

      public String getValue()
      Returns:
      the value
    • setValue

      public void setValue(String value)
      Parameters:
      value - the new value
    • getLength

      public int getLength()
      Returns the length property.
      Returns:
      the length
    • getDefaultValue

      public String getDefaultValue(Class<?> hint)
      Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.
      Specified by:
      getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      getDefaultValue in class HtmlUnitScriptable
      Parameters:
      hint - a hint as to the format of the default value (ignored in this case)
      Returns:
      the default value
    • add

      public static void add(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)
      Adds the given tokens to the list, omitting any that are already present.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
    • remove

      public static void remove(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)
      Removes the specified tokens from the underlying string.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
    • replace

      public boolean replace(String oldToken, String newToken)
      Replaces an existing token with a new token. If the first token doesn't exist, replace() returns false immediately, without adding the new token to the token list.
      Parameters:
      oldToken - a string representing the token you want to replace
      newToken - a string representing the token you want to replace oldToken with
      Returns:
      true if oldToken was successfully replaced, or false if not
    • toggle

      public boolean toggle(String token)
      Toggle the token, by adding or removing.
      Parameters:
      token - the token to add or remove
      Returns:
      whether the string now contains the token or not
    • contains

      public boolean contains(String token)
      Checks if the specified token is contained in the underlying string.
      Parameters:
      token - the token to add
      Returns:
      true if the underlying string contains token, otherwise false
    • item

      public String item(int index)
      Returns the item at the specified index.
      Parameters:
      index - the index of the item
      Returns:
      the item
    • keys

      public org.htmlunit.corejs.javascript.Scriptable keys()
      Returns an Iterator allowing to go through all keys contained in this object.
      Returns:
      a NativeArrayIterator
    • getIds

      public Object[] getIds()
      .
      Specified by:
      getIds in interface org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>
      Specified by:
      getIds in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      getIds in class org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
    • values

      public org.htmlunit.corejs.javascript.Scriptable values()
      Returns an Iterator allowing to go through all keys contained in this object.
      Returns:
      a NativeArrayIterator
    • entries

      public org.htmlunit.corejs.javascript.Scriptable entries()
      Returns an Iterator allowing to go through all key/value pairs contained in this object.
      Returns:
      a NativeArrayIterator
    • forEach

      public void forEach(Object callback)
      Calls the callback given in parameter once for each value in the list.
      Parameters:
      callback - function to execute for each element
    • get

      public Object get(int index, org.htmlunit.corejs.javascript.Scriptable start)
      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 org.htmlunit.corejs.javascript.ScriptableObject