public class

Attribute

extends Object
implements Cloneable Map.Entry<K, V>
java.lang.Object
   ↳ org.jsoup.nodes.Attribute

Class Overview

A single key + value attribute. Keys are trimmed and normalised to lower-case.

Summary

Public Constructors
Attribute(String key, String value)
Create a new attribute from unencoded (raw) key and value.
Public Methods
Attribute clone()
static Attribute createFromEncoded(String unencodedKey, String encodedValue)
Create a new Attribute from an unencoded key and a HMTL attribute encoded value.
boolean equals(Object o)
String getKey()
Get the attribute key.
String getValue()
Get the attribute value.
int hashCode()
String html()
Get the HTML representation of this attribute; e.g.
void setKey(String key)
Set the attribute key.
String setValue(String value)
Set the attribute value.
String toString()
Get the string representation of this attribute, implemented as html().
Protected Methods
void html(StringBuilder accum, Document.OutputSettings out)
boolean isDataAttribute()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Map.Entry

Public Constructors

public Attribute (String key, String value)

Create a new attribute from unencoded (raw) key and value.

Parameters
key attribute key
value attribute value

Public Methods

public Attribute clone ()

public static Attribute createFromEncoded (String unencodedKey, String encodedValue)

Create a new Attribute from an unencoded key and a HMTL attribute encoded value.

Parameters
unencodedKey assumes the key is not encoded, as can be only run of simple \w chars.
encodedValue HTML attribute encoded value
Returns
  • attribute

public boolean equals (Object o)

public String getKey ()

Get the attribute key.

Returns
  • the attribute key

public String getValue ()

Get the attribute value.

Returns
  • the attribute value

public int hashCode ()

public String html ()

Get the HTML representation of this attribute; e.g. href="index.html".

Returns
  • HTML

public void setKey (String key)

Set the attribute key. Gets normalised as per the constructor method.

Parameters
key the new key; must not be null

public String setValue (String value)

Set the attribute value.

Parameters
value the new attribute value; must not be null

public String toString ()

Get the string representation of this attribute, implemented as html().

Returns
  • string

Protected Methods

protected void html (StringBuilder accum, Document.OutputSettings out)

protected boolean isDataAttribute ()