java.lang.Object
org.jdrupes.mdoclet.internal.doclets.toolkit.Content
org.jdrupes.mdoclet.internal.doclets.formats.html.markup.HtmlTree

public class HtmlTree extends Content
A tree node representing an HTML element, containing the name of the element, a collection of attributes, and content.

Except where otherwise stated, all methods in this class will throw NullPointerException for any arguments that are null or that are arrays or collections that contain null.

Many methods in this class return this, to enable a series of chained method calls on a single object.

Terminology: An HTML element is typically composed of a start tag, some enclosed content and typically an end tag. The start tag contains any attributes for the element. See: HTML element.

Siehe auch:
  • Felddetails

  • Konstruktordetails

    • HtmlTree

      public HtmlTree(TagName tagName)
      Creates an HTMLTree object representing an HTML element with the given name.
      Parameter:
      tagName - the name
  • Methodendetails

    • put

      public HtmlTree put(HtmlAttr attrName, String attrValue)
      Adds an attribute.
      Parameter:
      attrName - the name of the attribute
      attrValue - the value of the attribute
      Gibt zurück:
      this object
    • setId

      public HtmlTree setId(HtmlId id)
      Sets the id attribute.
      Parameter:
      id - the value for the attribute
      Gibt zurück:
      this object
    • setTitle

      public HtmlTree setTitle(Content body)
      Sets the title attribute.

      Any nested start or end tags in the content will be removed.

      Parameter:
      body - the content for the title attribute
      Gibt zurück:
      this object
    • setRole

      Sets the role attribute.
      Parameter:
      role - the role
      Gibt zurück:
      this object
    • setStyle

      public HtmlTree setStyle(HtmlStyle style)
      Sets the class attribute.
      Parameter:
      style - the value for the attribute
      Gibt zurück:
      this object
    • addStyle

      public HtmlTree addStyle(HtmlStyle style)
    • addStyle

      public HtmlTree addStyle(String style)
    • add

      public HtmlTree add(Content content)
      Adds additional content for the HTML element.
      Setzt außer Kraft:
      add in Klasse Content
      Parameter:
      content - the content
      Gibt zurück:
      this HTML tree
    • addUnchecked

      public HtmlTree addUnchecked(Content content)
      Adds content to this HTML tree without checking whether it is discardable.
      Parameter:
      content - the content to add
      Gibt zurück:
      this HTML tree
    • add

      public HtmlTree add(CharSequence stringContent)
      Adds text content for the HTML element.

      If the last content member that was added is a StringContent, appends the string to that item; otherwise, creates and uses a new StringContent for the new text content.

      Setzt außer Kraft:
      add in Klasse Content
      Parameter:
      stringContent - string content that needs to be added
      Gibt zurück:
      this object
    • add

      public HtmlTree add(List<? extends Content> list)
      Adds each of a list of content items.
      Parameter:
      list - the list
      Gibt zurück:
      this object
    • addAll

      public <T> HtmlTree addAll(Collection<T> items, Function<T,Content> mapper)
      Adds each of a collection of items, using a map function to create the content for each item.
      Setzt außer Kraft:
      addAll in Klasse Content
      Parameter:
      items - the items
      mapper - the map function to generate the content for each item
      Gibt zurück:
      this object
    • charCount

      public int charCount()
      Beschreibung aus Klasse kopiert: Content
      Gibt the number of characters of plain text content in this object zurück.
      Setzt außer Kraft:
      charCount in Klasse Content
      Gibt zurück:
      the number of characters of plain text content in this object
    • encodeURL

      public static String encodeURL(String url)
      Apply percent-encoding to a URL.

      This is similar to URLEncoder but is less aggressive about encoding some characters, like ‘(’, ‘)’, ‘,’ which are used in the anchor names for Java methods in HTML5 mode.

      Parameter:
      url - the url to be percent-encoded.
      Gibt zurück:
      a percent-encoded string.
    • A

      public static HtmlTree A(String ref, Content body)
      Creates an HTML A element.

      The ref argument will be URL-encoded for use as the attribute value.

      Parameter:
      ref - the value for the href attribute
      body - the content for element
      Gibt zurück:
      the element
    • A

      public static HtmlTree A(URI ref, Content body)
      Creates an HTML A element.

      The ref argument is assumed to be already suitably encoded, and will not be additionally URL-encoded, but will be converted to ASCII for use as the attribute value.

      Parameter:
      ref - the value for the href attribute
      body - the content for element
      Gibt zurück:
      the element
    • CAPTION

      public static HtmlTree CAPTION(Content body)
      Creates an HTML CAPTION element with the given content.
      Parameter:
      body - content for the element
      Gibt zurück:
      the element
    • CODE

      public static HtmlTree CODE(Content body)
      Creates an HTML CODE element with the given content.
      Parameter:
      body - content for the element
      Gibt zurück:
      the element
    • DD

      public static HtmlTree DD(Content body)
      Creates an HTML DD element with the given content.
      Parameter:
      body - content for the element
      Gibt zurück:
      the element
    • DETAILS

      public static HtmlTree DETAILS()
      Creates an HTML DETAILS element.
      Gibt zurück:
      the element
    • DETAILS

      public static HtmlTree DETAILS(HtmlStyle style)
      Creates an HTML DETAILS element.
      Gibt zurück:
      the element
    • DL

      public static HtmlTree DL(HtmlStyle style)
      Creates an HTML DL element with the given style.
      Parameter:
      style - the style
      Gibt zurück:
      the element
    • DL

      public static HtmlTree DL(HtmlStyle style, Content body)
      Creates an HTML DL element with the given style and content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • DIV

      public static HtmlTree DIV(HtmlStyle style)
      Creates an HTML DIV element with the given style.
      Parameter:
      style - the style
      Gibt zurück:
      the element
    • DIV

      public static HtmlTree DIV(HtmlStyle style, Content body)
      Creates an HTML DIV element with the given style and content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • DIV

      public static HtmlTree DIV(Content body)
      Creates an HTML DIV element with the given content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • DT

      public static HtmlTree DT(Content body)
      Creates an HTML DT element with the given content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • FOOTER

      public static HtmlTree FOOTER()
      Creates an HTML FOOTER element.

      The role is set to contentinfo.

      Gibt zurück:
      the element
    • HEADER

      public static HtmlTree HEADER()
      Creates an HTML HEADER element.

      The role is set to banner.

      Gibt zurück:
      the element
    • HEADING

      public static HtmlTree HEADING(TagName headingTag, Content body)
      Creates an HTML heading element with the given content.
      Parameter:
      headingTag - the tag for the heading
      body - the content
      Gibt zurück:
      the element
    • HEADING

      public static HtmlTree HEADING(TagName headingTag, HtmlStyle style, Content body)
      Creates an HTML heading element with the given style and content.
      Parameter:
      headingTag - the tag for the heading
      style - the stylesheet class
      body - the content
      Gibt zurück:
      the element
    • HEADING_TITLE

      public static HtmlTree HEADING_TITLE(TagName headingTag, HtmlStyle style, Content body)
      Creates an HTML heading element with the given style and content.

      The title attribute is set from the content.

      Parameter:
      headingTag - the tag for the heading
      style - the stylesheet class
      body - the content
      Gibt zurück:
      the element
    • HEADING_TITLE

      public static HtmlTree HEADING_TITLE(TagName headingTag, Content body)
      Creates an HTML heading element with the given style and content.

      The title attribute is set from the content.

      Parameter:
      headingTag - the tag for the heading
      body - the content
      Gibt zurück:
      the element
    • HTML

      public static HtmlTree HTML(String lang, Content head, Content body)
      Creates an HTML HTML element with the given lang attribute, and HEAD and BODY contents.
      Parameter:
      lang - the value for the lang attribute
      head - the HEAD element
      body - the BODY element
      Gibt zurück:
      the HTML element
    • INPUT

      public static HtmlTree INPUT(String type, HtmlId id)
      Creates an HTML INPUT element with the given id.

      The element as marked as initially disabled.

      Parameter:
      type - the type of input
      id - the id
      Gibt zurück:
      the element
    • LABEL

      public static HtmlTree LABEL(String forLabel, Content body)
      Creates an HTML LABEL element with the given content.
      Parameter:
      forLabel - the value of the for attribute
      body - the content
      Gibt zurück:
      the element
    • LI

      public static HtmlTree LI(Content body)
      Creates an HTML LI element with the given content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • LI

      public static HtmlTree LI(HtmlStyle style, Content body)
      Creates an HTML LI element with the given style and the given content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • LINK

      public static HtmlTree LINK(String rel, String type, String href, String title)
      Creates an HTML LINK tag with the given attributes.
      Parameter:
      rel - the relevance of the link: the rel attribute
      type - the type of link: the type attribute
      href - the path for the link: the href attribute
      title - title for the link: the title attribute
      Gibt zurück:
      the element
    • MAIN

      public static HtmlTree MAIN()
      Creates an HTML MAIN element.

      The role is set to main.

      Gibt zurück:
      the element
    • MAIN

      public static HtmlTree MAIN(Content body)
      Creates an HTML MAIN element with the given content.

      The role is set to main.

      Gibt zurück:
      the element
    • META

      public static HtmlTree META(String httpEquiv, String content, String charset)
      Creates an HTML META element with http-equiv and content attributes.
      Parameter:
      httpEquiv - the value for the http-equiv attribute
      content - the type of content, to be used in the content attribute
      charset - the character set for the document, to be used in the content attribute
      Gibt zurück:
      the element
    • META

      public static HtmlTree META(String name, String content)
      Creates an HTML META element with name and content attributes.
      Parameter:
      name - the value for the name attribute
      content - the value for the content attribute
      Gibt zurück:
      the element
    • NOSCRIPT

      public static HtmlTree NOSCRIPT(Content body)
      Creates an HTML NOSCRIPT element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • P

      public static HtmlTree P(Content body)
      Creates an HTML P element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • P

      public static HtmlTree P(HtmlStyle style, Content body)
      Creates an HTML P element with the given style and some content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • PRE

      public static HtmlTree PRE(Content body)
      Creates an HTML PRE element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • SCRIPT

      public static HtmlTree SCRIPT(String src)
      Creates an HTML SCRIPT element with some script content.

      The type of the script is set to text/javascript.

      Parameter:
      src - the content
      Gibt zurück:
      the element
    • SECTION

      public static HtmlTree SECTION(HtmlStyle style)
      Creates an HTML SECTION element with the given style.
      Parameter:
      style - the style
      Gibt zurück:
      the element
    • SECTION

      public static HtmlTree SECTION(HtmlStyle style, Content body)
      Creates an HTML SECTION element with the given style and some content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • SMALL

      public static HtmlTree SMALL(Content body)
      Creates an HTML SMALL element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • SPAN

      public static HtmlTree SPAN(Content body)
      Creates an HTML SPAN element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • SPAN

      public static HtmlTree SPAN(HtmlStyle styleClass)
      Creates an HTML SPAN element with the given style.
      Parameter:
      styleClass - the style
      Gibt zurück:
      the element
    • SPAN

      public static HtmlTree SPAN(HtmlStyle styleClass, Content body)
      Creates an HTML SPAN element with the given style and some content.
      Parameter:
      styleClass - the style
      body - the content
      Gibt zurück:
      the element
    • SPAN_ID

      public static HtmlTree SPAN_ID(HtmlId id, Content body)
      Creates an HTML SPAN element with the given id and some content.
      Parameter:
      id - the id
      body - the content
      Gibt zurück:
      the element
    • SPAN

      public static HtmlTree SPAN(HtmlId id, HtmlStyle style, Content body)
      Creates an HTML SPAN element with the given id and style, and some content.
      Parameter:
      id - the id
      style - the style
      body - the content
      Gibt zurück:
      the element
    • SUMMARY

      public static HtmlTree SUMMARY(Content body)
      Creates an HTML SUMMARY element with the given content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • SUP

      public static HtmlTree SUP(Content body)
      Creates an HTML SUP element with the given content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • TD

      public static HtmlTree TD(HtmlStyle style, Content body)
      Creates an HTML TD element with the given style and some content.
      Parameter:
      style - the style
      body - the content
      Gibt zurück:
      the element
    • TH

      public static HtmlTree TH(HtmlStyle style, String scope, Content body)
      Creates an HTML TH element with the given style and scope, and some content.
      Parameter:
      style - the style
      scope - the value for the scope attribute
      body - the content
      Gibt zurück:
      the element
    • TH

      public static HtmlTree TH(String scope, Content body)
      Creates an HTML TH element with the given scope, and some content.
      Parameter:
      scope - the value for the scope attribute
      body - the content
      Gibt zurück:
      the element
    • TITLE

      public static HtmlTree TITLE(String body)
      Creates an HTML TITLE element with some content.
      Parameter:
      body - the content
      Gibt zurück:
      the element
    • UL

      public static HtmlTree UL(HtmlStyle style)
      Creates an HTML UL element with the given style.
      Parameter:
      style - the style
      Gibt zurück:
      the element
    • UL

      public static HtmlTree UL(HtmlStyle style, Content first, Content... more)
      Creates an HTML UL element with the given style and some content.
      Parameter:
      style - the style
      first - the initial content
      more - additional content
      Gibt zurück:
      the element
    • UL

      public static <T> HtmlTree UL(HtmlStyle style, Collection<T> items, Function<T,Content> mapper)
      Creates an HTML UL element with the given style and content generated from a collection of items.
      Parameter:
      style - the style
      items - the items to be added to the list
      mapper - a mapper to create the content for each item
      Gibt zurück:
      the element
    • isEmpty

      public boolean isEmpty()
      Beschreibung aus Klasse kopiert: Content
      Returns true if the content is empty.
      Angegeben von:
      isEmpty in Klasse Content
      Gibt zurück:
      true if no content to be displayed else return false
    • hasContent

      public boolean hasContent()
      Returns true if the HTML tree has content.
      Gibt zurück:
      true if the HTML tree has content else return false
    • hasAttrs

      public boolean hasAttrs()
      Returns true if the HTML tree has attributes.
      Gibt zurück:
      true if the HTML tree has attributes else return false
    • hasAttr

      public boolean hasAttr(HtmlAttr attrName)
      Returns true if the HTML tree has a specific attribute.
      Parameter:
      attrName - name of the attribute to check within the HTML tree
      Gibt zurück:
      true if the HTML tree has the specified attribute else return false
    • isDiscardable

      public boolean isDiscardable()
      Returns true if the HTML tree does not affect the output and can be discarded.

      This implementation considers non-void elements without content or id attribute as discardable, with the exception of SCRIPT which can sometimes be used without content.

      Setzt außer Kraft:
      isDiscardable in Klasse Content
      Gibt zurück:
      true if the HTML tree can be discarded without affecting the output
    • isInline

      public boolean isInline()
      Returns true if the element is a normal element that is phrasing content.
      Gibt zurück:
      true if this is an inline element
      Siehe auch:
    • isVoid

      public boolean isVoid()
      Returns whether or not this is a void element.
      Gibt zurück:
      whether or not this is a void element
      Siehe auch:
    • write

      public boolean write(Writer out, String newline, boolean atNewline) throws IOException
      Beschreibung aus Klasse kopiert: Content
      Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.
      Angegeben von:
      write in Klasse Content
      Parameter:
      out - the writer
      newline - the newline sequence to use
      atNewline - whether the writer has just written a newline
      Gibt zurück:
      whether the writer has just written a newline
      Löst aus:
      IOException - if an error occurs while writing the output