Class SafeHtmlBuilder


  • public final class SafeHtmlBuilder
    extends Object
    Utility to create and manage safe html objects setting strings, chars, numbers.
    Author:
    Andrea "Stock" Stocchero
    • Field Detail

      • EMPTY_SAFE_HTML

        public static final SafeHtml EMPTY_SAFE_HTML
        Default empty SafeHtml.
    • Method Detail

      • create

        public static SafeHtmlBuilder create()
        Creates and returns a safe html builder to consume.
        Returns:
        a safe html builder to consume
      • append

        public SafeHtmlBuilder append​(boolean value)
        Appends a boolean to the builder.
        Parameters:
        value - the boolean to add
        Returns:
        the safe html builder instance
      • append

        public SafeHtmlBuilder append​(byte value)
        Appends a byte to the builder.
        Parameters:
        value - the byte to add
        Returns:
        the safe html builder instance
      • append

        public SafeHtmlBuilder append​(char value)
        Appends a char to the builder.
        Parameters:
        value - the char to add
        Returns:
        the safe html builder instance
      • append

        public SafeHtmlBuilder append​(double value)
        Appends a double to the builder.
        Parameters:
        value - the double to add
        Returns:
        the safe html builder instance
      • append

        public SafeHtmlBuilder append​(int value)
        Appends a integer to the builder.
        Parameters:
        value - the integer to add
        Returns:
        the safe html builder instance
      • append

        public SafeHtmlBuilder append​(SafeHtml value)
        Appends the contents of another safe html object.
        Parameters:
        value - the safe html instance to add
        Returns:
        the safe html builder instance
      • appendEscaped

        public SafeHtmlBuilder appendEscaped​(String value)
        Appends a string to the builder.
        Parameters:
        value - the string to add
        Returns:
        the safe html builder instance
      • appendEscapedLines

        public SafeHtmlBuilder appendEscapedLines​(String value)
        Appends a string to the builder, splitting the string if contains line separators.
        Parameters:
        value - the string to append
        Returns:
        the safe html builder instance
      • appendHtmlConstant

        public SafeHtmlBuilder appendHtmlConstant​(String value)
        Appends a string without any escaping.
        Parameters:
        value - the HTML to be appended
        Returns:
        the safe html builder instance
      • toSafeHtml

        public SafeHtml toSafeHtml()
        Returns the safe html instance.
        Returns:
        the safe html instance