public class

Attributes

extends Object
implements Cloneable Iterable<T>
java.lang.Object
   ↳ org.jsoup.nodes.Attributes

Class Overview

The attributes of an Element.

Attributes are treated as a map: there can be only one value associated with an attribute key.

Attribute key and value comparisons are done case insensitively, and keys are normalised to lower-case.

Summary

Constants
String dataPrefix
Public Constructors
Attributes()
Public Methods
void addAll(Attributes incoming)
Add all the attributes from the incoming set to this set.
List<Attribute> asList()
Get the attributes as a List, for iteration.
Attributes clone()
Map<StringString> dataset()
Retrieves a filtered view of attributes that are HTML5 custom data attributes; that is, attributes with keys starting with data-.
boolean equals(Object o)
String get(String key)
Get an attribute value by key.
boolean hasKey(String key)
Tests if these attributes contain an attribute with this key.
int hashCode()
String html()
Get the HTML representation of these attributes.
Iterator<Attribute> iterator()
void put(Attribute attribute)
Set a new attribute, or replace an existing one by key.
void put(String key, String value)
Set a new attribute, or replace an existing one by key.
void remove(String key)
Remove an attribute by key.
int size()
Get the number of attributes in this set.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Iterable

Constants

protected static final String dataPrefix

Constant Value: "data-"

Public Constructors

public Attributes ()

Public Methods

public void addAll (Attributes incoming)

Add all the attributes from the incoming set to this set.

Parameters
incoming attributes to add to these attributes.

public List<Attribute> asList ()

Get the attributes as a List, for iteration. Do not modify the keys of the attributes via this view, as changes to keys will not be recognised in the containing set.

Returns
  • an view of the attributes as a List.

public Attributes clone ()

public Map<StringString> dataset ()

Retrieves a filtered view of attributes that are HTML5 custom data attributes; that is, attributes with keys starting with data-.

Returns
  • map of custom data attributes.

public boolean equals (Object o)

public String get (String key)

Get an attribute value by key.

Parameters
key the attribute key
Returns
  • the attribute value if set; or empty string if not set.
See Also

public boolean hasKey (String key)

Tests if these attributes contain an attribute with this key.

Parameters
key key to check for
Returns
  • true if key exists, false otherwise

public int hashCode ()

public String html ()

Get the HTML representation of these attributes.

Returns
  • HTML

public Iterator<Attribute> iterator ()

public void put (Attribute attribute)

Set a new attribute, or replace an existing one by key.

Parameters
attribute attribute

public void put (String key, String value)

Set a new attribute, or replace an existing one by key.

Parameters
key attribute key
value attribute value

public void remove (String key)

Remove an attribute by key.

Parameters
key attribute key to remove

public int size ()

Get the number of attributes in this set.

Returns
  • size

public String toString ()