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

CompoundExpression

public abstract class CompoundExpression extends Expression
Abstract class for expression that have exactly two children, such as and/or and relations.

Fields Summary
protected ExpressionOperator
operator
protected transient ExpressionOperator
platformOperator
protected Expression
firstChild
protected Expression
secondChild
Constructors Summary
public CompoundExpression()

        super();
    
Methods Summary
public oracle.toplink.essentials.internal.helper.DatabaseTablealiasForTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: Find the alias for a given table from the first or second child in the additionalOuterJoinCriteria

        DatabaseTable alias = null;
        if (getFirstChild() != null) {
            alias = getFirstChild().aliasForTable(table);
        }

        if ((alias == null) && (getSecondChild() != null)) {
            alias = getSecondChild().aliasForTable(table);
        }

        return alias;
    
public oracle.toplink.essentials.expressions.Expressioncreate(oracle.toplink.essentials.expressions.Expression base, java.lang.Object singleArgument, oracle.toplink.essentials.expressions.ExpressionOperator operator)
INTERNAL:

        setFirstChild(base);
        Expression argument = Expression.from(singleArgument, base);
        setSecondChild(argument);
        setOperator(operator);
        return this;
    
public oracle.toplink.essentials.expressions.Expressioncreate(oracle.toplink.essentials.expressions.Expression base, java.util.Vector arguments, oracle.toplink.essentials.expressions.ExpressionOperator operator)
INTERNAL:

        setFirstChild(base);
        if (!arguments.isEmpty()) {
            setSecondChild((Expression)arguments.firstElement());
        }
        setOperator(operator);
        return this;
    
public java.lang.StringdescriptionOfNodeType()
INTERNAL: Used for debug printing.

        return "Compound Expression";
    
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)

        ExpressionBuilder builder = getFirstChild().getBuilder();
        if (builder == null) {
            return getSecondChild().getBuilder();
        } else {
            return builder;
        }
    
public oracle.toplink.essentials.expressions.ExpressiongetFirstChild()

        return firstChild;
    
public oracle.toplink.essentials.expressions.ExpressionOperatorgetOperator()

        return operator;
    
public oracle.toplink.essentials.expressions.ExpressionOperatorgetPlatformOperator(oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform platform)

        if (platformOperator == null) {
            initializePlatformOperator(platform);
        }
        return platformOperator;
    
public oracle.toplink.essentials.expressions.ExpressiongetSecondChild()

        return secondChild;
    
public voidinitializePlatformOperator(oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform platform)
INTERNAL:

        if (getOperator().isComplete()) {
            platformOperator = getOperator();
            return;
        }
        platformOperator = platform.getOperator(getOperator().getSelector());
        if (platformOperator == null) {
            throw QueryException.invalidOperator(getOperator().toString());
        }
    
public booleanisCompoundExpression()

        return true;
    
public voiditerateOn(oracle.toplink.essentials.internal.expressions.ExpressionIterator iterator)
INTERNAL: For iterating using an inner class

        super.iterateOn(iterator);
        if (getFirstChild() != null) {
            getFirstChild().iterateOn(iterator);
        }
        if (getSecondChild() != null) {
            getSecondChild().iterateOn(iterator);
        }
    
public oracle.toplink.essentials.expressions.Expressionnormalize(oracle.toplink.essentials.internal.expressions.ExpressionNormalizer normalizer)
INTERNAL: Normalize into a structure that is printable. Also compute printing information such as outer joins.

        validateNode();
        if (getFirstChild() != null) {
            //let's make sure a session is available in the case of a parallel expression
            ExpressionBuilder builder = getFirstChild().getBuilder();
            if (builder != null){
                builder.setSession(normalizer.getSession().getRootSession(null));
            }
            setFirstChild(getFirstChild().normalize(normalizer));
        }
        if (getSecondChild() != null) {
            //let's make sure a session is available in the case of a parallel expression
             ExpressionBuilder builder = getSecondChild().getBuilder();
             if (builder != null){
                 builder.setSession(normalizer.getSession().getRootSession(null));
             }
            setSecondChild(getSecondChild().normalize(normalizer));
        }

        // For CR2456, it is now possible for normalize to remove redundant
        // conditions from the where clause.
        if (getFirstChild() == null) {
            return getSecondChild();
        } else if (getSecondChild() == null) {
            return getFirstChild();
        }
        return this;
    
