Class HTMLElement


  • public class HTMLElement
    extends XMLElement
    A XMLElement with utility methods to create XHTML documents. It provides methods of HTML tags to avoid magic strings in the generators.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String PUBID  
      private static java.lang.String SYSTEM  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        HTMLElement​(java.io.OutputStream output, java.lang.String encoding)
      Creates a html root element of a XHTML document.
      private HTMLElement​(java.lang.String name, HTMLElement parent)  
    • Constructor Detail

      • HTMLElement

        public HTMLElement​(java.io.OutputStream output,
                           java.lang.String encoding)
                    throws java.io.IOException
        Creates a html root element of a XHTML document.
        Parameters:
        encoding - character encoding used for output
        output - output stream will be closed if the root element is closed
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • HTMLElement

        private HTMLElement​(java.lang.String name,
                            HTMLElement parent)
                     throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • element

        public HTMLElement element​(java.lang.String name)
                            throws java.io.IOException
        Description copied from class: XMLElement
        Creates a new child element for this element. Might be overridden in subclasses to return a instance of the subclass.
        Overrides:
        element in class XMLElement
        Parameters:
        name - name of the child element
        Returns:
        child element instance
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • classattr

        private void classattr​(java.lang.String classattr)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • head

        public HTMLElement head()
                         throws java.io.IOException
        Creates a 'head' element.
        Returns:
        'head' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • body

        public HTMLElement body()
                         throws java.io.IOException
        Creates a 'body' element.
        Returns:
        'body' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • meta

        public HTMLElement meta​(java.lang.String httpequivattr,
                                java.lang.String contentattr)
                         throws java.io.IOException
        Creates a 'meta' element.
        Parameters:
        httpequivattr - value of the http-equiv attribute
        contentattr - value for the content attribute
        Returns:
        'meta' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • link

        public HTMLElement link​(java.lang.String relattr,
                                java.lang.String hrefattr,
                                java.lang.String typeattr)
                         throws java.io.IOException
        Creates a 'link' element.
        Parameters:
        relattr - value of the rel attribute
        hrefattr - value for the href attribute
        typeattr - value for the type attribute
        Returns:
        'link' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • title

        public HTMLElement title()
                          throws java.io.IOException
        Creates a 'title' element.
        Returns:
        'title' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • h1

        public HTMLElement h1()
                       throws java.io.IOException
        Creates a 'h1' element.
        Returns:
        'h1' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • p

        public HTMLElement p()
                      throws java.io.IOException
        Creates a 'p' element.
        Returns:
        'p' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • span

        public HTMLElement span()
                         throws java.io.IOException
        Creates a 'span' element.
        Returns:
        'span' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • span

        public HTMLElement span​(java.lang.String classattr)
                         throws java.io.IOException
        Creates a 'span' element.
        Parameters:
        classattr - value of the class attribute
        Returns:
        'span' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • span

        public HTMLElement span​(java.lang.String classattr,
                                java.lang.String idattr)
                         throws java.io.IOException
        Creates a 'span' element.
        Parameters:
        classattr - value of the class attribute
        idattr - value of the id attribute
        Returns:
        'span' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • div

        public HTMLElement div​(java.lang.String classattr)
                        throws java.io.IOException
        Creates a 'div' element.
        Parameters:
        classattr - value of the class attribute
        Returns:
        'div' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • code

        public HTMLElement code()
                         throws java.io.IOException
        Creates a 'code' element.
        Returns:
        'code' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • pre

        public HTMLElement pre​(java.lang.String classattr)
                        throws java.io.IOException
        Creates a 'pre' element.
        Parameters:
        classattr - value of the class attribute
        Returns:
        'pre' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • a

        public HTMLElement a​(java.lang.String hrefattr)
                      throws java.io.IOException
        Creates a 'a' element.
        Parameters:
        hrefattr - value of the href attribute
        Returns:
        'a' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • a

        public HTMLElement a​(java.lang.String hrefattr,
                             java.lang.String classattr)
                      throws java.io.IOException
        Creates a 'a' element.
        Parameters:
        hrefattr - value of the href attribute
        classattr - value of the class attribute
        Returns:
        'a' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • a

        public HTMLElement a​(ILinkable linkable,
                             ReportOutputFolder base)
                      throws java.io.IOException
        Creates a link to the given ILinkable.
        Parameters:
        linkable - object to link to
        base - base folder where the link should be placed
        Returns:
        'a' element or 'span' element, if the link target does not exist
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • table

        public HTMLElement table​(java.lang.String classattr)
                          throws java.io.IOException
        Creates a 'table' element.
        Parameters:
        classattr - value of the class attribute
        Returns:
        'table' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • thead

        public HTMLElement thead()
                          throws java.io.IOException
        Creates a 'thead' element.
        Returns:
        'thead' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • tfoot

        public HTMLElement tfoot()
                          throws java.io.IOException
        Creates a 'tfoot' element.
        Returns:
        'tfoot' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • tbody

        public HTMLElement tbody()
                          throws java.io.IOException
        Creates a 'tbody' element.
        Returns:
        'tbody' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • tr

        public HTMLElement tr()
                       throws java.io.IOException
        Creates a 'tr' element.
        Returns:
        'tr' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • td

        public HTMLElement td()
                       throws java.io.IOException
        Creates a 'td' element.
        Returns:
        'td' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • td

        public HTMLElement td​(java.lang.String classattr)
                       throws java.io.IOException
        Creates a 'td' element.
        Parameters:
        classattr - value of the class attribute
        Returns:
        'td' element
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • img

        public void img​(java.lang.String srcattr,
                        int widthattr,
                        int heightattr,
                        java.lang.String titleattr)
                 throws java.io.IOException
        Creates a 'img' element.
        Parameters:
        srcattr - value of the src attribute
        widthattr - value of the width attribute
        heightattr - value of the height attribute
        titleattr - value of the title and alt attribute
        Throws:
        java.io.IOException - in case of problems with the underlying output
      • script

        public void script​(java.lang.String srcattr)
                    throws java.io.IOException
        Creates a JavaScript 'script' element.
        Parameters:
        srcattr - value of the src attribute
        Throws:
        java.io.IOException - in case of problems with the underlying output