KickJava   Java API By Example, From Geeks To Geeks.

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


1 package spoon.support.reflect.declaration;
2
3 import java.util.Set JavaDoc;
4 import java.util.TreeSet JavaDoc;
5
6 import spoon.reflect.declaration.CtNamedElement;
7 import spoon.reflect.declaration.ModifierKind;
8 import spoon.reflect.reference.CtReference;
9
10 public abstract class CtNamedElementImpl extends CtElementImpl implements
11         CtNamedElement {
12
13     Set JavaDoc<ModifierKind> modifiers = new TreeSet JavaDoc<ModifierKind>();
14
15     String JavaDoc simpleName;
16
17     public Set JavaDoc<ModifierKind> getModifiers() {
18         return modifiers;
19     }
20
21     public CtReference getReference() {
22         return null;
23     }
24
25     public String JavaDoc getSimpleName() {
26         return simpleName;
27     }
28
29     public ModifierKind getVisibility() {
30         if (getModifiers().contains(ModifierKind.PUBLIC))
31             return ModifierKind.PUBLIC;
32         if (getModifiers().contains(ModifierKind.PROTECTED))
33             return ModifierKind.PROTECTED;
34         if (getModifiers().contains(ModifierKind.PRIVATE))
35             return ModifierKind.PRIVATE;
36         return null;
37     }
38
39     public boolean hasModifier(ModifierKind modifier) {
40         return getModifiers().contains(modifier);
41     }
42
43     public void setModifiers(Set JavaDoc<ModifierKind> modifiers) {
44         this.modifiers = modifiers;
45     }
46
47     public void setSimpleName(String JavaDoc simpleName) {
48         this.simpleName = simpleName;
49     }
50
51     public void setVisibility(ModifierKind visibility) {
52         getModifiers().remove(ModifierKind.PUBLIC);
53         getModifiers().remove(ModifierKind.PROTECTED);
54         getModifiers().remove(ModifierKind.PRIVATE);
55         getModifiers().add(visibility);
56     }
57
58 }
59
Popular Tags