Class Tag


  • public class Tag
    extends java.lang.Object
    A representation of DOM tag. A tag has a name (e.g. div, span) and a set of attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      Tag​(AttrBuilder attrs)
      Creates a tag with the given attributes.
      Tag​(java.lang.String name, AttrBuilder attrs)
      Creates a tag with the given name and attributes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AttrBuilder getAttrs()
      Returns the attributes of the tag.
      java.lang.String getName()
      Returns the name of the tag (e.g.
      Tag printlnEnd​(java.io.Writer out)
      Println the end tag of this tag (e.g.
      Tag printlnStart​(java.io.Writer out)
      Println the start tag of this tag (e.g.
      Tag setAttrs​(AttrBuilder attrs)
      Sets attributes of the tag.
      Tag setName​(java.lang.String name)
      Sets the name of the tag.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Tag

        public Tag​(@CheckForNull
                   java.lang.String name,
                   @Nonnull
                   AttrBuilder attrs)
        Creates a tag with the given name and attributes.
        Parameters:
        name - the name of the tag
        attrs - the attributes
      • Tag

        public Tag​(@Nonnull
                   AttrBuilder attrs)
        Creates a tag with the given attributes. The name is null in this case.
        Parameters:
        attrs - the attributes
    • Method Detail

      • getName

        @CheckForNull
        public java.lang.String getName()
        Returns the name of the tag (e.g. div, span).
        Returns:
        the name
      • setName

        @Nonnull
        public Tag setName​(@CheckForNull
                           java.lang.String name)
        Sets the name of the tag.
        Parameters:
        name - the name
        Returns:
        the tag
      • getAttrs

        @Nonnull
        public AttrBuilder getAttrs()
        Returns the attributes of the tag.
        Returns:
        the attributes of the tag
      • setAttrs

        @Nonnull
        public Tag setAttrs​(@Nonnull
                            AttrBuilder attrs)
        Sets attributes of the tag.
        Parameters:
        attrs - the attributes to set
        Returns:
        the tag with the newly set attributes
      • printlnStart

        @Nonnull
        public Tag printlnStart​(@Nonnull
                                java.io.Writer out)
                         throws java.io.IOException
        Println the start tag of this tag (e.g. "<div class='class1'>"). Note that no escaping/encoding of the name is performed.
        Parameters:
        out - the writer
        Returns:
        the tag
        Throws:
        java.io.IOException - if there's a problem while printing to the writer
      • printlnEnd

        @Nonnull
        public Tag printlnEnd​(@Nonnull
                              java.io.Writer out)
                       throws java.io.IOException
        Println the end tag of this tag (e.g. "</div>"). Note that no escaping/encoding of the name is performed.
        Parameters:
        out - the writer
        Returns:
        the tag
        Throws:
        java.io.IOException - if there's a problem while printing to the writer