Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openjava.ptree
Class CastExpression  view CastExpression download CastExpression.java

java.lang.Object
  extended byopenjava.ptree.ParseTreeObject
      extended byopenjava.ptree.NonLeaf
          extended byopenjava.ptree.CastExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression, ParseTree, VariableInitializer

public class CastExpression
extends NonLeaf
implements Expression

The CastExpression class represents a cast expression of parse tree.
If the operator in the expression of the right operand has week unity, this automatically produces the code in which the right operand is enclosed by parenthesises.
In the case the caster is int and the right operand to be casted is p + q, this produces the code :

     (int) (p + q)
 


Field Summary
 
Fields inherited from class openjava.ptree.NonLeaf
 
Fields inherited from class openjava.ptree.ParseTreeObject
LN
 
Constructor Summary
(package private) CastExpression()
           
  CastExpression(openjava.mop.OJClass type, Expression expr)
           
  CastExpression(TypeName ts, Expression expr)
          Allocates a new object.
 
Method Summary
 void accept(openjava.ptree.util.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.
 Expression getExpression()
          Gets the expression of the operand to be casted in this expression.
 openjava.mop.OJClass getType(openjava.mop.Environment env)
           
 TypeName getTypeSpecifier()
          Gets the type specifier to cast in this expression.
 void setExpression(Expression expr)
          Sets the expression of the operand to be casted in this expression.
 void setTypeSpecifier(TypeName tspec)
          Sets the type specifier to cast in this expression.
 
Methods inherited from class openjava.ptree.NonLeaf
childrenAccept, elementAt, equals, getComment, getContents, getLength, makeRecursiveCopy, replaceChildWith, set, set, set, set, set, set, set, set, set, setComment, setElementAt
 
Methods inherited from class openjava.ptree.ParseTreeObject
clone, equal, getObjectID, getParent, hashCode, lastObjectID, makeCopy, replace, setParent, toFlattenString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, equals, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Constructor Detail

CastExpression

public CastExpression(TypeName ts,
                      Expression expr)
Allocates a new object.


CastExpression

public CastExpression(openjava.mop.OJClass type,
                      Expression expr)

CastExpression

CastExpression()
Method Detail

getTypeSpecifier

public TypeName getTypeSpecifier()
Gets the type specifier to cast in this expression.


setTypeSpecifier

public void setTypeSpecifier(TypeName tspec)
Sets the type specifier to cast in this expression.


getExpression

public Expression getExpression()
Gets the expression of the operand to be casted in this expression.


setExpression

public void setExpression(Expression expr)
Sets the expression of the operand to be casted in this expression.


accept

public void accept(openjava.ptree.util.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

getType

public openjava.mop.OJClass getType(openjava.mop.Environment env)
                             throws java.lang.Exception
Specified by:
getType in interface Expression