public abstract class StringGenerator extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
StringGenerator.Type
Type of expression being processed.
|
Modifier and Type | Field and Description |
---|---|
protected 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(StringBuilder buf)
Initialize the StringGenerator with an output buffer.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
afterExpression(StringGenerator.Type type) |
void |
appendExpression(String expression,
boolean isSafeHtmlTyped,
boolean isPrimitiveTyped,
boolean needsConversionToString)
Append an expression to this string expression.
|
void |
appendStringLiteral(String str)
Append part of a string literal.
|
void |
appendStringValuedExpression(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(StringBuilder buf,
boolean returnsSafeHtml)
Create a
StringGenerator instance. |
protected abstract void |
finishOutput() |
protected abstract void |
forceStringPrefix() |
protected abstract void |
forceStringSuffix() |
protected final StringBuilder buf
protected boolean inString
protected StringGenerator(StringBuilder buf)
buf
- output bufferpublic static StringGenerator create(StringBuilder buf, boolean returnsSafeHtml)
StringGenerator
instance.buf
- returnsSafeHtml
- StringGenerator
instancepublic void appendExpression(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(String str)
str
- part of string literalpublic void appendStringValuedExpression(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()
Copyright © 2018. All rights reserved.