Class Tag
java.lang.Object
org.jsoup.parser.Tag
- All Implemented Interfaces:
Cloneable
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intTag option: the tag is a block tag (e.g.,<div>,<p>).static intTag option: the tag is a Data element that can have text but not character references (e.g.,<style>,<script>).static intTag option: the tag's value will be included when submitting a form (e.g.,<input>).static intTag option: pretty-print hint for block tags whose inline children should stay inline.static intTag option: the tag is known (specifically defined).static intTag option: the tag preserves whitespace (e.g.,<pre>).static intTag option: the tag is an RCDATA element that can have text and character references (e.g.,<title>,<textarea>).static intTag option: the tag has been seen self-closing in this parse.static intTag option: the tag can self-close (e.g.,<foo />).static intTag option: readable text boundary forElement.text(), used for controls, widgets, and embedded objects.static intTag option: the tag is a void tag (e.g.,<img>), that can contain no children, and in HTML does not require closing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear(int option) Clear (unset) an option from this tag.protected Tagclone()booleanbooleanDeprecated.getName()Get this tag's name.inthashCode()Hashcode of this Tag, consisting of the tag name and namespace.booleanis(int option) Test if an option is set on this tag.booleanisBlock()Gets if this is a block tag.booleanisEmpty()Get if this is void (aka empty) tag.booleanGet if this tag represents an element that should be submitted with a form.booleanisInline()Gets if this tag is an inline tag.booleanGet if this is a pre-defined tag in the TagSet, or was auto created on parsing.static booleanisKnownTag(String tagName) Check if this tag name is a known HTML tag.booleanGet if this tag is self-closing.Get this tag's local name.name()Get this tag's name.Change the tag's name.Get this tag's namespace.Set the tag's namespace.Get this tag's normalized (lowercased) name.prefix()Get this tag's prefix, if it has one; else the empty string.booleanGet if this tag should preserve whitespace within child text nodes.set(int option) Set an option on this tag.toString()static TagGet a Tag by name.static TagvalueOf(String tagName, String namespace, ParseSettings settings) Get a Tag by name.static TagvalueOf(String tagName, ParseSettings settings) Get a Tag by name.
-
Field Details
-
Known
Tag option: the tag is known (specifically defined). This impacts if options may need to be inferred (when not known) in, e.g., the pretty-printer. Set when a tag is added to a TagSet, or when settings are set(). -
Void
Tag option: the tag is a void tag (e.g.,<img>), that can contain no children, and in HTML does not require closing. -
Block
Tag option: the tag is a block tag (e.g.,<div>,<p>). Causes the element to be indented when pretty-printing. If not a block, it is inline. -
InlineContainer
Tag option: pretty-print hint for block tags whose inline children should stay inline. (Must also set Block.) -
SelfClose
Tag option: the tag can self-close (e.g.,<foo />). -
SeenSelfClose
Tag option: the tag has been seen self-closing in this parse. -
PreserveWhitespace
Tag option: the tag preserves whitespace (e.g.,<pre>). -
RcData
Tag option: the tag is an RCDATA element that can have text and character references (e.g.,<title>,<textarea>). -
Data
Tag option: the tag is a Data element that can have text but not character references (e.g.,<style>,<script>). -
FormSubmittable
Tag option: the tag's value will be included when submitting a form (e.g.,<input>). -
TextBoundary
Tag option: readable text boundary forElement.text(), used for controls, widgets, and embedded objects.
-
-
Constructor Details
-
Tag
-
Tag
-
-
Method Details
-
getName
-
name
-
name
-
prefix
-
localName
-
normalName
Get this tag's normalized (lowercased) name.- Returns:
- the tag's normal name.
-
namespace
-
namespace
-
set
-
is
Test if an option is set on this tag.- Parameters:
option- the option to test- Returns:
- true if the option is set
- Since:
- 1.20.1
-
clear
-
valueOf
Get a Tag by name. If not previously defined (unknown), returns a new generic tag, that can do anything.Pre-defined tags (p, div etc) will be ==, but unknown tags are not registered and will only .equals().
- Parameters:
tagName- Name of tag, e.g. "p". Case-insensitive.namespace- the namespace for the tag.settings- used to control tag name sensitivity- Returns:
- The tag, either defined or new generic.
- See Also:
-
valueOf
Get a Tag by name. If not previously defined (unknown), returns a new generic tag, that can do anything.Pre-defined tags (P, DIV etc) will be ==, but unknown tags are not registered and will only .equals().
- Parameters:
tagName- Name of tag, e.g. "p". Case sensitive.- Returns:
- The tag, either defined or new generic.
- See Also:
-
valueOf
Get a Tag by name. If not previously defined (unknown), returns a new generic tag, that can do anything.Pre-defined tags (P, DIV etc) will be ==, but unknown tags are not registered and will only .equals().
- Parameters:
tagName- Name of tag, e.g. "p". Case sensitive.settings- used to control tag name sensitivity- Returns:
- The tag, either defined or new generic.
- See Also:
-
isBlock
-
formatAsBlock
Deprecated.internal pretty-printing flag; useisInline()orisBlock()to check layout intent. Will be removed in jsoup 1.24.1.Get if this is an InlineContainer tag.- Returns:
- true if this tag has the InlineContainer pretty-print hint.
-
isInline
Gets if this tag is an inline tag. Just the opposite of isBlock.- Returns:
- if this tag is an inline tag.
-
isEmpty
-
isSelfClosing
Get if this tag is self-closing.- Returns:
- if this tag should be output as self-closing.
-
isKnownTag
Get if this is a pre-defined tag in the TagSet, or was auto created on parsing.- Returns:
- if a known tag
-
isKnownTag
Check if this tag name is a known HTML tag.- Parameters:
tagName- name of tag- Returns:
- if known HTML tag
-
preserveWhitespace
Get if this tag should preserve whitespace within child text nodes.- Returns:
- if preserve whitespace
-
isFormSubmittable
Get if this tag represents an element that should be submitted with a form. E.g. input, option- Returns:
- if submittable with a form
-
equals
-
hashCode
-
toString
-
clone
-
isInline()orisBlock()to check layout intent.