org.jsoup.nodes
Class Attribute

java.lang.Object
  extended by org.jsoup.nodes.Attribute

public class Attribute
extends Object

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

Author:
Jonathan Hedley, [email protected]

Constructor Summary
Attribute(String key, String value)
          Create a new attribute from unencoded (raw) key and value.
 
Method Summary
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.
protected  void html(StringBuilder accum)
           
 void setKey(String key)
          Set the attribute key.
 void 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
clone, 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.

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.

Returns:
the attribute value

setValue

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

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)

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 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

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


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