openjava.ptree
Class FieldAccess

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
        |
        +--openjava.ptree.NonLeaf
              |
              +--openjava.ptree.FieldAccess
All Implemented Interfaces:
Cloneable, Expression, ParseTree, VariableInitializer
Direct Known Subclasses:
TableReference

public class FieldAccess
extends NonLeaf
implements Expression

The FieldAccess class represents a field access.

Here is an example:

     f().str
 

In this field access, you can get f() by getReferenceExpr() and can get str by getName() .
Warning: this class may have bugs around the expression.

See Also:
NonLeaf, Expression

Field Summary
 
Fields inherited from class openjava.ptree.NonLeaf
 
Fields inherited from class openjava.ptree.ParseTreeObject
debugFlag, debugLevel, LN, out, writerStack
 
Constructor Summary
(package private) FieldAccess()
           
  FieldAccess(Expression expr, String name)
          An access to the specified field of the given expression.
  FieldAccess(OJClass clazz, String name)
          An access to the specified static field of the type.
  FieldAccess(String name)
          An access to the specified field of self.
  FieldAccess(TypeName typename, String name)
          An access to the specified static field of the type.
 
Method Summary
 void accept(ParseTreeVisitor v)
          Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.
 boolean equals(ParseTree o)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
 String getName()
          Gets the field name.
 ParseTree getReference()
           
 Expression getReferenceExpr()
          Gets the expression accessed.
 TypeName getReferenceType()
           
 OJClass getType(Environment env)
           
 boolean isTypeReference()
           
private static OJField pickupField(OJClass reftype, String name)
           
 void setName(String name)
          Sets the field name.
 void setReferenceExpr(Expression expr)
          Sets the expression accessed.
 void setReferenceType(TypeName typename)
           
 void writeCode()
          Writes the code this parse-tree presents for.
 
Methods inherited from class openjava.ptree.NonLeaf
childrenAccept, childrenAreEqual, elementAt, getComment, getContents, getLength, getRowType, makeRecursiveCopy, replaceChildWith, set, set, set, set, set, set, set, set, set, setComment, setElementAt
 
Methods inherited from class openjava.ptree.ParseTreeObject
clone, eq, eq, equal, flushPrintWriter, getDebugFlag, getNest, getObjectID, getParent, getPrintWriter, getTab, hashCode, lastObjectID, makeCopy, popNest, popPrintWriter, pushNest, pushPrintWriter, replace, setDebugFlag, setDebugLevel, setNest, setParent, setPrintStream, setTab, toFlattenString, toString, writeDebug, writeDebugL, writeDebugLln, writeDebugln, writeDebugLR, writeDebugR, writeDebugRln, writeTab
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface openjava.ptree.Expression
getRowType
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, eq, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Constructor Detail

FieldAccess

public FieldAccess(Expression expr,
                   String name)
An access to the specified field of the given expression.


FieldAccess

public FieldAccess(TypeName typename,
                   String name)
An access to the specified static field of the type.


FieldAccess

public FieldAccess(OJClass clazz,
                   String name)
An access to the specified static field of the type.


FieldAccess

public FieldAccess(String name)
An access to the specified field of self.


FieldAccess

FieldAccess()
Method Detail

equals

public boolean equals(ParseTree o)
Description copied from interface: ParseTree
Tests if this parse-tree-node's value equals to the specified ptree-node's.

Specified by:
equals in interface ParseTree
Overrides:
equals in class NonLeaf
Returns:
true if two values are same.

writeCode

public void writeCode()
Description copied from class: NonLeaf
Writes the code this parse-tree presents for.

Specified by:
writeCode in interface ParseTree
Overrides:
writeCode in class NonLeaf

getReference

public ParseTree getReference()

isTypeReference

public boolean isTypeReference()

getReferenceExpr

public Expression getReferenceExpr()
Gets the expression accessed.

Returns:
the expression accessed.

setReferenceExpr

public void setReferenceExpr(Expression expr)
Sets the expression accessed.

Parameters:
expr - the expression accessed.

getReferenceType

public TypeName getReferenceType()

setReferenceType

public void setReferenceType(TypeName typename)

getName

public String getName()
Gets the field name.

Returns:
the field name.

setName

public void setName(String name)
Sets the field name.

Parameters:
name - the field name.

accept

public void accept(ParseTreeVisitor v)
            throws ParseTreeException
Description copied from interface: ParseTree
Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.

This invoke an appropriate visit() method on the accepted visitor.

Specified by:
accept in interface ParseTree
Specified by:
accept in class ParseTreeObject
Parameters:
v - a visitor
ParseTreeException

getType

public OJClass getType(Environment env)
                throws Exception
Specified by:
getType in interface Expression
Exception

pickupField

private static OJField pickupField(OJClass reftype,
                                   String name)

SourceForge.net_Logo