Class DOMTokenListImpl

java.lang.Object
io.sf.carte.doc.DOMTokenListImpl
All Implemented Interfaces:
DOMTokenList, Iterable<String>

public class DOMTokenListImpl extends Object implements DOMTokenList
An implementation of the DOMTokenList interface.

It is internally a linked list, but behaves like an ordered set.

  • Constructor Details

    • DOMTokenListImpl

      public DOMTokenListImpl()
  • Method Details

    • getLength

      public int getLength()
      Description copied from interface: DOMTokenList
      Gets the number of tokens stored in this collection.
      Specified by:
      getLength in interface DOMTokenList
      Returns:
      the number of tokens stored in this collection.
    • getValue

      public String getValue()
      Description copied from interface: DOMTokenList
      Gets the value of the collection as a String.
      Specified by:
      getValue in interface DOMTokenList
      Returns:
      the value of the collection as a String.
    • getSortedValue

      public String getSortedValue()
      Description copied from interface: DOMTokenList
      Gets the value of the collection as a String, with the tokens alphabetically ordered.
      Specified by:
      getSortedValue in interface DOMTokenList
      Returns:
      the value of the collection as an alphabetically ordered string.
    • setValue

      public void setValue(String value) throws DOMException
      Sets the value of the collection as a String.
      Parameters:
      value - the string value of the collection
      Throws:
      DOMException - SYNTAX_ERR if value is null.
    • item

      public String item(int index)
      Description copied from interface: DOMTokenList
      Retrieves a token from the collection by its index.
      Specified by:
      item in interface DOMTokenList
      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.
    • contains

      public boolean contains(String token)
      Description copied from interface: DOMTokenList
      Does this collection contains this token?
      Specified by:
      contains in interface DOMTokenList
      Parameters:
      token - the token.
      Returns:
      true if the list contains the given token, false otherwise.
    • iterator

      public Iterator<String> iterator()
      Description copied from interface: DOMTokenList
      Obtain an iterator over the members of this set.
      Specified by:
      iterator in interface DOMTokenList
      Specified by:
      iterator in interface Iterable<String>
      Returns:
      an iterator over the members of this set.
    • containsAll

      public boolean containsAll(DOMTokenList otherlist) throws DOMException
      Description copied from interface: DOMTokenList
      Does this collection contain all the tokens in the supplied DOMTokenList?
      Specified by:
      containsAll in interface 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

      public boolean containsAll(Collection<String> tokenSet)
      Description copied from interface: DOMTokenList
      Does this collection contain all the tokens in the given collection?
      Specified by:
      containsAll in interface DOMTokenList
      Parameters:
      tokenSet - the collection of tokens.
      Returns:
      true if the list contains all the tokens in the given set, false otherwise.
    • add

      public void add(String token) throws DOMException
      Description copied from interface: DOMTokenList
      Adds the given token to this collection.

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

      Specified by:
      add in interface DOMTokenList
      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

      public void remove(String token) throws DOMException
      Description copied from interface: DOMTokenList
      Removes the given token from this collection.
      Specified by:
      remove in interface DOMTokenList
      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

      public boolean toggle(String token) throws DOMException
      Description copied from interface: DOMTokenList
      If the given token exists in this collection, remove it; otherwise add it.
      Specified by:
      toggle in interface DOMTokenList
      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

      public void replace(String oldToken, String newToken) throws DOMException
      Description copied from interface: DOMTokenList
      Replaces an existing token with a new token.

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

      Specified by:
      replace in interface DOMTokenList
      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.