summaryrefslogtreecommitdiff
path: root/src/main/java/io/devnulllabs/openjava/ptree/ClassLiteral.java
blob: a10b536041bc381529fdcb03443318c44fce227e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * ClassLiteral.java 1.0
 *
 *
 * Jun 20, 1997
 * Oct 10, 1997
 *
 * @see io.devnulllabs.openjava.ptree.ParseTree
 * @version 1.0 last updated:  Sep 29, 1997
 * @author  Michiaki Tatsubori
 */
package io.devnulllabs.openjava.ptree;


import io.devnulllabs.openjava.mop.Environment;
import io.devnulllabs.openjava.mop.OJClass;
import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor;



/**
 * The <code>ClassLiteral</code> class represents
 * an expression as a object of <code>Class</code> class,
 * which is suppoted since JDK 1.1.
 * This is like :
 * <br><blockquote><pre>
 *     String.class
 * </pre></blockquote><br>
 * or :
 * <br><blockquote><pre>
 *     int.class
 * </pre></blockquote><br>
 *
 * @see java.lang.Class
 * @see io.devnulllabs.openjava.ptree.Leaf
 * @see io.devnulllabs.openjava.ptree.Expression
 * @see io.devnulllabs.openjava.ptree.TypeName
 */
public class ClassLiteral extends NonLeaf
    implements Expression
{

    /**
     * Allocates a new object.
     *
     */
    public ClassLiteral( TypeName type ) {
    super();
    set(type);
    }

    public ClassLiteral( OJClass type ) {
    this( TypeName.forOJClass( type ) );
    }

    /**
     * Gets the type name of this class literal.
     *
     * @return  the type name.
     */
    public TypeName getTypeName() {
    return (TypeName) elementAt(0);
    }

    /**
     * Sets the type name of this class literal.
     *
     * @param type  the type name.
     */
    public void setTypeName(TypeName type) {
    set(type);
    }

    public OJClass getType( Environment env )
    throws Exception
    {
    return OJClass.forClass( Class . class );
    }

    public void accept( ParseTreeVisitor v ) throws ParseTreeException {
        v.visit( this );
    }

}