org.jsoup.nodes
Class Attribute

java.lang.Object
  extended by org.jsoup.nodes.Attribute
All Implemented Interfaces:
Cloneable, Map.Entry<String,String>

public class Attribute
extends Object
implements Map.Entry<String,String>, Cloneable

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

Author:
Jonathan Hedley, jonathan@hedley.net

Constructor Summary
Attribute(String key, String value)
          Create a new attribute from unencoded (raw) key and value.
 
Method Summary
 Attribute clone()
           
static Attribute createFromEncoded(String unencodedKey, String encodedValue)
          Create a new Attribute from an unencoded key and a HTML 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.
protected  void html(StringBuilder accum, Document.OutputSettings out)
           
protected  boolean isDataAttribute()
           
 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().
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(String key,
                 String value)
Create a new attribute from unencoded (raw) key and value.

Parameters:
key - attribute key
value - attribute value
See Also:
createFromEncoded(java.lang.String, java.lang.String)
Method Detail

getKey

public String getKey()
Get the attribute key.

Specified by:
getKey in interface Map.Entry<String,String>
Returns:
the attribute key

setKey

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

getValue

public String getValue()
Get the attribute value.

Specified by:
getValue in interface Map.Entry<String,String>
Returns:
the attribute value

setValue

public String setValue(String value)
Set the attribute value.

Specified by:
setValue in interface Map.Entry<String,String>
Parameters:
value - the new attribute value; must not be null

html

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

Returns:
HTML

html

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

toString

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

Overrides:
toString in class Object
Returns:
string

createFromEncoded

public static Attribute createFromEncoded(String unencodedKey,
                                          String encodedValue)
Create a new Attribute from an unencoded key and a HTML 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

isDataAttribute

protected boolean isDataAttribute()

equals

public boolean equals(Object o)
Specified by:
equals in interface Map.Entry<String,String>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map.Entry<String,String>
Overrides:
hashCode in class Object

clone

public Attribute clone()
Overrides:
clone in class Object


Copyright © 2009-2012 Jonathan Hedley. All Rights Reserved.