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

Quick Search    Search Deep

Source code: openjava/ptree/ClassLiteral.java


1   /*
2    * ClassLiteral.java 1.0
3    *
4    *
5    * Jun 20, 1997
6    * Oct 10, 1997
7    *
8    * @see openjava.ptree.ParseTree
9    * @version 1.0 last updated:  Sep 29, 1997
10   * @author  Michiaki Tatsubori
11   */
12  package openjava.ptree;
13  
14  
15  import openjava.mop.Environment;
16  import openjava.mop.OJClass;
17  import openjava.ptree.util.ParseTreeVisitor;
18  
19  
20  
21  /**
22   * The <code>ClassLiteral</code> class represents
23   * an expression as a object of <code>Class</code> class,
24   * which is suppoted since JDK 1.1.
25   * This is like :
26   * <br><blockquote><pre>
27   *     String.class
28   * </pre></blockquote><br>
29   * or :
30   * <br><blockquote><pre>
31   *     int.class
32   * </pre></blockquote><br>
33   * 
34   * @see java.lang.Class
35   * @see openjava.ptree.Leaf
36   * @see openjava.ptree.Expression
37   * @see openjava.ptree.TypeName
38   */
39  public class ClassLiteral extends NonLeaf
40      implements Expression
41  {
42  
43      /**
44       * Allocates a new object.
45       *
46       */
47      public ClassLiteral( TypeName type ) {
48    super();
49    set(type);
50      }
51  
52      public ClassLiteral( OJClass type ) {
53    this( TypeName.forOJClass( type ) );
54      }
55  
56      /**
57       * Gets the type name of this class literal.
58       *
59       * @return  the type name.
60       */
61      public TypeName getTypeName() {
62    return (TypeName) elementAt(0);
63      }
64  
65      /**
66       * Sets the type name of this class literal.
67       *
68       * @param type  the type name.
69       */
70      public void setTypeName(TypeName type) {
71    set(type);
72      }
73  
74      public OJClass getType( Environment env )
75    throws Exception
76      {
77    return OJClass.forClass( Class . class );
78      }
79  
80      public void accept( ParseTreeVisitor v ) throws ParseTreeException {
81          v.visit( this );
82      }
83  
84  }