Interface DOMTokenList

All Superinterfaces:
Iterable<String>
All Known Implementing Classes:
DOMTokenListImpl, DOMTokenSetImpl

public interface DOMTokenList extends Iterable<String>
Based on DOM interface DOMTokenList which is actually a set.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String token)
    Adds the given token to this collection.
    boolean
    Does this collection contains this token?
    boolean
    Does this collection contain all the tokens in the supplied DOMTokenList?
    boolean
    Does this collection contain all the tokens in the given collection?
    int
    Gets the number of tokens stored in this collection.
    Gets the value of the collection as a String, with the tokens alphabetically ordered.
    Gets the value of the collection as a String.
    item(int index)
    Retrieves a token from the collection by its index.
    Obtain an iterator over the members of this set.
    void
    remove(String token)
    Removes the given token from this collection.
    void
    replace(String oldToken, String newToken)
    Replaces an existing token with a new token.
    boolean
    toggle(String token)
    If the given token exists in this collection, remove it; otherwise add it.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • getLength

      int getLength()
      Gets the number of tokens stored in this collection.
      Returns:
      the number of tokens stored in this collection.
    • getValue

      String getValue()
      Gets the value of the collection as a String.
      Returns:
      the value of the collection as a String.
    • getSortedValue

      String getSortedValue()
      Gets the value of the collection as a String, with the tokens alphabetically ordered.
      Returns:
      the value of the collection as an alphabetically ordered string.
    • item

      String item(int index)
      Retrieves a token from the collection by its index.
      Parameters:
      index - the index.
      Returns:
      the token in the given place of this collection, or null if the index is negative, greater than or equal to the length of this collection.
    • iterator

      Iterator<String> iterator()
      Obtain an iterator over the members of this set.
      Specified by:
      iterator in interface Iterable<String>
      Returns:
      an iterator over the members of this set.
    • contains

      boolean contains(String token)
      Does this collection contains this token?
      Parameters:
      token - the token.
      Returns:
      true if the list contains the given token, false otherwise.
    • containsAll

      boolean containsAll(DOMTokenList otherlist)
      Does this collection contain all the tokens in the supplied DOMTokenList?
      Parameters:
      otherlist - another DOMTokenList.
      Returns:
      true if this list contains all the tokens in the given otherlist, false otherwise.
      Throws:
      DOMException - SYNTAX_ERR if the argument is null or empty.
    • containsAll

      boolean containsAll(Collection<String> tokenSet)
      Does this collection contain all the tokens in the given collection?
      Parameters:
      tokenSet - the collection of tokens.
      Returns:
      true if the list contains all the tokens in the given set, false otherwise.
      Throws:
      DOMException - SYNTAX_ERR if the argument is null or empty.
    • add

      void add(String token) throws DOMException
      Adds the given token to this collection.

      If the set already contains the token, then do nothing.

      Parameters:
      token - the token to add.
      Throws:
      DOMException - SYNTAX_ERR if the token is null or empty. INVALID_CHARACTER_ERR if the token contains spaces.
    • remove

      void remove(String token) throws DOMException
      Removes the given token from this collection.
      Parameters:
      token - the token to remove.
      Throws:
      DOMException - SYNTAX_ERR if the token is null or empty. INVALID_CHARACTER_ERR if the token contains spaces.
    • toggle

      boolean toggle(String token) throws DOMException
      If the given token exists in this collection, remove it; otherwise add it.
      Parameters:
      token - the token to toggle.
      Returns:
      true if the token is added, false if it is removed.
      Throws:
      DOMException - SYNTAX_ERR if the token is null or empty. INVALID_CHARACTER_ERR if the token contains spaces.
    • replace

      void replace(String oldToken, String newToken) throws DOMException
      Replaces an existing token with a new token.

      If the set does not contain the token, do nothing.

      Parameters:
      oldToken - the token that has to be replaced.
      newToken - the new token.
      Throws:
      DOMException - SYNTAX_ERR if any of the tokens is null or empty. INVALID_CHARACTER_ERR if any of the tokens contains spaces.