Interface ElementAttributes


public interface ElementAttributes
HTML attributes that are specified on a particular Element.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an immutable map that contains attributes of the element.
    Returns an immutable list that contains attribute nodes of the element.
    boolean
    Returns true when an attribute with the given name is specified on the element or has a default value, otherwise returns false.
    Returns Element, on which these attributes are specified.
    get(String name)
    Returns the value of the attribute with the given name.
    void
    put(String name, String value)
    Adds a new attribute with the given name and value.
    void
    remove(String name)
    Removes an attribute with the given name.
    int
    Returns a number of the specified attributes.
  • Method Details

    • element

      Element element()
      Returns Element, on which these attributes are specified.
    • size

      int size()
      Returns a number of the specified attributes.
      Throws:
      ObjectClosedException - when the element is closed
    • get

      String get(String name)
      Returns the value of the attribute with the given name.

      The returned string is empty if the attribute with the given name is not specified on the element, or has no value.

      Parameters:
      name - the attribute name
      Throws:
      IllegalArgumentException - when name is empty or blank
      ObjectClosedException - when the element is closed
    • put

      void put(String name, String value)
      Adds a new attribute with the given name and value.

      If an attribute with the given name is already specified, its value will be replaced with the new one.

      Parameters:
      name - the name of the attribute to add or alter
      value - value to set in string form. Can be empty for boolean attribute names which are always true despite the attribute value
      Throws:
      IllegalArgumentException - when name is empty or blank
      ObjectClosedException - when the element is closed
    • remove

      void remove(String name)
      Removes an attribute with the given name.

      This method does nothing if an attribute with the given name is not specified on the element.

      Parameters:
      name - the name of the attribute to remove
      Throws:
      IllegalArgumentException - when name is empty or blank
      ObjectClosedException - when the element is closed
    • contains

      boolean contains(String name)
      Returns true when an attribute with the given name is specified on the element or has a default value, otherwise returns false.
      Parameters:
      name - the name of the attribute
      Throws:
      IllegalArgumentException - when name is empty or blank
      ObjectClosedException - when the element is closed
    • asMap

      Map<String,String> asMap()
      Returns an immutable map that contains attributes of the element.

      Each map entry is a pair of strings where key stands for the attribute name and value stands for the attribute value.

      The returned map is empty if the element does not have attributes.

      Throws:
      ObjectClosedException - when the element is closed
    • asNodes

      List<Attribute> asNodes()
      Returns an immutable list that contains attribute nodes of the element.

      The returned list is empty if the element does not have attributes.

      Throws:
      ObjectClosedException - when the element is closed