public class Attribute
extends java.lang.Object
implements java.util.Map.Entry<java.lang.String,java.lang.String>, java.lang.Cloneable
| Constructor and Description |
|---|
Attribute(java.lang.String key,
java.lang.String value)
Create a new attribute from unencoded (raw) key and value.
|
Attribute(java.lang.String key,
java.lang.String val,
Attributes parent)
Create a new attribute from unencoded (raw) key and value.
|
| Modifier and Type | Method and Description |
|---|---|
Attribute |
clone() |
static Attribute |
createFromEncoded(java.lang.String unencodedKey,
java.lang.String encodedValue)
Create a new Attribute from an unencoded key and a HTML attribute encoded value.
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getKey()
Get the attribute key.
|
java.lang.String |
getValue()
Get the attribute value.
|
int |
hashCode() |
java.lang.String |
html()
Get the HTML representation of this attribute; e.g.
|
protected void |
html(java.lang.Appendable accum,
Document.OutputSettings out) |
protected static void |
html(java.lang.String key,
java.lang.String val,
java.lang.Appendable accum,
Document.OutputSettings out) |
protected boolean |
isBooleanAttribute()
Deprecated.
|
protected static boolean |
isBooleanAttribute(java.lang.String key)
Checks if this attribute name is defined as a boolean attribute in HTML5
|
protected boolean |
isDataAttribute() |
protected static boolean |
isDataAttribute(java.lang.String key) |
void |
setKey(java.lang.String key)
Set the attribute key; case is preserved.
|
java.lang.String |
setValue(java.lang.String val)
Set the attribute value.
|
protected boolean |
shouldCollapseAttribute(Document.OutputSettings out)
Collapsible if it's a boolean attribute and value is empty or same as name
|
protected static boolean |
shouldCollapseAttribute(java.lang.String key,
java.lang.String val,
Document.OutputSettings out) |
java.lang.String |
toString()
Get the string representation of this attribute, implemented as
html(). |
public Attribute(java.lang.String key,
java.lang.String value)
key - attribute key; case is preserved.value - attribute valuecreateFromEncoded(java.lang.String, java.lang.String)public Attribute(java.lang.String key,
java.lang.String val,
Attributes parent)
key - attribute key; case is preserved.val - attribute valueparent - the containing Attributes (this Attribute is not automatically added to said Attributes)createFromEncoded(java.lang.String, java.lang.String)public java.lang.String getKey()
getKey in interface java.util.Map.Entry<java.lang.String,java.lang.String>public void setKey(java.lang.String key)
key - the new key; must not be nullpublic java.lang.String getValue()
getValue in interface java.util.Map.Entry<java.lang.String,java.lang.String>public java.lang.String setValue(java.lang.String val)
setValue in interface java.util.Map.Entry<java.lang.String,java.lang.String>val - the new attribute value; must not be nullpublic java.lang.String html()
href="index.html".protected static void html(java.lang.String key,
java.lang.String val,
java.lang.Appendable accum,
Document.OutputSettings out)
throws java.io.IOException
java.io.IOExceptionprotected void html(java.lang.Appendable accum,
Document.OutputSettings out)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
html().toString in class java.lang.Objectpublic static Attribute createFromEncoded(java.lang.String unencodedKey, java.lang.String encodedValue)
unencodedKey - assumes the key is not encoded, as can be only run of simple \w chars.encodedValue - HTML attribute encoded valueprotected boolean isDataAttribute()
protected static boolean isDataAttribute(java.lang.String key)
protected final boolean shouldCollapseAttribute(Document.OutputSettings out)
out - output settingsprotected static boolean shouldCollapseAttribute(java.lang.String key,
java.lang.String val,
Document.OutputSettings out)
protected boolean isBooleanAttribute()
protected static boolean isBooleanAttribute(java.lang.String key)
public boolean equals(java.lang.Object o)
equals in interface java.util.Map.Entry<java.lang.String,java.lang.String>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Map.Entry<java.lang.String,java.lang.String>hashCode in class java.lang.Objectpublic Attribute clone()
clone in class java.lang.Object