KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > support > reflect > declaration > CtAnonymousExecutableImpl


1 package spoon.support.reflect.declaration;
2
3 import java.util.Set JavaDoc;
4 import java.util.TreeSet JavaDoc;
5
6 import spoon.reflect.code.CtBlock;
7 import spoon.reflect.declaration.CtAnonymousExecutable;
8 import spoon.reflect.declaration.CtClass;
9 import spoon.reflect.declaration.ModifierKind;
10 import spoon.reflect.visitor.CtVisitor;
11
12 public class CtAnonymousExecutableImpl extends CtElementImpl implements
13         CtAnonymousExecutable {
14     private static final long serialVersionUID = 1L;
15
16     CtBlock body;
17
18     Set JavaDoc<ModifierKind> modifiers = new TreeSet JavaDoc<ModifierKind>();
19
20     public void accept(CtVisitor visitor) {
21         visitor.visitCtAnonymousExecutable(this);
22     }
23
24     public CtBlock getBody() {
25         return body;
26     }
27
28     public Set JavaDoc<ModifierKind> getModifiers() {
29         return modifiers;
30     }
31
32     public CtClass getOwnerClass() {
33         return (CtClass) parent;
34     }
35
36     public ModifierKind getVisibility() {
37         if (getModifiers().contains(ModifierKind.PUBLIC))
38             return ModifierKind.PUBLIC;
39         if (getModifiers().contains(ModifierKind.PROTECTED))
40             return ModifierKind.PROTECTED;
41         if (getModifiers().contains(ModifierKind.PRIVATE))
42             return ModifierKind.PRIVATE;
43         return null;
44     }
45
46     public boolean hasModifier(ModifierKind modifier) {
47         return modifiers.contains(modifier);
48     }
49
50     public void setBody(CtBlock block) {
51         body = block;
52     }
53
54     public void setModifiers(Set JavaDoc<ModifierKind> modifiers) {
55         this.modifiers = modifiers;
56     }
57
58     public void setVisibility(ModifierKind visibility) {
59         getModifiers().remove(ModifierKind.PUBLIC);
60         getModifiers().remove(ModifierKind.PROTECTED);
61         getModifiers().remove(ModifierKind.PRIVATE);
62         getModifiers().add(visibility);
63     }
64
65 }
66
Popular Tags