org.apache.jdo.impl.jdoql.tree
Class FieldAccessExpr

java.lang.Object
  extended byantlr.BaseAST
      extended byantlr.CommonAST
          extended byorg.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
              extended byorg.apache.jdo.impl.jdoql.tree.NodeImpl
                  extended byorg.apache.jdo.impl.jdoql.tree.Expr
                      extended byorg.apache.jdo.impl.jdoql.tree.IdentifierExpr
                          extended byorg.apache.jdo.impl.jdoql.tree.FieldAccessExpr
All Implemented Interfaces:
antlr.collections.AST, java.lang.Cloneable, Expression, FieldAccessExpression, IdentifierExpression, Node, java.io.Serializable

public final class FieldAccessExpr
extends IdentifierExpr
implements FieldAccessExpression

This node represents a field access expression. Field access expressions have exactly one child, the target expression. This expression can be an arbitrary expression.

Author:
Michael Watzek
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
column, line, typeInfo
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
FieldAccessExpr()
          The noarg constructor is needed for ANTLR support and deserialization.
FieldAccessExpr(antlr.Token token)
          The noarg constructor is needed for ANTLR support.
 
Method Summary
 void arrive(NodeVisitor visitor)
          Delegates to the argument visitor.
 java.lang.Object getFieldValue(javax.jdo.PersistenceManager pm, java.lang.Object object)
          Returns the value of the field corresponding with this field access expression for the argument object.
 java.lang.String getName()
          Returns the name of the accessed field.
 Expression getTarget()
          Returns the target expression of this field access.
 java.lang.Object leave(NodeVisitor visitor, java.lang.Object[] results)
          Delegates to the argument visitor.
 void setName(java.lang.String fieldName)
          Sets the name of the accessed field.
 
Methods inherited from class org.apache.jdo.impl.jdoql.tree.IdentifierExpr
getTypeName
 
Methods inherited from class org.apache.jdo.impl.jdoql.tree.NodeImpl
clone, getChildren, getJavaClass, getObject, getParent, getTokenType, setObject, setParent, toString, walkNextChild
 
Methods inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
getColumn, getLine, getTypeInfo, initialize, initialize, initialize, setColumn, setLine, setTypeInfo, treeToString
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jdo.jdoql.tree.IdentifierExpression
getTypeName
 
Methods inherited from interface org.apache.jdo.jdoql.tree.Node
getChildren, getJavaClass, getObject, getParent, getTokenType, setObject, setParent, walkNextChild
 

Constructor Detail

FieldAccessExpr

public FieldAccessExpr()
The noarg constructor is needed for ANTLR support and deserialization. The caller must make sure to set the ANTLR tree structure himself or, call setChildren optionally.


FieldAccessExpr

public FieldAccessExpr(antlr.Token token)
The noarg constructor is needed for ANTLR support. The caller must make sure to set the ANTLR tree structure himself or, call setChildren optionally.

Method Detail

getName

public java.lang.String getName()
Returns the name of the accessed field. Please note, that this name does not contain any information about the target object of this field access.

Specified by:
getName in interface IdentifierExpression
Overrides:
getName in class IdentifierExpr
Returns:
the field name

setName

public void setName(java.lang.String fieldName)
Sets the name of the accessed field. Please note, that this name must not contain any information about the target object of this field access. This method is used by semantic analysis only.

Parameters:
fieldName - the field name

getTarget

public Expression getTarget()
Returns the target expression of this field access. The target expression can be an instance of ThisExpression or an instance of an arbitrary other Expression, e.g. FieldAccessExpression.

Specified by:
getTarget in interface FieldAccessExpression
Returns:
the target expression

getFieldValue

public java.lang.Object getFieldValue(javax.jdo.PersistenceManager pm,
                                      java.lang.Object object)
Returns the value of the field corresponding with this field access expression for the argument object. Note: If the field value is obtained via reflection and the reflection call throws an IllegalAccessException, then undefined is returned.

Specified by:
getFieldValue in interface FieldAccessExpression
Parameters:
pm - the persistence manager of the query
object - the instance for which to return the field value
Returns:
the field value for object
Throws:
JDOQueryException - if the access to the desired field is denied

arrive

public void arrive(NodeVisitor visitor)
Delegates to the argument visitor.

Specified by:
arrive in interface Node
Overrides:
arrive in class IdentifierExpr
Parameters:
visitor - the node visitor

leave

public java.lang.Object leave(NodeVisitor visitor,
                              java.lang.Object[] results)
Delegates to the argument visitor.

Specified by:
leave in interface Node
Overrides:
leave in class IdentifierExpr
Parameters:
visitor - the node visitor
results - the result array
Returns:
the object returned by the visitor instance


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.