Package org.jsoup.parser
Class Tag
- java.lang.Object
-
- org.jsoup.parser.Tag
-
public class Tag extends java.lang.Object
HTML Tag capabilities.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
blockTags
private boolean
canContainInline
private boolean
empty
private static java.lang.String[]
emptyTags
private boolean
formatAsBlock
private static java.lang.String[]
formatAsInlineTags
private boolean
formList
private static java.lang.String[]
formListedTags
private boolean
formSubmit
private static java.lang.String[]
formSubmitTags
private static java.lang.String[]
inlineTags
private boolean
isBlock
private java.lang.String
normalName
private boolean
preserveWhitespace
private static java.lang.String[]
preserveWhitespaceTags
private boolean
selfClosing
private java.lang.String
tagName
private static java.util.Map<java.lang.String,Tag>
tags
-
Constructor Summary
Constructors Modifier Constructor Description private
Tag(java.lang.String tagName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canContainBlock()
Deprecated.No longer used, and no different result than {isBlock()
}boolean
equals(java.lang.Object o)
boolean
formatAsBlock()
Gets if this tag should be formatted as a block (or as inline)java.lang.String
getName()
Get this tag's name.int
hashCode()
boolean
isBlock()
Gets if this is a block tag.boolean
isData()
Gets if this tag is a data only tag.boolean
isEmpty()
Get if this is an empty tagboolean
isFormListed()
Get if this tag represents a control associated with a form.boolean
isFormSubmittable()
Get if this tag represents an element that should be submitted with a form.boolean
isInline()
Gets if this tag is an inline tag.boolean
isKnownTag()
Get if this is a pre-defined tag, or was auto created on parsing.static boolean
isKnownTag(java.lang.String tagName)
Check if this tagname is a known tag.boolean
isSelfClosing()
Get if this tag is self closing.java.lang.String
normalName()
Get this tag's normalized (lowercased) name.boolean
preserveWhitespace()
Get if this tag should preserve whitespace within child text nodes.private static void
register(Tag tag)
(package private) Tag
setSelfClosing()
java.lang.String
toString()
static Tag
valueOf(java.lang.String tagName)
Get a Tag by name.static Tag
valueOf(java.lang.String tagName, ParseSettings settings)
Get a Tag by name.
-
-
-
Field Detail
-
tags
private static final java.util.Map<java.lang.String,Tag> tags
-
tagName
private java.lang.String tagName
-
normalName
private java.lang.String normalName
-
isBlock
private boolean isBlock
-
formatAsBlock
private boolean formatAsBlock
-
canContainInline
private boolean canContainInline
-
empty
private boolean empty
-
selfClosing
private boolean selfClosing
-
preserveWhitespace
private boolean preserveWhitespace
-
formList
private boolean formList
-
formSubmit
private boolean formSubmit
-
blockTags
private static final java.lang.String[] blockTags
-
inlineTags
private static final java.lang.String[] inlineTags
-
emptyTags
private static final java.lang.String[] emptyTags
-
formatAsInlineTags
private static final java.lang.String[] formatAsInlineTags
-
preserveWhitespaceTags
private static final java.lang.String[] preserveWhitespaceTags
-
formListedTags
private static final java.lang.String[] formListedTags
-
formSubmitTags
private static final java.lang.String[] formSubmitTags
-
-
Method Detail
-
getName
public java.lang.String getName()
Get this tag's name.- Returns:
- the tag's name
-
normalName
public java.lang.String normalName()
Get this tag's normalized (lowercased) name.- Returns:
- the tag's normal name.
-
valueOf
public static Tag valueOf(java.lang.String tagName, ParseSettings settings)
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.settings
- used to control tag name sensitivity- Returns:
- The tag, either defined or new generic.
-
valueOf
public static Tag valueOf(java.lang.String tagName)
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.
-
isBlock
public boolean isBlock()
Gets if this is a block tag.- Returns:
- if block tag
-
formatAsBlock
public boolean formatAsBlock()
Gets if this tag should be formatted as a block (or as inline)- Returns:
- if should be formatted as block or inline
-
canContainBlock
public boolean canContainBlock()
Deprecated.No longer used, and no different result than {isBlock()
}Gets if this tag can contain block tags.- Returns:
- if tag can contain block tags
-
isInline
public boolean isInline()
Gets if this tag is an inline tag.- Returns:
- if this tag is an inline tag.
-
isData
public boolean isData()
Gets if this tag is a data only tag.- Returns:
- if this tag is a data only tag
-
isEmpty
public boolean isEmpty()
Get if this is an empty tag- Returns:
- if this is an empty tag
-
isSelfClosing
public boolean isSelfClosing()
Get if this tag is self closing.- Returns:
- if this tag should be output as self closing.
-
isKnownTag
public boolean isKnownTag()
Get if this is a pre-defined tag, or was auto created on parsing.- Returns:
- if a known tag
-
isKnownTag
public static boolean isKnownTag(java.lang.String tagName)
Check if this tagname is a known tag.- Parameters:
tagName
- name of tag- Returns:
- if known HTML tag
-
preserveWhitespace
public boolean preserveWhitespace()
Get if this tag should preserve whitespace within child text nodes.- Returns:
- if preserve whitespace
-
isFormListed
public boolean isFormListed()
Get if this tag represents a control associated with a form. E.g. input, textarea, output- Returns:
- if associated with a form
-
isFormSubmittable
public boolean 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
-
setSelfClosing
Tag setSelfClosing()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
register
private static void register(Tag tag)
-
-