KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > reflect > declaration > CtElement


1 package spoon.reflect.declaration;
2
3 import java.lang.annotation.Annotation JavaDoc;
4 import java.util.List JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import spoon.processing.FactoryAccessor;
8 import spoon.reflect.reference.CtTypeReference;
9 import spoon.reflect.visitor.CtVisitor;
10 import spoon.reflect.visitor.Filter;
11 import spoon.reflect.visitor.Root;
12
13 /**
14  * This interface is the root interface for the metamodel elements (any program
15  * element).
16  */

17 @Root
18 public interface CtElement extends FactoryAccessor, Comparable JavaDoc<CtElement> {
19     /**
20      * Accepts a visitor.
21      *
22      * @param visitor
23      * to accept
24      */

25     void accept(CtVisitor visitor);
26
27     /**
28      * Searches for an annotation of the given class that annotates the current
29      * element.
30      *
31      * @param <A>
32      * the annotation's type
33      * @param annotationType
34      * the annotation's class
35      * @return if found, returns a proxy for this annotation
36      */

37     <A extends Annotation JavaDoc> A getAnnotation(Class JavaDoc<A> annotationType);
38
39     /**
40      * Gets the annotation element for a given annotation type.
41      *
42      * @param annotationType
43      * the annotation type
44      * @return the annotation if this element is annotated by one annotation of
45      * the given type
46      */

47     <A extends Annotation JavaDoc> CtAnnotation<A> getAnnotation(
48             CtTypeReference<A> annotationType);
49
50     /**
51      * Returns the annotations that are present on this element.
52      */

53     Set JavaDoc<CtAnnotation<? extends Annotation JavaDoc>> getAnnotations();
54
55     /**
56      * Returns the text of the documentation ("javadoc") comment of this
57      * element.
58      */

59     String JavaDoc getDocComment();
60
61     /**
62      * Gets the parent of current element.
63      */

64     CtElement getParent();
65
66     /**
67      * Gets the first parent that matches the given type.
68      */

69     <P extends CtElement> P getParent(Class JavaDoc<P> parentType);
70
71     /**
72      * Tells if the given element is a direct or indirect parent.
73      */

74     boolean hasParent(CtElement candidate);
75     
76     /**
77      * Gets the position of this element in input source files
78      *
79      * @return Source file and line number of this element or null
80      */

81     SourcePosition getPosition();
82
83     /**
84      * Replaces this element by another one.
85      */

86     void replace(CtElement element);
87
88     /**
89      * Replaces the elements that match the filter by the given element.
90      */

91     void replace(Filter<? extends CtElement> replacementPoints,
92             CtElement element);
93
94     /**
95      * Sets the annotations for this element.
96      */

97     void setAnnotations(Set JavaDoc<CtAnnotation<? extends Annotation JavaDoc>> annotation);
98
99     /**
100      * Sets the text of the documentation ("javadoc") comment of this
101      * declaration.
102      */

103     void setDocComment(String JavaDoc docComment);
104
105     /**
106      * Sets the parent element of the current element.
107      *
108      * @param element
109      * parent
110      */

111     void setParent(CtElement element);
112
113     /**
114      * Sets the position in the Java source file.
115      *
116      * @param position
117      * of this element in the input source files
118      */

119     void setPosition(SourcePosition position);
120
121     /**
122      * Gets the child elements annotated with the given annotation type's
123      * instances.
124      *
125      * @param <E>
126      * the element's type
127      * @param annotationType
128      * the annotation type
129      * @return all the child elements annotated with an instance of the given
130      * annotation type
131      */

132     <E extends CtElement> List JavaDoc<E> getAnnotatedChildren(
133             Class JavaDoc<? extends Annotation JavaDoc> annotationType);
134
135 }
Popular Tags