KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mirror > type > MirroredTypeException


1 /*
2  * @(#)MirroredTypeException.java 1.1 04/04/20
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.mirror.type;
9
10
11 import java.lang.annotation.Annotation JavaDoc;
12
13 import com.sun.mirror.declaration.Declaration;
14
15
16 /**
17  * Thrown when an application attempts to access the {@link Class} object
18  * corresponding to a {@link TypeMirror}.
19  *
20  * @see MirroredTypesException
21  * @see Declaration#getAnnotation(Class)
22  */

23 public class MirroredTypeException extends RuntimeException JavaDoc {
24
25     private static final long serialVersionUID = 1;
26
27     private transient TypeMirror type; // cannot be serialized
28
private String JavaDoc name; // type's qualified "name"
29

30     /**
31      * Constructs a new MirroredTypeException for the specified type.
32      *
33      * @param type the type being accessed
34      */

35     public MirroredTypeException(TypeMirror type) {
36     super("Attempt to access Class object for TypeMirror " + type);
37     this.type = type;
38     name = type.toString();
39     }
40
41     /**
42      * Returns the type mirror corresponding to the type being accessed.
43      * The type mirror may be unavailable if this exception has been
44      * serialized and then read back in.
45      *
46      * @return the type mirror, or <tt>null</tt> if unavailable
47      */

48     public TypeMirror getTypeMirror() {
49     return type;
50     }
51
52     /**
53      * Returns the fully qualified name of the type being accessed.
54      * More precisely, returns the canonical name of a class,
55      * interface, array, or primitive, and returns <tt>"void"</tt> for
56      * the pseudo-type representing the type of <tt>void</tt>.
57      *
58      * @return the fully qualified name of the type being accessed
59      */

60     public String JavaDoc getQualifiedName() {
61     return name;
62     }
63 }
64
Popular Tags