Package org.jsoup.parser

Class Tag

java.lang.Object
org.jsoup.parser.Tag
All Implemented Interfaces:
Cloneable

public class Tag extends Object implements Cloneable
Tag capabilities.
Author:
Jonathan Hedley, jonathan@hedley.net
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Tag
    clone()
     
    boolean
    equals(Object o)
     
    boolean
    Gets if this tag should be formatted as a block (or as inline)
    String
    Get this tag's name.
    int
     
    boolean
    Gets if this is a block tag.
    boolean
    Get if this is an empty tag
    boolean
    Get if this tag represents a control associated with a form.
    boolean
    Get if this tag represents an element that should be submitted with a form.
    boolean
    Gets if this tag is an inline tag.
    boolean
    Get if this is a pre-defined tag, or was auto created on parsing.
    static boolean
    isKnownTag(String tagName)
    Check if this tagname is a known tag.
    boolean
    Get if this tag is self-closing.
    String
     
    String
    Get this tag's normalized (lowercased) name.
    boolean
    Get if this tag should preserve whitespace within child text nodes.
    String
     
    static Tag
    valueOf(String tagName)
    Get a Tag by name.
    static Tag
    valueOf(String tagName, String namespace, ParseSettings settings)
    Get a Tag by name.
    static Tag
    valueOf(String tagName, ParseSettings settings)
    Get a Tag by name.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • getName

      public String getName()
      Get this tag's name.
      Returns:
      the tag's name
    • normalName

      public String normalName()
      Get this tag's normalized (lowercased) name.
      Returns:
      the tag's normal name.
    • namespace

      public String namespace()
    • valueOf

      public static Tag valueOf(String tagName, String namespace, 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.
      namespace - the namespace for the tag.
      settings - used to control tag name sensitivity
      Returns:
      The tag, either defined or new generic.
    • valueOf

      public static Tag valueOf(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.
      See Also:
    • valueOf

      public static Tag valueOf(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 sensitive.
      settings - used to control tag name sensitivity
      Returns:
      The tag, either defined or new generic.
      See Also:
    • 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
    • isInline

      public boolean isInline()
      Gets if this tag is an inline tag.
      Returns:
      if this tag is an inline 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(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
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      protected Tag clone()
      Overrides:
      clone in class Object