protected voidpostCopyIn(java.util.Dictionary alreadyDone)
INTERNAL: Used for cloning.

        super.postCopyIn(alreadyDone);
        if (getFirstChild() != null) {
            setFirstChild(getFirstChild().copiedVersionFrom(alreadyDone));
        }
        if (getSecondChild() != null) {
            setSecondChild(getSecondChild().copiedVersionFrom(alreadyDone));
        }
    
public voidprintJava(oracle.toplink.essentials.internal.expressions.ExpressionJavaPrinter printer)
INTERNAL: Print java for project class generation

        ExpressionOperator realOperator = getPlatformOperator(printer.getPlatform());
        realOperator.printJavaDuo(getFirstChild(), getSecondChild(), printer);
    
public voidprintSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)
INTERNAL: Print SQL

        ExpressionOperator realOperator = getPlatformOperator(printer.getPlatform());
        printer.printString("(");
        realOperator.printDuo(getFirstChild(), getSecondChild(), printer);
        printer.printString(")");
    
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

        Vector arguments;

        Expression first = getFirstChild().rebuildOn(newBase);
        if (getSecondChild() == null) {
            arguments = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(0);
        } else {
            arguments = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1);
            arguments.addElement(getSecondChild().rebuildOn(newBase));
        }
        return first.performOperator(getOperator(), arguments);
    
protected voidsetFirstChild(oracle.toplink.essentials.expressions.Expression firstChild)

        this.firstChild = firstChild;
    
public voidsetOperator(oracle.toplink.essentials.expressions.ExpressionOperator newOperator)

        operator = newOperator;
    
protected voidsetSecondChild(oracle.toplink.essentials.expressions.Expression secondChild)

        this.secondChild = secondChild;
    
public oracle.toplink.essentials.expressions.ExpressiontwistedForBaseAndContext(oracle.toplink.essentials.expressions.Expression newBase, oracle.toplink.essentials.expressions.Expression context)
INTRENAL: Used to change an expression off of one base to an expression off of a different base. i.e. expression on address to an expression on an employee's address.

        Vector arguments;

        if (getSecondChild() == null) {
            arguments = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(0);
        } else {
            arguments = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1);
            arguments.addElement(getSecondChild().twistedForBaseAndContext(newBase, context));
        }

        Expression first = getFirstChild().twistedForBaseAndContext(newBase, context);
        return first.performOperator(getOperator(), arguments);
    
public voidvalidateNode()
Do any required validation for this node. Throw an exception if it's incorrect. Ensure that both sides are not data expressions.

        if (getFirstChild() != null) {
            if (getFirstChild().isDataExpression() || getFirstChild().isConstantExpression()) {
                throw QueryException.invalidExpression(this);
            }
        }
        if (getSecondChild() != null) {
            if (getSecondChild().isDataExpression() || getSecondChild().isConstantExpression()) {
                throw QueryException.invalidExpression(this);
            }
        }
    
public voidwriteDescriptionOn(java.io.BufferedWriter writer)
INTERNAL: Used to print a debug form of the expression tree.

        writer.write(operator.toString());
    
public voidwriteSubexpressionsTo(java.io.BufferedWriter writer, int indent)
INTERNAL: Used for toString for debugging only.

        if (getFirstChild() != null) {
            getFirstChild().toString(writer, indent);
        }
        if (getSecondChild() != null) {
            getSecondChild().toString(writer, indent);
        }