FileDocCategorySizeDatePackage
ConstantExpression.javaAPI DocGlassfish v2 API6628Tue May 22 16:54:32 BST 2007oracle.toplink.essentials.internal.expressions

ConstantExpression

public class ConstantExpression extends Expression
Used for wrapping constant values.

Fields Summary
protected Object
value
protected Expression
localBase
Constructors Summary
public ConstantExpression()

        super();
    
public ConstantExpression(Object newValue, Expression baseExpression)

        super();
        value = newValue;
        localBase = baseExpression;
    
Methods Summary
public java.lang.StringdescriptionOfNodeType()
INTERNAL: Used for debug printing.

        return "Constant";
    
public oracle.toplink.essentials.expressions.ExpressionBuildergetBuilder()
Return the expression builder which is the ultimate base of this expression, or null if there isn't one (shouldn't happen if we start from a root)

        return getLocalBase().getBuilder();
    
protected oracle.toplink.essentials.expressions.ExpressiongetLocalBase()

        return localBase;
    
public java.lang.ObjectgetValue()

        return value;
    
public booleanisConstantExpression()

        return true;
    
public booleanisValueExpression()
INTERNAL:

        return true;
    
protected voidpostCopyIn(java.util.Dictionary alreadyDone)
INTERNAL: Used for cloning.

        super.postCopyIn(alreadyDone);
        localBase = localBase.copiedVersionFrom(alreadyDone);
    
public voidprintJava(oracle.toplink.essentials.internal.expressions.ExpressionJavaPrinter printer)
INTERNAL: Print java for project class generation

        printer.printJava(getValue());
    
public voidprintSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)
INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context

        Object value = getLocalBase().getFieldValue(getValue());
        if(value == null) {
            printer.printNull(this);
        } else {
            printer.printPrimitive(value);
        }
    
public voidprintSQLWithoutConversion(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)
INTERNAL: Print SQL, this is called from functions, so must not be converted through the mapping.

        printer.printPrimitive(getValue());
    
public oracle.toplink.essentials.expressions.ExpressionrebuildOn(oracle.toplink.essentials.expressions.Expression newBase)
INTERNAL: This expression is built on a different base than the one we want. Rebuild it and return the root of the new tree

        Expression result = (ConstantExpression)clone();
        result.setLocalBase(getLocalBase().rebuildOn(newBase));
        return result;
    
public voidsetLocalBase(oracle.toplink.essentials.expressions.Expression e)

        localBase = e;
    
public oracle.toplink.essentials.expressions.ExpressiontwistedForBaseAndContext(oracle.toplink.essentials.expressions.Expression newBase, oracle.toplink.essentials.expressions.Expression context)
INTERNAL: Rebuild myself against the base, with the values of parameters supplied by the context expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping) into part of some larger expression. You normally would not call this directly, instead calling twist See the comment there for more details"

        return (Expression)this.clone();
    
public java.lang.ObjectvalueFromObject(java.lang.Object object, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean isObjectUnregistered)
INTERNAL: Return the value for in memory comparison. This is only valid for valueable expressions.

        return getLocalBase().getFieldValue(getValue());
    
public voidwriteDescriptionOn(java.io.BufferedWriter writer)
INTERNAL: Used to print a debug form of the expression tree.

        writer.write(String.valueOf(getValue()));
    
public voidwriteFields(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer, java.util.Vector newFields, oracle.toplink.essentials.internal.expressions.SQLSelectStatement statement)
INTERNAL: Append the constant value into the printer

        //print ", " before each selected field except the first one
        if (printer.isFirstElementPrinted()) {
            printer.printString(", ");
        } else {
            printer.setIsFirstElementPrinted(true);
        }

        // This field is a constant value, so any name can be used.
        newFields.addElement(new DatabaseField("*"));
        printSQL(printer);