FileDocCategorySizeDatePackage
TrimNode.javaAPI DocGlassfish v2 API4853Tue May 22 16:54:40 BST 2007oracle.toplink.essentials.internal.parsing

TrimNode

public class TrimNode extends StringFunctionNode
INTERNAL

Purpose: Represent a TRIM

Responsibilities:

  • Generate the correct expression for TRIM

Fields Summary
private Node
trimChar
private boolean
leading
private boolean
trailing
private boolean
both
Constructors Summary
public TrimNode()
TrimNode constructor.

        super();
    
Methods Summary
public oracle.toplink.essentials.expressions.ExpressiongenerateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)
INTERNAL Generate the TopLink expression for this node

        Expression whereClause = getLeft().generateExpression(context);
        if (leading) {
            // use leftTrim
            if (trimChar != null) {
                Expression trimCharExpr = trimChar.generateExpression(context);
                whereClause = whereClause.leftTrim(trimCharExpr);
            } else {
                whereClause = whereClause.leftTrim();
            }
        } else if (trailing) {
            if (trimChar != null) {
                Expression trimCharExpr = trimChar.generateExpression(context);
                whereClause = whereClause.rightTrim(trimCharExpr);
            } else {
                whereClause = whereClause.rightTrim();
            }
        } else {
            if (trimChar != null) {
                Expression trimCharExpr = trimChar.generateExpression(context);
                whereClause = whereClause.leftTrim(trimCharExpr).rightTrim(trimCharExpr);
            } else {
                whereClause = whereClause.leftTrim().rightTrim();
            }
        }
        return whereClause;
    
public booleanisBoth()

        return both;
    
public booleanisLeading()

        return leading;
    
public booleanisTrailing()

        return trailing;
    
public voidsetBoth(boolean newBoth)

        this.both = newBoth;
    
public voidsetLeading(boolean newLeading)

        this.leading = newLeading;
    
public voidsetTrailing(boolean newTrailing)

        this.trailing = newTrailing;
    
public voidsetTrimChar(oracle.toplink.essentials.internal.parsing.Node trimChar)

        this.trimChar = trimChar;
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculate its type.

        TypeHelper typeHelper = context.getTypeHelper();
        if (left != null) {
            left.validate(context);
            left.validateParameter(context, typeHelper.getStringType());
        }
        if (trimChar != null) {
            trimChar.validate(context);
            trimChar.validateParameter(context, typeHelper.getCharType());
        }
        setType(typeHelper.getStringType());