public class Attribute
extends java.lang.Object
implements java.util.Map.Entry<java.lang.String,java.lang.String>, java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String[] |
booleanAttributes |
private java.lang.String |
key |
private java.lang.String |
value |
| Constructor and Description |
|---|
Attribute(java.lang.String key,
java.lang.String value)
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 boolean |
isBooleanAttribute() |
protected boolean |
isDataAttribute() |
void |
setKey(java.lang.String key)
Set the attribute key; case is preserved.
|
java.lang.String |
setValue(java.lang.String value)
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
|
java.lang.String |
toString()
Get the string representation of this attribute, implemented as
html(). |
private static final java.lang.String[] booleanAttributes
private java.lang.String key
private java.lang.String value
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 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 value)
setValue in interface java.util.Map.Entry<java.lang.String,java.lang.String>value - the new attribute value; must not be nullpublic java.lang.String html()
href="index.html".protected 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 final boolean shouldCollapseAttribute(Document.OutputSettings out)
out - output settingsprotected boolean isBooleanAttribute()
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