01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.support.reflect.declaration;
19:
20: import java.util.Set;
21: import java.util.TreeSet;
22:
23: import spoon.reflect.declaration.CtNamedElement;
24: import spoon.reflect.declaration.ModifierKind;
25: import spoon.reflect.reference.CtReference;
26:
27: public abstract class CtNamedElementImpl extends CtElementImpl
28: implements CtNamedElement {
29:
30: Set<ModifierKind> modifiers = new TreeSet<ModifierKind>();
31:
32: String simpleName;
33:
34: public Set<ModifierKind> getModifiers() {
35: return modifiers;
36: }
37:
38: public CtReference getReference() {
39: return null;
40: }
41:
42: public String getSimpleName() {
43: return simpleName;
44: }
45:
46: public ModifierKind getVisibility() {
47: if (getModifiers().contains(ModifierKind.PUBLIC))
48: return ModifierKind.PUBLIC;
49: if (getModifiers().contains(ModifierKind.PROTECTED))
50: return ModifierKind.PROTECTED;
51: if (getModifiers().contains(ModifierKind.PRIVATE))
52: return ModifierKind.PRIVATE;
53: return null;
54: }
55:
56: public boolean hasModifier(ModifierKind modifier) {
57: return getModifiers().contains(modifier);
58: }
59:
60: public void setModifiers(Set<ModifierKind> modifiers) {
61: this .modifiers = modifiers;
62: }
63:
64: public void setSimpleName(String simpleName) {
65: this .simpleName = simpleName;
66: }
67:
68: public void setVisibility(ModifierKind visibility) {
69: getModifiers().remove(ModifierKind.PUBLIC);
70: getModifiers().remove(ModifierKind.PROTECTED);
71: getModifiers().remove(ModifierKind.PRIVATE);
72: getModifiers().add(visibility);
73: }
74:
75: }
|