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 static java.util.regex.Pattern |
htmlKeyReplace |
private static java.util.regex.Pattern |
htmlKeyValid |
private java.lang.String |
key |
(package private) Attributes |
parent |
private java.lang.String |
val |
private static java.util.regex.Pattern |
xmlKeyReplace |
private static java.util.regex.Pattern |
xmlKeyValid |
| 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.
|
static java.lang.String |
getValidKey(java.lang.String key,
Document.OutputSettings.Syntax syntax) |
java.lang.String |
getValue()
Get the attribute value.
|
boolean |
hasDeclaredValue()
Check if this Attribute has a 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) |
(package private) static void |
htmlNoValidate(java.lang.String key,
java.lang.String val,
java.lang.Appendable accum,
Document.OutputSettings out) |
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(). |
private static final java.lang.String[] booleanAttributes
private java.lang.String key
@Nullable private java.lang.String val
@Nullable Attributes parent
private static final java.util.regex.Pattern xmlKeyValid
private static final java.util.regex.Pattern xmlKeyReplace
private static final java.util.regex.Pattern htmlKeyValid
private static final java.util.regex.Pattern htmlKeyReplace
public Attribute(java.lang.String key,
@Nullable
java.lang.String value)
key - attribute key; case is preserved.value - attribute value (may be null)createFromEncoded(java.lang.String, java.lang.String)public Attribute(java.lang.String key,
@Nullable
java.lang.String val,
@Nullable
Attributes parent)
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)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 boolean hasDeclaredValue()
public java.lang.String setValue(@Nullable
java.lang.String val)
setValue in interface java.util.Map.Entry<java.lang.String,java.lang.String>val - the new attribute value; may be null (to set an enabled boolean attribute)public java.lang.String html()
href="index.html".protected void html(java.lang.Appendable accum,
Document.OutputSettings out)
throws java.io.IOException
java.io.IOExceptionprotected static void html(java.lang.String key,
@Nullable
java.lang.String val,
java.lang.Appendable accum,
Document.OutputSettings out)
throws java.io.IOException
java.io.IOExceptionstatic void htmlNoValidate(java.lang.String key,
@Nullable
java.lang.String val,
java.lang.Appendable accum,
Document.OutputSettings out)
throws java.io.IOException
java.io.IOException@Nullable
public static java.lang.String getValidKey(java.lang.String key,
Document.OutputSettings.Syntax syntax)
public 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,
@Nullable
java.lang.String val,
Document.OutputSettings out)
public static boolean isBooleanAttribute(java.lang.String key)
public boolean equals(@Nullable
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