openjava.ptree
Class VariableDeclaration

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

public class VariableDeclaration
extends NonLeaf
implements Statement

The VariableDeclaration class presents local variable declaration statement node of parse tree.

See Also:
ParseTree, NonLeaf, Statement, ModifierList, TypeName, VariableDeclarator, VariableInitializer

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) VariableDeclaration()
           
  VariableDeclaration(ModifierList modifs, TypeName typespec, String vname, VariableInitializer vinit)
          Allocates a new object.
  VariableDeclaration(ModifierList modifs, TypeName typespec, VariableDeclarator vdeclr)
          Allocates a new object.
  VariableDeclaration(TypeName typespec, String vname, VariableInitializer vinit)
          Allocates a new object.
  VariableDeclaration(TypeName typespec, VariableDeclarator vdeclr)
          Allocates a new 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.
 VariableInitializer getInitializer()
          Gets variable initializer.
 ModifierList getModifiers()
          Gets the modifer list of this variable declaration.
 TypeName getTypeSpecifier()
          Gets the type specifier of this variable declaration.
 String getVariable()
          Gets declarator name, declarator name includes variable name but its dimension.
 VariableDeclarator getVariableDeclarator()
          Gets the variable declarator of this variable declaration.
 void setInitializer(VariableInitializer vinit)
          Sets variable initializer.
 void setModifiers(ModifierList modifs)
          Sets the modifer list of this variable declaration.
 void setTypeSpecifier(TypeName tspec)
          Sets the type specifier of this variable declaration.
 void setVariable(String name)
          Sets declarator name, declarator name includes variable name but its dimension.
 void setVariableDeclarator(VariableDeclarator vdeclr)
          Sets the variable declarator of this variable declaration.
 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.ParseTree
childrenAccept, eq, equals, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Constructor Detail

VariableDeclaration

public VariableDeclaration(ModifierList modifs,
                           TypeName typespec,
                           VariableDeclarator vdeclr)
Allocates a new object.

Parameters:
modifs - the modifier list of this variable declaration.
typespec - the type specifier.
vdeclr - the variable declarator.

VariableDeclaration

public VariableDeclaration(TypeName typespec,
                           VariableDeclarator vdeclr)
Allocates a new object.

Parameters:
typespec - the type specifier.
vdeclr - the variable declarator.

VariableDeclaration

public VariableDeclaration(ModifierList modifs,
                           TypeName typespec,
                           String vname,
                           VariableInitializer vinit)
Allocates a new object.

Parameters:
modifs - the modifier list of this variable declaration.
typespec - the type specifier.
vname - the variable name.
vinit - the variable initializer.

VariableDeclaration

public VariableDeclaration(TypeName typespec,
                           String vname,
                           VariableInitializer vinit)
Allocates a new object.

Parameters:
typespec - the type specifier.
vname - the variable name.
vinit - the variable initializer.

VariableDeclaration

VariableDeclaration()
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

getModifiers

public ModifierList getModifiers()
Gets the modifer list of this variable declaration.

Returns:
the modifier list.

setModifiers

public void setModifiers(ModifierList modifs)
Sets the modifer list of this variable declaration.

Parameters:
modifs - the modifier list to set.

getTypeSpecifier

public TypeName getTypeSpecifier()
Gets the type specifier of this variable declaration. Any modification on obtained objects is never reflected on this object.

Returns:
the type specifier for this variable.

setTypeSpecifier

public void setTypeSpecifier(TypeName tspec)
Sets the type specifier of this variable declaration.

Parameters:
tspec - the type specifier to set.

getVariableDeclarator

public VariableDeclarator getVariableDeclarator()
Gets the variable declarator of this variable declaration.

Returns:
the variable declarator.

setVariableDeclarator

public void setVariableDeclarator(VariableDeclarator vdeclr)
Sets the variable declarator of this variable declaration.

Parameters:
vdeclr - the variable declarator to set.

getVariable

public String getVariable()
Gets declarator name, declarator name includes variable name but its dimension.

Returns:
declarator name

setVariable

public void setVariable(String name)
Sets declarator name, declarator name includes variable name but its dimension.

Parameters:
name - declarator name to set.
See Also:
TypeName

getInitializer

public VariableInitializer getInitializer()
Gets variable initializer.

Returns:
variable initializer.

setInitializer

public void setInitializer(VariableInitializer vinit)
Sets variable initializer.

Parameters:
vinit - the variable initializer to set.

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