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 Details

    • backgroundImage

      StylesBuilder backgroundImage(SafeUri uri)
      Sets the background-image CSS property.
      Parameters:
      uri - the URI of the background image
      Returns:
      this StylesBuilder
      See Also:
    • borderStyle

      StylesBuilder borderStyle(Style.BorderStyle value)
      Sets the border-style CSS property.
    • borderWidth

      StylesBuilder borderWidth(double value, Style.Unit unit)
      Set the border-width css property.
    • bottom

      StylesBuilder bottom(double value, Style.Unit unit)
      Set the bottom css property.
    • cursor

      StylesBuilder cursor(Style.Cursor value)
      Sets the cursor CSS property.
    • display

      StylesBuilder display(Style.Display value)
      Sets the display CSS property.
    • endStyle

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

      StylesBuilder floatprop(Style.Float value)
      Set the float css property.
    • fontSize

      StylesBuilder fontSize(double value, Style.Unit unit)
      Set the font-size css property.
    • fontStyle

      StylesBuilder fontStyle(Style.FontStyle value)
      Sets the font-style CSS property.
    • fontWeight

      StylesBuilder fontWeight(Style.FontWeight value)
      Sets the font-weight CSS property.
    • height

      StylesBuilder height(double value, Style.Unit unit)
      Set the height css property.
    • left

      StylesBuilder left(double value, Style.Unit unit)
      Set the left css property.
    • lineHeight

      StylesBuilder lineHeight(double value, Style.Unit unit)
      Set the line-height css property.
    • listStyleType

      StylesBuilder listStyleType(Style.ListStyleType value)
      Sets the list-style-type CSS property.
    • margin

      StylesBuilder margin(double value, Style.Unit unit)
      Set the margin css property.
    • marginBottom

      StylesBuilder marginBottom(double value, Style.Unit unit)
      Set the margin-bottom css property.
    • marginLeft

      StylesBuilder marginLeft(double value, Style.Unit unit)
      Set the margin-left css property.
    • marginRight

      StylesBuilder marginRight(double value, Style.Unit unit)
      Set the margin-right css property.
    • marginTop

      StylesBuilder marginTop(double value, Style.Unit unit)
      Set the margin-top css property.
    • opacity

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

      StylesBuilder outlineStyle(Style.OutlineStyle value)
      Sets the outline-style CSS property.
    • outlineWidth

      StylesBuilder outlineWidth(double value, Style.Unit unit)
      Set the outline-width css property.
    • overflow

      StylesBuilder overflow(Style.Overflow value)
      Sets the overflow CSS property.
    • overflowX

      StylesBuilder overflowX(Style.Overflow value)
      Sets the overflow-x CSS property.
    • overflowY

      StylesBuilder overflowY(Style.Overflow value)
      Sets the overflow-y CSS property.
    • padding

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

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

      StylesBuilder paddingLeft(double value, Style.Unit unit)
      Set the padding-left css property.
    • paddingRight

      StylesBuilder paddingRight(double value, Style.Unit unit)
      Set the padding-right css property.
    • paddingTop

      StylesBuilder paddingTop(double value, Style.Unit unit)
      Set the padding-top css property.
    • position

      StylesBuilder position(Style.Position value)
      Sets the position CSS property.
    • right

      StylesBuilder right(double value, Style.Unit unit)
      Set the right css property.
    • tableLayout

      StylesBuilder tableLayout(Style.TableLayout value)
      Set the table-layout CSS property.
    • textAlign

      StylesBuilder textAlign(Style.TextAlign value)
      Set the text-align CSS property.
    • textDecoration

      StylesBuilder textDecoration(Style.TextDecoration value)
      Set the text-decoration CSS property.
    • textIndent

      StylesBuilder textIndent(double value, Style.Unit unit)
      Set the text-indent CSS property.
    • textJustify

      StylesBuilder textJustify(Style.TextJustify value)
      Set the text-justify CSS3 property.
    • textOverflow

      StylesBuilder textOverflow(Style.TextOverflow value)
      Set the text-overflow CSS3 property.
    • textTransform

      StylesBuilder textTransform(Style.TextTransform value)
      Set the text-transform CSS property.
    • top

      StylesBuilder top(double value, Style.Unit unit)
      Set the top css property.
    • trustedBackgroundColor

      StylesBuilder trustedBackgroundColor(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(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(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(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(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(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(String name, 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.
    • verticalAlign

      StylesBuilder verticalAlign(Style.VerticalAlign value)
      Sets the vertical-align CSS property.
    • visibility

      StylesBuilder visibility(Style.Visibility value)
      Sets the visibility CSS property.
    • width

      StylesBuilder width(double value, Style.Unit unit)
      Set the width css property.
    • zIndex

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