/** {@inheritDoc} */
  @Override
  public void parse(String jpqlFragment) {

    StringBuilder sb = new StringBuilder();
    sb.append(TRIM);
    sb.append(LEFT_PARENTHESIS);
    sb.append(jpqlFragment);
    sb.append(RIGHT_PARENTHESIS);

    JPQLExpression jpqlExpression =
        new JPQLExpression(sb, getGrammar(), FunctionsReturningStringsBNF.ID, true);

    TrimExpression trimExpression = (TrimExpression) jpqlExpression.getQueryStatement();
    setSpecification(trimExpression.getSpecification());
    parseTrimCharacter(trimExpression.getTrimCharacter().toParsedText());
    super.parse(trimExpression.getExpression().toParsedText());

    // The trim character is actually the string primary
    if (!hasStateObject() && hasTrimCharacter()) {
      setStateObject(new StringLiteralStateObject(this, trimCharacter.toString()));
      trimCharacter = null;
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void toTextEncapsulatedExpression(Appendable writer) throws IOException {

    // Specification
    if (specification != Specification.DEFAULT) {
      writer.append(specification.name());
      writer.append(SPACE);
    }

    // Trim character
    if (hasTrimCharacter()) {
      trimCharacter.toString(writer);
      writer.append(SPACE);
    }

    // FROM
    if ((specification != Specification.DEFAULT) || hasTrimCharacter()) {
      writer.append(FROM);
      writer.append(SPACE);
    }

    // String primary
    super.toTextEncapsulatedExpression(writer);
  }
 /** {@inheritDoc} */
 @Override
 public void setStateObject(StateObject stateObject) {
   super.setStateObject(stateObject);
 }
 /**
  * Keeps a reference of the {@link TrimExpression parsed object} object, which should only be done
  * when this object is instantiated during the conversion of a parsed JPQL query into {@link
  * StateObject StateObjects}.
  *
  * @param expression The {@link TrimExpression parsed object} representing a <code><b>TRIM</b>
  *     </code> expression
  */
 public void setExpression(TrimExpression expression) {
   super.setExpression(expression);
 }