Class StringGenerator

  • Direct Known Subclasses:
    PlainStringGenerator, SafeHtmlStringGenerator

    public abstract class StringGenerator
    extends java.lang.Object
    Helper class to produce string expressions consisting of literals and computed values.
    • Field Detail

      • buf

        protected final java.lang.StringBuilder buf
        Output string buffer.
      • inString

        protected boolean inString
        True if we are in the middle of a string literal.
    • Constructor Detail

      • StringGenerator

        protected StringGenerator​(java.lang.StringBuilder buf)
        Initialize the StringGenerator with an output buffer.
        Parameters:
        buf - output buffer
    • Method Detail

      • appendExpression

        public void appendExpression​(java.lang.String expression,
                                     boolean isSafeHtmlTyped,
                                     boolean isPrimitiveTyped,
                                     boolean needsConversionToString)
        Append an expression to this string expression.
        Parameters:
        expression - to add
        isSafeHtmlTyped - true if the expression is known to be of type SafeHtml; only relevant if this generator has been initialized to generate a SafeHtml-valued expression
        isPrimitiveTyped - true if the expression is of a primitive type; only relevant if this generator has been initialized to generate a SafeHtml-valued expression
        needsConversionToString - true if the expression is not known to be of type String and needs to be converted
      • appendStringLiteral

        public void appendStringLiteral​(java.lang.String str)
        Append part of a string literal.
        Parameters:
        str - part of string literal
      • appendStringValuedExpression

        public void appendStringValuedExpression​(java.lang.String expression)
        Append an expression to this string expression.
        Parameters:
        expression - to add, which the caller asserts is String-valued
      • completeString

        public void completeString()
        Complete the string, closing an open quote and handling empty strings.
      • finishOutput

        protected abstract void finishOutput()
      • forceStringPrefix

        protected abstract void forceStringPrefix()
      • forceStringSuffix

        protected abstract void forceStringSuffix()