openjava.ptree
Class MethodCall

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
        |
        +--openjava.ptree.NonLeaf
              |
              +--openjava.ptree.MethodCall
All Implemented Interfaces:
Cloneable, Expression, ParseTree, VariableInitializer

public class MethodCall
extends NonLeaf
implements Expression

The MethodCall class represents a method call 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) MethodCall()
           
  MethodCall(Expression expr, String name, ExpressionList args)
          Allocates a new method call expression object.
  MethodCall(OJClass clazz, String name, ExpressionList args)
           
  MethodCall(String name, ExpressionList args)
          Allocates a new method call expression for 'this'.
  MethodCall(TypeName type, String name, ExpressionList args)
          Allocates a new method call expression object.
 
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 p)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
 ExpressionList getArguments()
          Gets the arguments for this method.
 String getName()
          Gets the method name.
 Expression getReferenceExpr()
          Gets the expression accessed.
 TypeName getReferenceType()
           
 OJClass getType(Environment env)
           
private static OJMethod pickupMethod(OJClass reftype, String name, OJClass[] argtypes)
           
 OJMethod resolve(Environment env)
          Returns the method that this call is to.
 void setArguments(ExpressionList exprs)
          Sets the arguments for this method.
 void setName(String name)
          Sets the method name.
 void setReferenceExpr(Expression expr)
          Sets the expression accessed.
 void setReferenceType(TypeName type)
           
 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

MethodCall

public MethodCall(Expression expr,
                  String name,
                  ExpressionList args)
Allocates a new method call expression object.

Parameters:
expr - the expression which indicates an object or a class. This may be null for invocation on 'this'.
name - the method name.
args - the argumetns for this method.

MethodCall

public MethodCall(String name,
                  ExpressionList args)
Allocates a new method call expression for 'this'. This is equivalent to:
     new MethodCall( (Expression) null, name, args )
 

Parameters:
name - the method name.
args - the argumetns for this method.

MethodCall

public MethodCall(TypeName type,
                  String name,
                  ExpressionList args)
Allocates a new method call expression object.

Parameters:
name - the method name.
args - the argumetns for this method.

MethodCall

public MethodCall(OJClass clazz,
                  String name,
                  ExpressionList args)

MethodCall

MethodCall()
Method Detail

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

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 type)

getName

public String getName()
Gets the method name.

Returns:
the method name.

setName

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

Parameters:
name - the method name.

getArguments

public ExpressionList getArguments()
Gets the arguments for this method.

Returns:
the expression list as the arguments.

setArguments

public void setArguments(ExpressionList exprs)
Sets the arguments for this method.

Parameters:
exprs - the expression list as the arguments.

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

resolve

public OJMethod resolve(Environment env)
                 throws Exception
Returns the method that this call is to.

Exception

pickupMethod

private static OJMethod pickupMethod(OJClass reftype,
                                     String name,
                                     OJClass[] argtypes)

equals

public boolean equals(ParseTree p)
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.

SourceForge.net_Logo