openjava.ptree
Class ArrayAllocationExpression

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

public class ArrayAllocationExpression
extends NonLeaf
implements Expression

The ArrayAllocationExpression class represents an expression which allocates a new array object.
This expression is like:

     new Object[2][3]
 

or:
     new String[]{ "this", "is", "a", "test" }
 

The latter is supported from JDK 1.1.

See Also:
Expression, TypeName, ExpressionList, ArrayInitializer

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) ArrayAllocationExpression()
           
  ArrayAllocationExpression(OJClass type, ExpressionList args)
           
  ArrayAllocationExpression(OJClass type, ExpressionList args, ArrayInitializer ainit)
           
  ArrayAllocationExpression(TypeName typename, ExpressionList dimlist)
          Allocates a new ptree object.
  ArrayAllocationExpression(TypeName typename, ExpressionList dimlist, ArrayInitializer ainit)
          Allocates a new ptree 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.
 ExpressionList getDimExprList()
          Gets the dimexpr list of the array.
 ArrayInitializer getInitializer()
          Gets the initializer of this array allocation.
 OJClass getType(Environment env)
           
 TypeName getTypeName()
          Gets the type name of the array.
 void setDimExprList(ExpressionList dimlist)
          Sets the dimexpr list of the array.
 void setInitializer(ArrayInitializer ainit)
          Sets the initializer of this array allocation.
 void setTypeName(TypeName typename)
          Sets the type name of the array.
 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

ArrayAllocationExpression

public ArrayAllocationExpression(TypeName typename,
                                 ExpressionList dimlist)
Allocates a new ptree object.

Parameters:
typename - the type name.
dimlist - the dimension expression list.

ArrayAllocationExpression

public ArrayAllocationExpression(TypeName typename,
                                 ExpressionList dimlist,
                                 ArrayInitializer ainit)
Allocates a new ptree object.

Parameters:
typename - the type name.
dimlist - the dimension expression list.
ainit - the array initializer. If this is null, no initializer will be provided this allocation with.

ArrayAllocationExpression

public ArrayAllocationExpression(OJClass type,
                                 ExpressionList args)

ArrayAllocationExpression

public ArrayAllocationExpression(OJClass type,
                                 ExpressionList args,
                                 ArrayInitializer ainit)

ArrayAllocationExpression

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

getTypeName

public TypeName getTypeName()
Gets the type name of the array.

Returns:
the type name of the array.

setTypeName

public void setTypeName(TypeName typename)
Sets the type name of the array.

Parameters:
typename - the type name of the array.

getDimExprList

public ExpressionList getDimExprList()
Gets the dimexpr list of the array.

Returns:
the dimexpr list of the array.

setDimExprList

public void setDimExprList(ExpressionList dimlist)
Sets the dimexpr list of the array.

Parameters:
dimlist - the dimexpr list of the array.

getInitializer

public ArrayInitializer getInitializer()
Gets the initializer of this array allocation.

Returns:
the initializer.

setInitializer

public void setInitializer(ArrayInitializer ainit)
Sets the initializer of this array allocation.

Parameters:
ainit - the initializer. If this is null, no initializer will be set.

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