Interface DOMTokenList

All Known Implementing Classes:
DOMTokenListImpl

public interface DOMTokenList
A set of space-separated tokens. Such a set is returned by Element.classList
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String tokens)
    Adds all arguments passed, except those already present.
    boolean
    Returns true if token is present, and false otherwise.
    int
    Returns the number of tokens.
    Returns the associated set as string.
    item(int index)
    Returns the token with index index.
    void
    remove(String tokens)
    Removes arguments passed, if they are present.
    boolean
    replace(String oldToken, String newToken)
    Replaces token with newToken.
    void
    setValue.
    boolean
    Returns true if token is in the associated attribute's supported tokens.
    boolean
    toggle(String token)
    toggle.
    boolean
    toggle(String token, boolean force)
    If force is not given, "toggles" token, removing it if it's present and adding it if it's not present.
  • Method Details

    • getLength

      int getLength()
      Returns the number of tokens.
      Returns:
      a Integer object.
    • getValue

      String getValue()
      Returns the associated set as string. Can be set, to change the associated attribute.
      Returns:
      a String object.
    • setValue

      void setValue(String value)

      setValue.

      Parameters:
      value - a String object.
    • add

      void add(String tokens)
      Adds all arguments passed, except those already present. Throws a "SyntaxError" DOMException if one of the arguments is the empty string. Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
      Parameters:
      tokens - a String object.
    • contains

      boolean contains(String token)
      Returns true if token is present, and false otherwise.
      Parameters:
      token - a String object.
      Returns:
      a boolean.
    • item

      String item(int index)
      Returns the token with index index.
      Parameters:
      index - a Integer object.
      Returns:
      a String object.
    • remove

      void remove(String tokens)
      Removes arguments passed, if they are present. Throws a "SyntaxError" DOMException if one of the arguments is the empty string. Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
      Parameters:
      tokens - a String object.
    • replace

      boolean replace(String oldToken, String newToken)
      Replaces token with newToken. Returns true if token was replaced with newToken, and false otherwise. Throws a "SyntaxError" DOMException if one of the arguments is the empty string. Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace.
      Parameters:
      oldToken - a String object.
      newToken - a String object.
      Returns:
      a boolean.
    • supports

      boolean supports(String token)
      Returns true if token is in the associated attribute's supported tokens. Returns false otherwise.

      Throws a TypeError if the associated attribute has no supported tokens defined.

      Parameters:
      token - a String object.
      Returns:
      a boolean.
    • toggle

      boolean toggle(String token, boolean force)
      If force is not given, "toggles" token, removing it if it's present and adding it if it's not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()). Returns true if token is now present, and false otherwise. Throws a "SyntaxError" DOMException if token is empty. Throws an "InvalidCharacterError" DOMException if token contains any spaces.
      Parameters:
      token - a String object.
      force - a boolean.
      Returns:
      a boolean.
    • toggle

      boolean toggle(String token)

      toggle.

      Parameters:
      token - a String object.
      Returns:
      a boolean.