KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > annotation > AnnotationTypeMismatchException


1 /*
2  * @(#)AnnotationTypeMismatchException.java 1.5 05/01/04
3  *
4  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.annotation;
9 import java.lang.reflect.Method JavaDoc;
10
11 /**
12  * Thrown to indicate that a program has attempted to access an element of
13  * an annotation whose type has changed after the annotation was compiled
14  * (or serialized).
15  *
16  * @author Josh Bloch
17  * @since 1.5
18  */

19 public class AnnotationTypeMismatchException extends RuntimeException JavaDoc {
20     /**
21      * The <tt>Method</tt> object for the annotation element.
22      */

23     private final Method JavaDoc element;
24
25     /**
26      * The (erroneous) type of data found in the annotation. This string
27      * may, but is not required to, contain the value as well. The exact
28      * format of the string is unspecified.
29      */

30     private final String JavaDoc foundType;
31
32     /**
33      * Constructs an AnnotationTypeMismatchException for the specified
34      * annotation type element and found data type.
35      *
36      * @param element the <tt>Method</tt> object for the annotation element
37      * @param foundType the (erroneous) type of data found in the annotation.
38      * This string may, but is not required to, contain the value
39      * as well. The exact format of the string is unspecified.
40      */

41     public AnnotationTypeMismatchException(Method JavaDoc element, String JavaDoc foundType) {
42         super("Incorrectly typed data found for annotation element " + element
43               + " (Found data of type " + foundType + ")");
44         this.element = element;
45         this.foundType = foundType;
46     }
47
48     /**
49      * Returns the <tt>Method</tt> object for the incorrectly typed element.
50      *
51      * @return the <tt>Method</tt> object for the incorrectly typed element
52      */

53     public Method JavaDoc element() {
54         return this.element;
55     }
56
57     /**
58      * Returns the type of data found in the incorrectly typed element.
59      * The returned string may, but is not required to, contain the value
60      * as well. The exact format of the string is unspecified.
61      *
62      * @return the type of data found in the incorrectly typed element
63      */

64     public String JavaDoc foundType() {
65         return this.foundType;
66     }
67 }
68
Popular Tags