Class HtmlAppendableBase<T extends HtmlAppendableBase<T>>

    • Constructor Detail

      • HtmlAppendableBase

        public HtmlAppendableBase​(LineAppendable other,
                                  boolean inheritIndent)
      • HtmlAppendableBase

        public HtmlAppendableBase​(int indentSize,
                                  int formatOptions)
      • HtmlAppendableBase

        public HtmlAppendableBase​(@Nullable
                                  java.lang.Appendable other,
                                  int indentSize,
                                  int formatOptions)
    • Method Detail

      • isSuppressOpenTagLine

        public boolean isSuppressOpenTagLine()
      • setSuppressOpenTagLine

        public void setSuppressOpenTagLine​(boolean suppressOpenTagLine)
      • isSuppressCloseTagLine

        public boolean isSuppressCloseTagLine()
      • setSuppressCloseTagLine

        @NotNull
        public T setSuppressCloseTagLine​(boolean suppressCloseTagLine)
      • toString

        @NotNull
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • raw

        @NotNull
        public T raw​(@NotNull
                     java.lang.CharSequence s)
        Specified by:
        raw in interface HtmlAppendable
      • raw

        @NotNull
        public T raw​(@NotNull
                     java.lang.CharSequence s,
                     int count)
        Specified by:
        raw in interface HtmlAppendable
      • rawPre

        @NotNull
        public T rawPre​(@NotNull
                        java.lang.CharSequence s)
        Specified by:
        rawPre in interface HtmlAppendable
      • rawIndentedPre

        @NotNull
        public T rawIndentedPre​(@NotNull
                                java.lang.CharSequence s)
        Specified by:
        rawIndentedPre in interface HtmlAppendable
      • text

        @NotNull
        public T text​(@NotNull
                      java.lang.CharSequence s)
        Specified by:
        text in interface HtmlAppendable
      • attr

        @NotNull
        public T attr​(@NotNull
                      java.lang.CharSequence attrName,
                      @NotNull
                      java.lang.CharSequence value)
        Specified by:
        attr in interface HtmlAppendable
      • tag

        @NotNull
        public T tag​(@NotNull
                     java.lang.CharSequence tagName)
        Specified by:
        tag in interface HtmlAppendable
      • tag

        @NotNull
        public T tag​(@NotNull
                     java.lang.CharSequence tagName,
                     @NotNull
                     java.lang.Runnable runnable)
        Specified by:
        tag in interface HtmlAppendable
      • tagVoid

        @NotNull
        public T tagVoid​(@NotNull
                         java.lang.CharSequence tagName)
        Specified by:
        tagVoid in interface HtmlAppendable
      • getOpenTagText

        protected java.lang.String getOpenTagText()
      • pushTag

        protected void pushTag​(java.lang.CharSequence tagName)
      • popTag

        protected void popTag​(java.lang.CharSequence tagName)
      • tagOpened

        protected void tagOpened​(java.lang.CharSequence tagName)
      • tagClosed

        protected void tagClosed​(java.lang.CharSequence tagName)
      • getOpenTags

        @NotNull
        public java.util.Stack<java.lang.String> getOpenTags()
        Specified by:
        getOpenTags in interface HtmlAppendable
      • getOpenTagsAfterLast

        @NotNull
        public java.util.List<java.lang.String> getOpenTagsAfterLast​(@NotNull
                                                                     java.lang.CharSequence latestTag)
        Specified by:
        getOpenTagsAfterLast in interface HtmlAppendable
      • tag

        @NotNull
        public T tag​(@NotNull
                     java.lang.CharSequence tagName,
                     boolean voidElement)
        Specified by:
        tag in interface HtmlAppendable
      • closeTag

        @NotNull
        public T closeTag​(@NotNull
                          java.lang.CharSequence tagName)
        Specified by:
        closeTag in interface HtmlAppendable
      • tag

        @NotNull
        public T tag​(@NotNull
                     java.lang.CharSequence tagName,
                     boolean withIndent,
                     boolean withLine,
                     @NotNull
                     java.lang.Runnable runnable)
        Specified by:
        tag in interface HtmlAppendable
      • tagVoidLine

        @NotNull
        public T tagVoidLine​(@NotNull
                             java.lang.CharSequence tagName)
        Specified by:
        tagVoidLine in interface HtmlAppendable
      • tagLine

        @NotNull
        public T tagLine​(@NotNull
                         java.lang.CharSequence tagName)
        Specified by:
        tagLine in interface HtmlAppendable
      • tagLine

        @NotNull
        public T tagLine​(@NotNull
                         java.lang.CharSequence tagName,
                         boolean voidElement)
        Specified by:
        tagLine in interface HtmlAppendable
      • tagLine

        @NotNull
        public T tagLine​(@NotNull
                         java.lang.CharSequence tagName,
                         @NotNull
                         java.lang.Runnable runnable)
        Specified by:
        tagLine in interface HtmlAppendable
      • tagIndent

        @NotNull
        public T tagIndent​(@NotNull
                           java.lang.CharSequence tagName,
                           @NotNull
                           java.lang.Runnable runnable)
        Specified by:
        tagIndent in interface HtmlAppendable
      • tagLineIndent

        @NotNull
        public T tagLineIndent​(@NotNull
                               java.lang.CharSequence tagName,
                               @NotNull
                               java.lang.Runnable runnable)
        Specified by:
        tagLineIndent in interface HtmlAppendable
      • iterator

        @NotNull
        public java.util.Iterator<LineInfo> iterator()
        Description copied from interface: LineAppendable
        Full line iterator NOTE: will not issue line() to terminate any unterminated lines before iteration and will not include unterminated lines in iteration
        Specified by:
        iterator in interface java.lang.Iterable<T extends HtmlAppendableBase<T>>
        Specified by:
        iterator in interface LineAppendable
        Returns:
        iterator over lines
      • getLines

        @NotNull
        public java.lang.Iterable<BasedSequence> getLines​(int maxTrailingBlankLines,
                                                          int startLine,
                                                          int endLine,
                                                          boolean withPrefixes)
        Description copied from interface: LineAppendable
        Full line iterator over some lines

        NOTE: will issue line() to terminate any unterminated lines before iteration

        Specified by:
        getLines in interface LineAppendable
        Parameters:
        maxTrailingBlankLines - maximum trailing blank lines, -1 if trailing EOL should be removed
        startLine - start line index
        endLine - end line index, exclusive
        withPrefixes - true if prefixes should be included, else only non-prefix line text
        Returns:
        iterator over lines
      • getLinesInfo

        @NotNull
        public java.lang.Iterable<LineInfo> getLinesInfo​(int maxTrailingBlankLines,
                                                         int startLine,
                                                         int endLine)
        Description copied from interface: LineAppendable
        Full line iterator with line info

        NOTE: will issue line() to terminate any unterminated lines before iteration

        Specified by:
        getLinesInfo in interface LineAppendable
        Parameters:
        maxTrailingBlankLines - maximum trailing blank lines, -1 if trailing EOL should be removed
        startLine - start line index
        endLine - end line index, exclusive
        Returns:
        iterator over lines
      • setPrefixLength

        public void setPrefixLength​(int lineIndex,
                                    int prefixEndIndex)
        Description copied from interface: LineAppendable
        Change prefix length for a given line without changing the line content
        Specified by:
        setPrefixLength in interface LineAppendable
        Parameters:
        lineIndex - index of the line
        prefixEndIndex - new prefix length
      • insertLine

        public void insertLine​(int lineIndex,
                               @NotNull
                               java.lang.CharSequence prefix,
                               @NotNull
                               java.lang.CharSequence text)
        Description copied from interface: LineAppendable
        Insert a line at the index with given content and prefix for a line
        Specified by:
        insertLine in interface LineAppendable
        Parameters:
        lineIndex - index of the line
        prefix - prefix of the line
        text - content text of the line
      • setLine

        public void setLine​(int lineIndex,
                            @NotNull
                            java.lang.CharSequence prefix,
                            @NotNull
                            java.lang.CharSequence text)
        Description copied from interface: LineAppendable
        Set content and prefix for a line
        Specified by:
        setLine in interface LineAppendable
        Parameters:
        lineIndex - index of the line
        prefix - prefix of the line
        text - content text of the line
      • appendTo

        public <T extends java.lang.Appendable> T appendTo​(@NotNull
                                                           T out,
                                                           boolean withPrefixes,
                                                           int maxBlankLines,
                                                           int maxTrailingBlankLines,
                                                           int startLine,
                                                           int endLine)
                                                    throws java.io.IOException
        Description copied from interface: LineAppendable
        append lines to appendable with given maximum trailing blank lines and given prefix to add to all lines

        NOTE:

        Specified by:
        appendTo in interface LineAppendable
        Type Parameters:
        T - type of out
        Parameters:
        out - appendable to output the resulting lines
        withPrefixes - true if to include prefixes
        maxBlankLines - maximum blank lines to allow in the body,
        maxTrailingBlankLines - maximum trailing blank lines at the end, if <maxBlankLines then maxBlankLines will be used, if -1 then no trailing EOL will be added
        startLine - line from which to start output
        endLine - line at which to stop output
        Returns:
        out
        Throws:
        java.io.IOException - if thrown by appendable
      • endsWithEOL

        public boolean endsWithEOL()
        Specified by:
        endsWithEOL in interface LineAppendable
        Returns:
        true if not empty and have no unterminated lines
      • isPendingSpace

        public boolean isPendingSpace()
        Description copied from interface: LineAppendable
        Test if trailing text ends in space or tab
        Specified by:
        isPendingSpace in interface LineAppendable
        Returns:
        true if ending in space or tab
      • isPreFormatted

        public boolean isPreFormatted()
        Specified by:
        isPreFormatted in interface LineAppendable
        Returns:
        true if in pre-formatted region
      • getTrailingBlankLines

        public int getTrailingBlankLines​(int endLine)
        Description copied from interface: LineAppendable
        Get trailing blank line count ending on given line
        Specified by:
        getTrailingBlankLines in interface LineAppendable
        Parameters:
        endLine - end line
        Returns:
        number of trailing blank lines
      • column

        public int column()
        Description copied from interface: LineAppendable
        Get column offset after last append
        Specified by:
        column in interface LineAppendable
        Returns:
        column offset after last append
      • getLineCount

        public int getLineCount()
        Description copied from interface: LineAppendable
        Get the number of lines appended, not including any unterminated ones
        Specified by:
        getLineCount in interface LineAppendable
        Returns:
        number of full lines appended
      • getLineCountWithPending

        public int getLineCountWithPending()
        Description copied from interface: LineAppendable
        Get the number of lines appended, including any unterminated ones

        NOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly

        Specified by:
        getLineCountWithPending in interface LineAppendable
        Returns:
        number of lines appended
      • getOptions

        public int getOptions()
        Description copied from interface: LineAppendable
        Get current options as bit mask flags
        Specified by:
        getOptions in interface LineAppendable
        Returns:
        option flags
      • getPendingSpace

        public int getPendingSpace()
        Description copied from interface: LineAppendable
        Get number of spaces at end of pending text
        Specified by:
        getPendingSpace in interface LineAppendable
        Returns:
        number of eols at end of text
      • getPendingEOL

        public int getPendingEOL()
        Description copied from interface: LineAppendable
        Get number of EOLs at end of appendable, this is actually number of tail blank lines
        Specified by:
        getPendingEOL in interface LineAppendable
        Returns:
        number of eols at end of text
      • offset

        public int offset()
        Description copied from interface: LineAppendable
        Get text offset of all output lines, excluding any text for the last line being accumulated
        Specified by:
        offset in interface LineAppendable
        Returns:
        offset of text as would be returned for all
      • getAfterEolPrefixDelta

        public int getAfterEolPrefixDelta()
        Description copied from interface: LineAppendable
        Get pending prefix after EOL
        Specified by:
        getAfterEolPrefixDelta in interface LineAppendable
        Returns:
        change in prefix length after next eol
      • getPrefix

        @NotNull
        public BasedSequence getPrefix()
        Description copied from interface: LineAppendable
        Get prefix being applied to all lines, even in pre-formatted sections This is the prefix that will be set after EOL
        Specified by:
        getPrefix in interface LineAppendable
        Returns:
        char sequence of the current prefix
      • getLineInfo

        @NotNull
        public LineInfo getLineInfo​(int lineIndex)
        Description copied from interface: LineAppendable
        Get Line information at given line index

        NOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly

        Specified by:
        getLineInfo in interface LineAppendable
        Parameters:
        lineIndex - line index for the info to get
        Returns:
        line info
      • getLine

        @NotNull
        public BasedSequence getLine​(int lineIndex)
        Description copied from interface: LineAppendable
        Get Line at given line index

        NOTE: if there is an unterminated line it will be available as the last line, without being terminated explicitly

        Specified by:
        getLine in interface LineAppendable
        Parameters:
        lineIndex - line index
        Returns:
        line char sequence
      • getIndentPrefix

        @NotNull
        public BasedSequence getIndentPrefix()
        Description copied from interface: LineAppendable
        Get prefix appended after a new line character for every indent level
        Specified by:
        getIndentPrefix in interface LineAppendable
        Returns:
        char sequence of the current indent prefix used for each indent level
      • toSequence

        @NotNull
        public java.lang.CharSequence toSequence​(int maxBlankLines,
                                                 int maxTrailingBlankLines,
                                                 boolean withPrefixes)
        Description copied from interface: LineAppendable
        get the resulting text for all lines
        Specified by:
        toSequence in interface LineAppendable
        Parameters:
        maxBlankLines - maximum blank lines to allow in the text
        maxTrailingBlankLines - maximum trailing blank lines
        withPrefixes - true if to include prefixes
        Returns:
        resulting text
      • toString

        @NotNull
        public java.lang.String toString​(int maxBlankLines,
                                         int maxTrailingBlankLines,
                                         boolean withPrefixes)
        Description copied from interface: LineAppendable
        get the resulting text for all lines
        Specified by:
        toString in interface LineAppendable
        Parameters:
        maxBlankLines - maximum blank lines to allow in the text
        maxTrailingBlankLines - maximum trailing blank lines
        withPrefixes - true if to include prefixes
        Returns:
        resulting text
      • removeExtraBlankLines

        @NotNull
        public T removeExtraBlankLines​(int maxBlankLines,
                                       int maxTrailingBlankLines,
                                       int startLine,
                                       int endLine)
        Description copied from interface: LineAppendable
        Normalize the appendable by removing extra blank lines in the body or at the end of given line range
        Specified by:
        removeExtraBlankLines in interface LineAppendable
        Parameters:
        maxBlankLines - maximum blank lines to allow in the body
        maxTrailingBlankLines - maximum trailing blank lines ending on endLine, if <maxBlankLines then maxBlankLines will be used
        startLine - line from which to start output
        endLine - line at which to stop output
        Returns:
        this
      • removeLines

        @NotNull
        public T removeLines​(int startLine,
                             int endLine)
        Specified by:
        removeLines in interface LineAppendable
      • changeOptions

        @NotNull
        public T changeOptions​(int addFlags,
                               int removeFlags)
        Specified by:
        changeOptions in interface LineAppendable
      • addIndentOnFirstEOL

        @NotNull
        public T addIndentOnFirstEOL​(@NotNull
                                     java.lang.Runnable listener)
        Description copied from interface: LineAppendable
        Add an indent on first EOL appended and run runnable
        Specified by:
        addIndentOnFirstEOL in interface LineAppendable
        Parameters:
        listener - runnable to run if adding indent on first EOL
        Returns:
        this
      • addPrefix

        @NotNull
        public T addPrefix​(@NotNull
                           java.lang.CharSequence prefix)
        Description copied from interface: LineAppendable
        Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections

        This appends the sequence to current prefix

        Specified by:
        addPrefix in interface LineAppendable
        Parameters:
        prefix - prefix characters to add to current prefix for new lines appended after this is set
        Returns:
        this
      • addPrefix

        @NotNull
        public T addPrefix​(@NotNull
                           java.lang.CharSequence prefix,
                           boolean afterEol)
        Description copied from interface: LineAppendable
        Add to prefix appended after a new line character for every line and after a new line in pre-formatted sections

        This appends the sequence to current prefix

        Specified by:
        addPrefix in interface LineAppendable
        Parameters:
        prefix - prefix characters to add to current prefix for new lines appended after this is set
        afterEol - if true prefix will take effect after EOL
        Returns:
        this
      • append

        @NotNull
        public T append​(char c)
        Specified by:
        append in interface java.lang.Appendable
        Specified by:
        append in interface LineAppendable
      • append

        @NotNull
        public T append​(@NotNull
                        java.lang.CharSequence csq)
        Specified by:
        append in interface java.lang.Appendable
        Specified by:
        append in interface LineAppendable
      • append

        @NotNull
        public T append​(@NotNull
                        java.lang.CharSequence csq,
                        int start,
                        int end)
        Specified by:
        append in interface java.lang.Appendable
        Specified by:
        append in interface LineAppendable
      • append

        @NotNull
        public T append​(@NotNull
                        LineAppendable lines,
                        int startLine,
                        int endLine,
                        boolean withPrefixes)
        Description copied from interface: LineAppendable
        Append lines from another line formatting appendable.

        NOTE: does not apply formatting options. Instead, appends already formatted lines as is

        If there is an accumulating line, it will be terminated by an EOL before appending lines

        Specified by:
        append in interface LineAppendable
        Parameters:
        lines - lines to append, any unterminated lines will be terminated by a LineAppendable.line() invocation.
        startLine - start line to append
        endLine - end line to append, endLine is excluded.
        withPrefixes - true if to include prefixes from the lineAppendable.
        Returns:
        this
      • blankLine

        @NotNull
        public T blankLine()
        Description copied from interface: LineAppendable
        Add a blank line, if there is not one already appended.
        Specified by:
        blankLine in interface LineAppendable
        Returns:
        this
      • blankLine

        @NotNull
        public T blankLine​(int count)
        Description copied from interface: LineAppendable
        Add a blank lines, if there isn't already given number of blank lines appended. Will append only enough blank lines to increase it to given level. If more are already in the wings then nothing is done.
        Specified by:
        blankLine in interface LineAppendable
        Parameters:
        count - number of blank lines to append
        Returns:
        this
      • blankLineIf

        @NotNull
        public T blankLineIf​(boolean predicate)
        Description copied from interface: LineAppendable
        Add a blank line, if predicate is true and there isn't already blank lines appended.
        Specified by:
        blankLineIf in interface LineAppendable
        Parameters:
        predicate - when true append blank line
        Returns:
        this
      • closePreFormatted

        @NotNull
        public T closePreFormatted()
        Description copied from interface: LineAppendable
        Close preformatted section and suspend content modification
        Specified by:
        closePreFormatted in interface LineAppendable
        Returns:
        this
      • indent

        @NotNull
        public T indent()
        Description copied from interface: LineAppendable
        Increase the indent level, will terminate the current line if there is unterminated text

        NOTE: this is equivalent to pushPrefix(), addPrefix(getIndentPrefix()) but adds a flag to validate that LineAppendable.unIndent() is called only on prefixes added by this method

        Specified by:
        indent in interface LineAppendable
        Returns:
        this
      • line

        @NotNull
        public T line()
        Description copied from interface: LineAppendable
        Add a new line if there was any unterminated text appended or if this is a preformatted region
        Specified by:
        line in interface LineAppendable
        Returns:
        this
      • lineIf

        @NotNull
        public T lineIf​(boolean predicate)
        Description copied from interface: LineAppendable
        Add a new line, if predicate is true and line() would add an EOL.
        Specified by:
        lineIf in interface LineAppendable
        Parameters:
        predicate - call LineAppendable.line() if value is true.
        Returns:
        this
      • lineWithTrailingSpaces

        @NotNull
        public T lineWithTrailingSpaces​(int count)
        Description copied from interface: LineAppendable
        Add a new line, keep trailing spaces if there was any unterminated text appended

        NOTE: only applies in preformatted region or if the line is not empty

        Specified by:
        lineWithTrailingSpaces in interface LineAppendable
        Parameters:
        count - number of trailing spaces to add
        Returns:
        this
      • openPreFormatted

        @NotNull
        public T openPreFormatted​(boolean keepIndent)
        Description copied from interface: LineAppendable
        Open preformatted section and suspend content modification
        Specified by:
        openPreFormatted in interface LineAppendable
        Parameters:
        keepIndent - if true will add the current prefix to first line
        Returns:
        this
      • popPrefix

        @NotNull
        public T popPrefix()
        Description copied from interface: LineAppendable
        Pop a prefix from the stack and set the current prefix
        Specified by:
        popPrefix in interface LineAppendable
        Returns:
        this
      • popPrefix

        @NotNull
        public T popPrefix​(boolean afterEol)
        Description copied from interface: LineAppendable
        Pop a prefix from the stack and set the current prefix
        Specified by:
        popPrefix in interface LineAppendable
        Parameters:
        afterEol - if true prefix will take effect after EOL
        Returns:
        this
      • pushPrefix

        @NotNull
        public T pushPrefix()
        Description copied from interface: LineAppendable
        Save the current prefix on the stack
        Specified by:
        pushPrefix in interface LineAppendable
        Returns:
        this
      • removeIndentOnFirstEOL

        @NotNull
        public T removeIndentOnFirstEOL​(@NotNull
                                        java.lang.Runnable listener)
        Description copied from interface: LineAppendable
        Remove runnable, has no effect if EOL was already appended and runnable was run
        Specified by:
        removeIndentOnFirstEOL in interface LineAppendable
        Parameters:
        listener - runnable added with addIndentOnFirstEOL
        Returns:
        this
      • append

        @NotNull
        public T append​(char c,
                        int count)
        Specified by:
        append in interface LineAppendable
      • setIndentPrefix

        @NotNull
        public T setIndentPrefix​(@Nullable
                                 java.lang.CharSequence prefix)
        Description copied from interface: LineAppendable
        Set prefix to append after a new line character for every indent level
        Specified by:
        setIndentPrefix in interface LineAppendable
        Parameters:
        prefix - prefix characters for new lines appended after this is set
        Returns:
        this
      • setOptions

        @NotNull
        public T setOptions​(int flags)
        Description copied from interface: LineAppendable
        Set options on processing text
        Specified by:
        setOptions in interface LineAppendable
        Parameters:
        flags - option flags
        Returns:
        this
      • setPrefix

        @NotNull
        public T setPrefix​(@NotNull
                           java.lang.CharSequence prefix)
        Description copied from interface: LineAppendable
        Set prefix appended after a new line character for every line and after a new line in pre-formatted sections

        This appends the sequence to current prefix

        Specified by:
        setPrefix in interface LineAppendable
        Parameters:
        prefix - prefix characters to add to current prefix for new lines appended after this is set
        Returns:
        this
      • setPrefix

        @NotNull
        public T setPrefix​(@Nullable
                           java.lang.CharSequence prefix,
                           boolean afterEol)
        Description copied from interface: LineAppendable
        Set prefix appended after a new line character for every line and after a new line in pre-formatted sections

        This appends the sequence to current prefix

        Specified by:
        setPrefix in interface LineAppendable
        Parameters:
        prefix - prefix characters to add to current prefix for new lines appended after this is set
        afterEol - if true prefix will take effect after EOL
        Returns:
        this
      • unIndent

        @NotNull
        public T unIndent()
        Description copied from interface: LineAppendable
        Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text

        NOTE: this is equivalent to popPrefix() but with validation that it is called only on prefixes added by LineAppendable.indent()

        Specified by:
        unIndent in interface LineAppendable
        Returns:
        this
      • unIndentNoEol

        @NotNull
        public T unIndentNoEol()
        Description copied from interface: LineAppendable
        Decrease the indent level, if there is unterminated text then unindented prefix is to be applied after the next EOL.

        Will NOT terminate the current line if there is unterminated text

        NOTE: should be used with LineAppendable.addIndentOnFirstEOL(Runnable) if callback is invoked

        Specified by:
        unIndentNoEol in interface LineAppendable
        Returns:
        this