Package org.jsoup.parser

Class TagSet

java.lang.Object
org.jsoup.parser.TagSet

public class TagSet extends Object
A TagSet controls the Tag configuration for a Document's parse, and its serialization. It contains the initial defaults, and after the parse, any additionally discovered tags.
Since:
1.20.1
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    TagSet()
     
    TagSet(TagSet original)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Tag tag)
    Insert a tag into this TagSet.
    boolean
    equals(Object o)
     
    @Nullable Tag
    get(String tagName, String namespace)
    Get an existing Tag from this TagSet by tagName and namespace.
    int
     
    static TagSet
    Html()
    Returns a mutable copy of the default HTML tag set.
    Tag
    valueOf(String tagName, String namespace)
    Get a Tag by name from this TagSet.
    Tag
    valueOf(String tagName, String namespace, ParseSettings settings)
    Get a Tag by name from this TagSet.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TagSet

      public TagSet()
    • TagSet

      public TagSet(TagSet original)
  • Method Details

    • Html

      public static TagSet Html()
      Returns a mutable copy of the default HTML tag set.
    • add

      public TagSet add(Tag tag)
      Insert a tag into this TagSet. If the tag already exists, it is replaced.

      Tags explicitly added like this are considered to be known tags (vs those that are dynamically created via .valueOf() if not already in the set.

      Parameters:
      tag- the tag to add
      Returns:
      this TagSet
    • get

      public @Nullable Tag get(String tagName, String namespace)
      Get an existing Tag from this TagSet by tagName and namespace. The tag name is not normalized, to support mixed instances.
      Parameters:
      tagName- the case-sensitive tag name
      namespace- the namespace
      Returns:
      the tag, or null if not found
    • valueOf

      public Tag valueOf(String tagName, String namespace, ParseSettings settings)
      Get a Tag by name from this TagSet. If not previously defined (unknown), returns a new tag.

      New tags will be added to this TagSet.

      Parameters:
      tagName- Name of tag, e.g. "p".
      namespace- the namespace for the tag.
      settings- used to control tag name sensitivity
      Returns:
      The tag, either defined or new generic.
    • valueOf

      public Tag valueOf(String tagName, String namespace)
      Get a Tag by name from this TagSet. If not previously defined (unknown), returns a new tag.

      New tags will be added to this TagSet.

      Parameters:
      tagName- Name of tag, e.g. "p". Case-sensitive.
      namespace- the namespace for the tag.
      Returns:
      The tag, either defined or new generic.
      See Also:
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object