Class DOMTokenList

java.lang.Object
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.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable

public class DOMTokenList extends HtmlUnitScriptable
A JavaScript object for DOMTokenList.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
     
    private static final String
     

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

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    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
    void
    add(String token)
    Adds the specified token to the underlying string.
    boolean
    Checks if the specified token is contained in the underlying string.
    get(int index, org.htmlunit.corejs.javascript.Scriptable start)
    private String
     
    Returns the JavaScript default value of this object.
    int
    Returns the length property.
    private static boolean
    isWhitespace(int ch)
     
    item(int index)
    Returns the item at the specified index.
    void
    JavaScript constructor.
    private static int
    position(String value, String token)
     
    void
    remove(String token)
    Removes the specified token from the underlying string.
    boolean
    toggle(String token)
    Toggle the token, by adding or removing.
    private void
     

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

    applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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.
    • getLength

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

      private String getAttribValue()
    • 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 void add(String token)
      Adds the specified token to the underlying string.
      Parameters:
      token - the token to add
    • remove

      public void remove(String token)
      Removes the specified token from the underlying string.
      Parameters:
      token - the token to remove
    • 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 Object item(int index)
      Returns the item at the specified index.
      Parameters:
      index - the index of the item
      Returns:
      the item
    • get

      public Object get(int index, org.htmlunit.corejs.javascript.Scriptable start)
      Specified by:
      get in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      get in class org.htmlunit.corejs.javascript.ScriptableObject
    • updateAttribute

      private void updateAttribute(String value)
    • position

      private static int position(String value, String token)
    • isWhitespace

      private static boolean isWhitespace(int ch)