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

DataExpression

public abstract class DataExpression extends Expression
Superclass for all expression that have a context. i.e. a base expression.

Fields Summary
protected Vector
derivedTables
protected Vector
derivedFields
protected Expression
baseExpression
protected boolean
hasBeenNormalized
protected TableAliasLookup
tableAliases
Constructors Summary
public DataExpression()
DataExpression constructor comment.


            
      
        super();
    
Methods Summary
public voidaddDerivedField(oracle.toplink.essentials.expressions.Expression addThis)

        if (derivedFields == null) {
            derivedFields = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(4);
        }
        derivedFields.addElement(addThis);
    
public voidaddDerivedTable(oracle.toplink.essentials.expressions.Expression addThis)

        if (derivedTables == null) {
            derivedTables = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(4);
        }
        derivedTables.addElement(addThis);
    
public oracle.toplink.essentials.internal.helper.DatabaseTablealiasForTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: Find the alias for a given table

        if (tableAliases == null) {
            if (getBaseExpression() == null) {
                return null;
            }
            return getBaseExpression().aliasForTable(table);
        }

        return tableAliases.keyAtValue(table);
    
protected voidassignAlias(java.lang.String name, oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: Alias a particular table within this node

        assignAlias(new DatabaseTable(name), table);
    
protected voidassignAlias(oracle.toplink.essentials.internal.helper.DatabaseTable alias, oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL: Alias a particular table within this node

        if (tableAliases == null) {
            tableAliases = new TableAliasLookup();
        }
        tableAliases.put(alias, table);
    
public voidclearAliases()
INTERNAL:

        tableAliases = null;
    
public java.util.VectorcopyCollection(java.util.Vector in, java.util.Dictionary alreadyDone)

        if (in == null) {
            return null;
        }
        Vector result = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(in.size());
        for (Enumeration e = in.elements(); e.hasMoreElements();) {
            Expression exp = (Expression)e.nextElement();
            result.addElement(exp.copiedVersionFrom(alreadyDone));
        }
        return result;
    
public oracle.toplink.essentials.expressions.ExpressionexistingDerivedField(oracle.toplink.essentials.internal.helper.DatabaseField field)
INTERNAL:

        if (derivedFields == null) {
            return null;
        }
        for (Enumeration e = derivedFields.elements(); e.hasMoreElements();) {
            FieldExpression exp = (FieldExpression)e.nextElement();
            if (exp.getField().equals(field)) {
                return exp;
            }
        }
        return null;

    
public oracle.toplink.essentials.expressions.ExpressionexistingDerivedTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL:

        if (derivedTables == null) {
            return null;
        }
        for (Enumeration e = derivedTables.elements(); e.hasMoreElements();) {
            TableExpression exp = (TableExpression)e.nextElement();
            if (exp.getTable().equals(table)) {
                return exp;
            }
        }
        return null;

    
public oracle.toplink.essentials.internal.helper.DatabaseFieldgetAliasedField()
INTERNAL: Return the field appropriately aliased

        return null;

    
public oracle.toplink.essentials.expressions.ExpressiongetBaseExpression()

        return baseExpression;
    
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)

        if (getBaseExpression() == null) {
            return null;
        }
        return getBaseExpression().getBuilder();
    
public oracle.toplink.essentials.descriptors.ClassDescriptorgetDescriptor()

        return null;

    
public oracle.toplink.essentials.internal.helper.DatabaseFieldgetField()
INTERNAL:

        return null;
    
public oracle.toplink.essentials.expressions.ExpressiongetField(java.lang.String fieldName)

        DatabaseField field = new DatabaseField(fieldName);
        return getField(field);

    
public oracle.toplink.essentials.expressions.ExpressiongetField(oracle.toplink.essentials.internal.helper.DatabaseField field)

        Expression existing = existingDerivedField(field);
        if (existing != null) {
            return existing;
        }
        return newDerivedField(field);

    
public oracle.toplink.essentials.mappings.DatabaseMappinggetMapping()

        if (getBaseExpression() == null) {
            return null;
        }
        ClassDescriptor aDescriptor = ((DataExpression)getBaseExpression()).getDescriptor();
        if (aDescriptor == null) {
            return null;
        }
        return aDescriptor.getObjectBuilder().getMappingForAttributeName(getName());
    
public java.util.VectorgetOwnedTables()
INTERNAL:

        if (getDescriptor() == null) {
            return null;
        } else {
            if (getDescriptor().isAggregateDescriptor()) {
                return null;
            } else {
                return getDescriptor().getTables();
            }
        }
    
public oracle.toplink.essentials.querykeys.QueryKeygetQueryKeyOrNull()

        return null;

    
public oracle.toplink.essentials.expressions.ExpressiongetTable(java.lang.String tableName)

        DatabaseTable table = new DatabaseTable(tableName);
        return getTable(table);
    
public oracle.toplink.essentials.expressions.ExpressiongetTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)

        Expression existing = existingDerivedTable(table);
        if (existing != null) {
            return existing;
        }
        return newDerivedTable(table);

    
