public abstract class StringGenerator
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
StringGenerator.Type
Type of expression being processed.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.StringBuilder |
buf
Output string buffer.
|
protected boolean |
inString
True if we are in the middle of a string literal.
|
Modifier | Constructor and Description |
---|---|
protected |
StringGenerator(java.lang.StringBuilder buf)
Initialize the StringGenerator with an output buffer.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
afterExpression(StringGenerator.Type type) |
void |
appendExpression(java.lang.String expression,
boolean isSafeHtmlTyped,
boolean isPrimitiveTyped,
boolean needsConversionToString)
Append an expression to this string expression.
|
void |
appendStringLiteral(java.lang.String str)
Append part of a string literal.
|
void |
appendStringValuedExpression(java.lang.String expression)
Append an expression to this string expression.
|
protected abstract void |
beforeExpression(StringGenerator.Type type) |
void |
completeString()
Complete the string, closing an open quote and handling empty strings.
|
static StringGenerator |
create(java.lang.StringBuilder buf,
boolean returnsSafeHtml)
Create a
StringGenerator instance. |
protected abstract void |
finishOutput() |
protected abstract void |
forceStringPrefix() |
protected abstract void |
forceStringSuffix() |
protected final java.lang.StringBuilder buf
protected boolean inString
protected StringGenerator(java.lang.StringBuilder buf)
buf
- output bufferpublic static StringGenerator create(java.lang.StringBuilder buf, boolean returnsSafeHtml)
StringGenerator
instance.buf
- returnsSafeHtml
- StringGenerator
instancepublic void appendExpression(java.lang.String expression, boolean isSafeHtmlTyped, boolean isPrimitiveTyped, boolean needsConversionToString)
expression
- to addisSafeHtmlTyped
- true if the expression is known to be of type
SafeHtml
; only relevant
if this generator has been initialized to generate a
SafeHtml
-valued
expressionisPrimitiveTyped
- true if the expression is of a primitive type;
only relevant if this generator has been initialized to generate a
SafeHtml
-valued
expressionneedsConversionToString
- true if the expression is not known to be
of type String and needs to be convertedpublic void appendStringLiteral(java.lang.String str)
str
- part of string literalpublic void appendStringValuedExpression(java.lang.String expression)
expression
- to add, which the caller asserts is String-valuedpublic void completeString()
protected abstract void afterExpression(StringGenerator.Type type)
protected abstract void beforeExpression(StringGenerator.Type type)
protected abstract void finishOutput()
protected abstract void forceStringPrefix()
protected abstract void forceStringSuffix()