if (stateObject.isDecorated()) {
toText(stateObject);
}
else {
TrimExpression expression = stateObject.getExpression();
// 'TRIM'
appendIdentifier((expression != null) ? expression.getActualIdentifier() : stateObject.getIdentifier(), stateObject.getIdentifier());
// '('
if (shouldOutput(expression) || expression.hasLeftParenthesis()) {
writer.append(LEFT_PARENTHESIS);
}
else if ((expression != null) && expression.hasSpaceAfterIdentifier()) {
writer.append(SPACE);
}
// Trim specification
if (stateObject.hasSpecification()) {
String specification = stateObject.getSpecification().name();
String actualSpecification = (expression != null) ? expression.getActualSpecificationIdentifier() : null;
if (!specification.equalsIgnoreCase(actualSpecification)) {
actualSpecification = specification;
}
appendIdentifier(actualSpecification, specification);
}
if (shouldOutput(expression) || expression.hasSpaceAfterSpecification()) {
writer.append(SPACE);
}
// Trim character
if (stateObject.hasTrimCharacter()) {
stateObject.getTrimCharacter().accept(this);
if (shouldOutput(expression) || expression.hasSpaceAfterTrimCharacter()) {
writer.append(SPACE);
}
}
// 'FROM'
if (stateObject.hasSpecification() ||
stateObject.hasTrimCharacter()) {
appendIdentifier((expression != null) ? expression.getActualFromIdentifier() : FROM, FROM);
if (shouldOutput(expression) || expression.hasSpaceAfterFrom()) {
writer.append(SPACE);
}
}
// String primary
if (stateObject.hasStateObject()) {
stateObject.getStateObject().accept(this);
}
// ')'
if (shouldOutput(expression) || expression.hasRightParenthesis()) {
writer.append(RIGHT_PARENTHESIS);
}
}
}