FileDocCategorySizeDatePackage
AttributeNode.javaAPI DocGlassfish v2 API7531Tue May 22 16:54:36 BST 2007oracle.toplink.essentials.internal.parsing

AttributeNode

public class AttributeNode extends Node
INTERNAL

Purpose: Represent a attribute.

Responsibilities:

Fields Summary
private String
name
The attribute name.
private boolean
outerJoin
Flag indicating outer join
private boolean
requiresCollectionAttribute
private DatabaseMapping
mapping
Constructors Summary
public AttributeNode()
Create a new AttributeNode

        super();
    
public AttributeNode(String name)
Create a new AttributeNode with the passed name

param
name the attribute name

        setAttributeName(name);
    
Methods Summary
public oracle.toplink.essentials.expressions.ExpressionaddToExpression(oracle.toplink.essentials.expressions.Expression parentExpression, oracle.toplink.essentials.internal.parsing.GenerationContext context)

        if (isCollectionAttribute()) {
            //special case for NOT MEMBER OF
            if (context.hasMemberOfNode()) {
                return parentExpression.noneOf(name, new ExpressionBuilder().equal(context.getMemberOfNode().getLeftExpression()));
            }
            return outerJoin ? parentExpression.anyOfAllowingNone(name) : 
                parentExpression.anyOf(name);
        } else {
            // check whether collection attribute is required
            if (requiresCollectionAttribute()) {
                throw EJBQLException.invalidCollectionMemberDecl(
                    context.getParseTreeContext().getQueryInfo(), 
                    getLine(), getColumn(), name);
            }

            if (context.shouldUseOuterJoins() || isOuterJoin()) {
                return parentExpression.getAllowingNull(name);
            } else {
                return parentExpression.get(name);
            }
        }
    
public java.lang.StringgetAsString()
INTERNAL Get the string representation of this node.

        return getAttributeName();
    
public java.lang.StringgetAttributeName()

        return name;
    
public oracle.toplink.essentials.mappings.DatabaseMappinggetMapping()

        return mapping;
    
public booleanisAttributeNode()
INTERNAL Is this node an AttributeNode

        return true;
    
public booleanisCollectionAttribute()

        DatabaseMapping mapping = getMapping();
        return (mapping != null) && mapping.isCollectionMapping();
    
public booleanisOuterJoin()

        return outerJoin;
    
public oracle.toplink.essentials.internal.parsing.NodequalifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL If called this AttributeNode represents an unqualified field access. The method returns a DotNode representing a qualified field access with the base variable as left child node and the attribute as right child node.

        return (Node)context.getNodeFactory().newQualifiedAttribute(
            getLine(), getColumn(), context.getBaseVariable(), name); 
    
public booleanrequiresCollectionAttribute()

        return requiresCollectionAttribute;
    
public java.lang.ClassresolveClass(oracle.toplink.essentials.internal.parsing.GenerationContext context, java.lang.Class ownerClass)
resolveClass: Answer the class for the mapping associated with the my variableName in the ownerClass. Answer null if the node represents a mapping that doesn't exist

        DatabaseMapping mapping;

        mapping = resolveMapping(context, ownerClass);

        // if we are working with a direct-to-field, or the mapping's null,
        // return the owner class
        // Returning the ownerClass when the mapping is null delegates error handling
        // to the query rather than me
        if ((mapping == null) || (mapping.isDirectToFieldMapping())) {
            return ownerClass;
        }

        ClassDescriptor descriptor = mapping.getReferenceDescriptor();
        return (descriptor==null) ? null : descriptor.getJavaClass();
        //return mapping.getReferenceDescriptor().getJavaClass();
    
public oracle.toplink.essentials.mappings.DatabaseMappingresolveMapping(oracle.toplink.essentials.internal.parsing.GenerationContext context, java.lang.Class ownerClass)
resolveMapping: Answer the mapping which corresponds to my variableName.

        ClassDescriptor descriptor = context.getSession().getDescriptor(ownerClass);
        return (descriptor==null) ? null : descriptor.getMappingForAttributeName(getAttributeName());
    
public voidsetAttributeName(java.lang.String name)

        this.name = name;
    
public voidsetMapping(oracle.toplink.essentials.mappings.DatabaseMapping mapping)

        this.mapping = mapping;
    
public voidsetOuterJoin(boolean outerJoin)

        this.outerJoin = outerJoin;
    
public voidsetRequiresCollectionAttribute(boolean requiresCollectionAttribute)

        this.requiresCollectionAttribute = requiresCollectionAttribute;
    
public java.lang.StringtoString(int indent)

        StringBuffer buffer = new StringBuffer();
        toStringIndent(indent, buffer);
        buffer.append(toStringDisplayName() + "[" + getAttributeName() + "]");
        return buffer.toString();
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate the current node and calculates its type.

        // The type is calculated in the parent DotNode.