public oracle.toplink.essentials.internal.expressions.TableAliasLookupgetTableAliases()
INTERNAL: Return the aliases used. For CR#2456 must never lazily initialize as also used for Expression identity.

        return tableAliases;

    
public booleanhasBeenAliased()

        return ((tableAliases != null) && (tableAliases.size() != 0));

    
public booleanhasBeenNormalized()
INTERNAL: Did the normalizer already add additional joins to the where clause due to this query key representing a foreign reference mapping? This insures that join criteria (for any query key expression) is not added twice.

New meaning: DataExpressions are often iterated on multiple times during normalize, but Function/Relation expressions only once. Adding a has been normalized flag improves performance and is required in some applications, such as have temporal query criteria been added.

        return hasBeenNormalized;
    
protected booleanhasDerivedFields()

        return derivedFields != null;
    
protected booleanhasDerivedTables()

        return derivedTables != null;
    
public booleanisAttribute()
INTERNAL:

        return false;
    
public booleanisDataExpression()

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

        super.iterateOn(iterator);
        if (baseExpression != null) {
            baseExpression.iterateOn(iterator);
        }
    
public oracle.toplink.essentials.expressions.ExpressionmappingCriteria()

        return null;
    
public oracle.toplink.essentials.expressions.ExpressionnewDerivedField(oracle.toplink.essentials.internal.helper.DatabaseField field)
INTERNAL:

        FieldExpression result = new FieldExpression(field, this);
        addDerivedField(result);
        return result;

    
public oracle.toplink.essentials.expressions.ExpressionnewDerivedTable(oracle.toplink.essentials.internal.helper.DatabaseTable table)
INTERNAL:

        TableExpression result = new TableExpression(table);
        result.setBaseExpression(this);
        addDerivedTable(result);
        return result;

    
public oracle.toplink.essentials.expressions.Expressionnormalize(oracle.toplink.essentials.internal.expressions.ExpressionNormalizer normalizer)
INTERNAL: Normalize the expression into a printable structure. Any joins must be added to form a new root.

        if (getBaseExpression() != null) {
            // First normalize the base.
            setBaseExpression(getBaseExpression().normalize(normalizer));
        }

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

        super.postCopyIn(alreadyDone);
        clearAliases();
        if (baseExpression != null) {
            baseExpression = baseExpression.copiedVersionFrom(alreadyDone);
        }
        derivedFields = copyCollection(derivedFields, alreadyDone);
        derivedTables = copyCollection(derivedTables, alreadyDone);
    
public voidprintSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)
INTERNAL: Print SQL onto the stream, using the ExpressionPrinter for context

        printer.printField(getAliasedField());
    
protected voidsetBaseExpression(oracle.toplink.essentials.expressions.Expression e)

        baseExpression = e;
    
public voidsetHasBeenNormalized(boolean value)

        hasBeenNormalized = value;
    
public voidsetTableAliases(oracle.toplink.essentials.internal.expressions.TableAliasLookup tableAliases)
INTERNAL: For CR#2456, Table identity involves having two tables sharing the same aliasing table.

        if (this.tableAliases == null) {
            this.tableAliases = tableAliases;
        }
    
public java.lang.StringtableAliasesDescription()

        if (tableAliases == null) {
            return "";
        }
        return tableAliases.toString();
    
public voidwriteSubexpressionsTo(java.io.BufferedWriter writer, int indent)
Print the base for debuggin purposes.

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