openjava.ptree
Class AllocationExpression

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

public class AllocationExpression
extends NonLeaf
implements Expression

The AllocationExpression class represents an expression which allocates a new object with its constructor.
This expression is like:

     new String( "test" )
 

or:
     new String( "test" ){
             public void hoge(){ ... }
             ...
         }
 

The latter is supported from JDK 1.1, is called an anoymous class of the inner class.

See Also:
Expression, TypeName, ExpressionList, MemberDeclarationList

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) AllocationExpression()
           
  AllocationExpression(Expression encloser, TypeName typename, ExpressionList args)
          Allocates a new object with the class body.
  AllocationExpression(Expression encloser, TypeName typename, ExpressionList args, MemberDeclarationList mdlst)
          Allocates a new object with the class body.
  AllocationExpression(OJClass type, ExpressionList args)
           
  AllocationExpression(TypeName ctype, ExpressionList args)
          Allocates a new object without class body.
  AllocationExpression(TypeName typename, ExpressionList args, MemberDeclarationList mdlst)
          Allocates a new object with the class body.
 
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.
 ExpressionList getArguments()
          Gets the arguments of this constructor.
 MemberDeclarationList getClassBody()
          Gets the class body of this constructor.
 TypeName getClassType()
          Gets the class type of this constructor.
 Expression getEncloser()
          Gets the expression of enclosing object.
 OJClass getType(Environment env)
           
 void setArguments(ExpressionList args)
          Sets the arguments of this constructor.
 void setClassBody(MemberDeclarationList mdlist)
          Sets the class body of this constructor.
 void setClassType(TypeName ctype)
          Sets the class type of this constructor.
 void setEncloser(Expression encloser)
          Sets the expression of enclosing object.
 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.Expression
getRowType
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, eq, equals, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Constructor Detail

AllocationExpression

public AllocationExpression(Expression encloser,
                            TypeName typename,
                            ExpressionList args,
                            MemberDeclarationList mdlst)
Allocates a new object with the class body.

Parameters:
args - argument list of constructor
mdlst - the class body. If this is null, no class body will be provided this construct expression with.

AllocationExpression

public AllocationExpression(TypeName typename,
                            ExpressionList args,
                            MemberDeclarationList mdlst)
Allocates a new object with the class body.

Parameters:
args - argument list of constructor
mdlst - the class body. If this is null, no class body will be provided this construct expression with.

AllocationExpression

public AllocationExpression(Expression encloser,
                            TypeName typename,
                            ExpressionList args)
Allocates a new object with the class body.

Parameters:
args - argument list of constructor

AllocationExpression

public AllocationExpression(TypeName ctype,
                            ExpressionList args)
Allocates a new object without class body.

Parameters:
ctype - a class name to be constructed
args - argument list of constructor

AllocationExpression

public AllocationExpression(OJClass type,
                            ExpressionList args)

AllocationExpression

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

getEncloser

public Expression getEncloser()
Gets the expression of enclosing object.

Returns:
the expression of enclosing object

setEncloser

public void setEncloser(Expression encloser)
Sets the expression of enclosing object.

Parameters:
encloser - the expression of enclosing object

getClassType

public TypeName getClassType()
Gets the class type of this constructor.

Returns:
the class type of this constructor.

setClassType

public void setClassType(TypeName ctype)
Sets the class type of this constructor.

Parameters:
ctype - the class body to set.

getArguments

public ExpressionList getArguments()
Gets the arguments of this constructor.

Returns:
the arguments as an expressions list.

setArguments

public void setArguments(ExpressionList args)
Sets the arguments of this constructor.

Returns:
the expressions list of arguments.

getClassBody

public MemberDeclarationList getClassBody()
Gets the class body of this constructor.

Returns:
the member declaration list as the class body of this constructor.

setClassBody

public void setClassBody(MemberDeclarationList mdlist)
Sets the class body of this constructor.

Parameters:
mdlist - the member declaration list of the class body. If this is null, the class body will disappear.

getType

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

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