Package org.jsoup.nodes
Class Attribute
java.lang.Object
org.jsoup.nodes.Attribute
A single key + value attribute. (Only used for presentation.)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
static Attribute
createFromEncoded
(String unencodedKey, String encodedValue) Create a new Attribute from an unencoded key and a HTML attribute encoded value.boolean
getKey()
Get the attribute key.static String
getValidKey
(String key, Document.OutputSettings.Syntax syntax) getValue()
Get the attribute value.boolean
Check if this Attribute has a value.int
hashCode()
html()
Get the HTML representation of this attribute; e.g.protected void
html
(Appendable accum, Document.OutputSettings out) protected static void
html
(String key, String val, Appendable accum, Document.OutputSettings out) static boolean
isBooleanAttribute
(String key) Checks if this attribute name is defined as a boolean attribute in HTML5protected boolean
protected static boolean
isDataAttribute
(String key) void
Set the attribute key; case is preserved.Set the attribute value.protected static boolean
shouldCollapseAttribute
(String key, String val, Document.OutputSettings out) protected final boolean
Collapsible if it's a boolean attribute and value is empty or same as nametoString()
Get the string representation of this attribute, implemented ashtml()
.
-
Constructor Details
-
Attribute
Create a new attribute from unencoded (raw) key and value.- Parameters:
key
- attribute key; case is preserved.value
- attribute value (may be null)- See Also:
-
Attribute
Create a new attribute from unencoded (raw) key and value.- Parameters:
key
- attribute key; case is preserved.val
- attribute value (may be null)parent
- the containing Attributes (this Attribute is not automatically added to said Attributes)- See Also:
-
-
Method Details
-
getKey
Get the attribute key. -
setKey
Set the attribute key; case is preserved.- Parameters:
key
- the new key; must not be null
-
getValue
Get the attribute value. Will return an empty string if the value is not set. -
hasDeclaredValue
public boolean hasDeclaredValue()Check if this Attribute has a value. Set boolean attributes have no value.- Returns:
- if this is a boolean attribute / attribute without a value
-
setValue
Set the attribute value. -
html
Get the HTML representation of this attribute; e.g.href="index.html"
.- Returns:
- HTML
-
html
- Throws:
IOException
-
html
protected static void html(String key, @Nullable String val, Appendable accum, Document.OutputSettings out) throws IOException - Throws:
IOException
-
getValidKey
-
toString
Get the string representation of this attribute, implemented ashtml()
. -
createFromEncoded
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() -
isDataAttribute
-
shouldCollapseAttribute
Collapsible if it's a boolean attribute and value is empty or same as name- Parameters:
out
- output settings- Returns:
- Returns whether collapsible or not
-
shouldCollapseAttribute
protected static boolean shouldCollapseAttribute(String key, @Nullable String val, Document.OutputSettings out) -
isBooleanAttribute
Checks if this attribute name is defined as a boolean attribute in HTML5 -
equals
-
hashCode
public int hashCode() -
clone
-