Interface StylesBuilder

  • All Known Implementing Classes:
    DomStylesBuilder, HtmlStylesBuilder

    public interface StylesBuilder
    Builds the style attribute on an element.

    The HTML implementation of class appends the style properties to the HTML string. The DOM implementation of this class sets the element's styles directly.

    • Method Detail

      • endStyle

        void endStyle()
        End the current style attribute.
        Throws:
        java.lang.IllegalStateException - if the style attribute is already closed
      • opacity

        StylesBuilder opacity​(double value)
        Set the opacity css property.
      • paddingBottom

        StylesBuilder paddingBottom​(double value,
                                    Style.Unit unit)
        Set the padding-bottom css property.
      • trustedBackgroundColor

        StylesBuilder trustedBackgroundColor​(java.lang.String value)

        Sets the "background-color" style property to the specified color string. Does not check or escape the color string. The calling code should be carefully reviewed to ensure that the provided color string won't cause a security issue if included in a style attribute.

        For details and constraints, see SafeStyles.

        Returns:
        this StylesBuilder
      • trustedBackgroundImage

        StylesBuilder trustedBackgroundImage​(java.lang.String value)

        Sets the "background-image" style property to the specified value. Does not check or escape the value. The calling code should be carefully reviewed to ensure that the provided value string won't cause a security issue if included in a style attribute.

        For details and constraints, see SafeStyles.

        Returns:
        this StylesBuilder
      • trustedBorderColor

        StylesBuilder trustedBorderColor​(java.lang.String value)

        Sets the "border-color" style property to the specified color string. Does not check or escape the color string. The calling code should be carefully reviewed to ensure that the provided color string won't cause a security issue if included in a style attribute.

        For details and constraints, see SafeStyles.

        Returns:
        this StylesBuilder
      • trustedColor

        StylesBuilder trustedColor​(java.lang.String value)

        Sets the "color" style property, which controls font color, to the specified color string. Does not check or escape the color string. The calling code should be carefully reviewed to ensure that the provided color string won't cause a security issue if included in a style attribute.

        For details and constraints, see SafeStyles.

        Returns:
        this StylesBuilder
      • trustedOutlineColor

        StylesBuilder trustedOutlineColor​(java.lang.String value)

        Sets the "outline-color" style property to the specified color string. Does not check or escape the color string. The calling code should be carefully reviewed to ensure that the provided color string won't cause a security issue if included in a style attribute.

        For details and constraints, see SafeStyles.

        Returns:
        this StylesBuilder
      • trustedProperty

        StylesBuilder trustedProperty​(java.lang.String name,
                                      double value,
                                      Style.Unit unit)

        Set a style property from a trusted name and a trusted value, i.e., without escaping the name and value. No checks are performed. The calling code should be carefully reviewed to ensure the argument will satisfy the SafeStyles contract when they are composed into the form: "<name>:<value>;".

        SafeStyles may never contain literal angle brackets. Otherwise, it could be unsafe to place a SafeStyles into a <style> tag (where it can't be HTML escaped). For example, if the SafeStyles containing " font: 'foo <style><script>evil</script>'" is used in a style sheet in a <style> tag, this could then break out of the style context into HTML.

        Parameters:
        unit - the units of the value
        Returns:
        this StylesBuilder
      • trustedProperty

        StylesBuilder trustedProperty​(java.lang.String name,
                                      java.lang.String value)

        Set a style property from a trusted name and a trusted value, i.e., without escaping the name and value. No checks are performed. The calling code should be carefully reviewed to ensure the argument will satisfy the SafeStyles contract when they are composed into the form: "<name>:<value>;".

        SafeStyles may never contain literal angle brackets. Otherwise, it could be unsafe to place a SafeStyles into a <style> tag (where it can't be HTML escaped). For example, if the SafeStyles containing " font: 'foo <style><script>evil</script>'" is used in a style sheet in a <style> tag, this could then break out of the style context into HTML.

        Returns:
        this StylesBuilder
      • verticalAlign

        StylesBuilder verticalAlign​(double value,
                                    Style.Unit unit)
        Sets the vertical-align CSS property.
      • zIndex

        StylesBuilder zIndex​(int value)
        Set the z-index css property.