openjava.ptree
Class MethodDeclaration

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
        |
        +--openjava.ptree.NonLeaf
              |
              +--openjava.ptree.MethodDeclaration
All Implemented Interfaces:
Cloneable, MemberDeclaration, ParseTree

public class MethodDeclaration
extends NonLeaf
implements MemberDeclaration

The MethodDeclaration class presents method declaration node of parse tree.

See Also:
ParseTree, NonLeaf, FieldDeclaration

Field Summary
private  Hashtable suffixes
           
 
Fields inherited from class openjava.ptree.NonLeaf
 
Fields inherited from class openjava.ptree.ParseTreeObject
debugFlag, debugLevel, LN, out, writerStack
 
Fields inherited from interface openjava.ptree.MemberDeclaration
CONSTRUCTOR, FIELD, METHOD, STATICINIT, STATICINITIALIZER, TYPE
 
Constructor Summary
(package private) MethodDeclaration()
          Is needed for recursive copy.
  MethodDeclaration(ModifierList modiflist, TypeName typespec, String name, ParameterList params, TypeName[] throwlist, StatementList block)
          Constructs new MethodDeclaration from its elements.
 
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.
 StatementList getBody()
          Gets body of this method.
 ModifierList getModifiers()
          Gets modifierlist of this method.
 String getName()
          Gets name of this method.
 ParameterList getParameters()
          Gets parameter list of this method.
 TypeName getReturnType()
          Gets type specifier of this method.
 Hashtable getSuffixes()
           
 TypeName[] getThrows()
          Gets throw type name list of this method.
 void setBody(StatementList stmts)
          Sets body of this method.
 void setModifiers(ModifierList modifs)
          Sets modifierlist of this method.
 void setName(String name)
          Sets name of this method.
 void setParameters(ParameterList params)
          Sets parameter list of this method.
 void setReturnType(TypeName tspec)
          Sets type specifier of this method.
 void setSuffixes(Hashtable suffixes)
           
 void setThrows(TypeName[] thrwlist)
          Sets throw type name list of this method.
 void writeCode()
          Writes the code this parse-tree presents for.
 
Methods inherited from class openjava.ptree.NonLeaf
childrenAccept, childrenAreEqual, elementAt, equals, 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.MemberDeclaration
eq, equals
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Field Detail

suffixes

private Hashtable suffixes
Constructor Detail

MethodDeclaration

public MethodDeclaration(ModifierList modiflist,
                         TypeName typespec,
                         String name,
                         ParameterList params,
                         TypeName[] throwlist,
                         StatementList block)
Constructs new MethodDeclaration from its elements.

Parameters:
modiflist - modifier list. If it has no modifier list then thes arg is set empty list.
typespec - returning type specifier
throwlist - throw type list. If there is no throws then this arg is set empty list
block - method block. if arg block is null, it means method body with only semi colon such as methods in interface

MethodDeclaration

MethodDeclaration()
Is needed for recursive copy.

Method Detail

writeCode

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

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

getModifiers

public ModifierList getModifiers()
Gets modifierlist of this method.

Returns:
modifier list. Even if there is no modifiers, getModifiers returns empty list

setModifiers

public void setModifiers(ModifierList modifs)
Sets modifierlist of this method.

Parameters:
modifs - modifier list to set

getReturnType

public TypeName getReturnType()
Gets type specifier of this method.

Returns:
type specifier node

setReturnType

public void setReturnType(TypeName tspec)
Sets type specifier of this method.

Parameters:
tspec - type specifier to set

getName

public String getName()
Gets name of this method.

Returns:
method declarator node

setName

public void setName(String name)
Sets name of this method.

Parameters:
name - method's name

getParameters

public ParameterList getParameters()
Gets parameter list of this method. Even if this method has no parameter, this returns an empty list of parameter.

Returns:
method's name

setParameters

public void setParameters(ParameterList params)
Sets parameter list of this method.

Parameters:
params - parameter list to set

getThrows

public TypeName[] getThrows()
Gets throw type name list of this method. Even if there is no throws, this returns an empty list.

Returns:
class type list

setThrows

public void setThrows(TypeName[] thrwlist)
Sets throw type name list of this method.


getBody

public StatementList getBody()
Gets body of this method. If the body is only semi colon such as the methods' body of interface, this returns null.

Returns:
statement list

setBody

public void setBody(StatementList stmts)
Sets body of this method.

Parameters:
stmts - statement list to set

setSuffixes

public void setSuffixes(Hashtable suffixes)

getSuffixes

public Hashtable getSuffixes()

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

SourceForge.net_Logo