Class Attribute
java.lang.Object
org.jsoup.nodes.Attribute
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static AttributecreateFromEncoded(String unencodedKey, String encodedValue) Create a new Attribute from an unencoded key and a HTML attribute encoded value.booleangetKey()Get the attribute's key (aka name).static @Nullable StringgetValidKey(String key, Document.OutputSettings.Syntax syntax) Get a valid attribute key for the given syntax.getValue()Get the attribute value.booleanCheck if this Attribute has a value.inthashCode()html()Get the HTML representation of this attribute; e.g.protected voidhtml(Appendable accum, Document.OutputSettings out) Deprecated.protected static voidhtml(String key, @Nullable String val, Appendable accum, Document.OutputSettings out) Deprecated.internal method; usehtml(String, String, QuietAppendable, Document.OutputSettings)withQuietAppendable.wrap(Appendable)instead.static booleanisBooleanAttribute(String key) Checks if this attribute name is defined as a boolean attribute in HTML5protected booleanprotected static booleanisDataAttribute(String key) Get this attribute's local name.Get this attribute's namespace URI, if the attribute was prefixed with a defined namespace name.prefix()Get this attribute's key prefix, if it has one; else the empty string.voidSet the attribute key; case is preserved.Set the attribute value.protected static booleanshouldCollapseAttribute(String key, @Nullable String val, Document.OutputSettings out) protected final booleanDeprecated.internal method; useshouldCollapseAttribute(String, String, Document.OutputSettings)instead.Get the source ranges (start to end positions) in the original input source from which this attribute's name and value were parsed.toString()Get the string representation of this attribute, implemented ashtml().
-
Constructor Details
-
Attribute
-
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
-
setKey
-
getValue
-
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
-
prefix
-
localName
-
namespace
-
html
-
sourceRange
Get the source ranges (start to end positions) in the original input source from which this attribute's name and value were parsed.Position tracking must be enabled prior to parsing the content.
- Returns:
- the ranges for the attribute's name and value, or
untrackedif the attribute does not exist or its range was not tracked. - Since:
- 1.17.1
- See Also:
-
html
Deprecated.internal method; usehtml(String, String, QuietAppendable, Document.OutputSettings)withQuietAppendable.wrap(Appendable)instead. Will be removed in jsoup 1.24.1.- Throws:
IOException
-
html
@Deprecated protected static void html(String key, @Nullable String val, Appendable accum, Document.OutputSettings out) throws IOException Deprecated.internal method; usehtml(String, String, QuietAppendable, Document.OutputSettings)withQuietAppendable.wrap(Appendable)instead. Will be removed in jsoup 1.24.1.- Throws:
IOException
-
getValidKey
Get a valid attribute key for the given syntax. If the key is not valid, it will be coerced into a valid key.- Parameters:
key- the original attribute keysyntax- HTML or XML- Returns:
- the original key if it's valid; a key with invalid characters replaced with "_" otherwise; or null if a valid key could not be created.
-
toString
-
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
-
isDataAttribute
-
shouldCollapseAttribute
Deprecated.internal method; useshouldCollapseAttribute(String, String, Document.OutputSettings)instead. Will be removed in jsoup 1.24.1.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
-
clone
-
html(String, String, QuietAppendable, Document.OutputSettings)withQuietAppendable.wrap(Appendable)instead.