KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > generator > JEntity


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop.generator;
19
20 import java.lang.reflect.Modifier JavaDoc;
21
22 public class JEntity {
23     private String JavaDoc name;
24     private int modifiers;
25     private JEntity parent;
26
27     public JEntity(String JavaDoc name) {
28         this(name, Modifier.PUBLIC);
29     }
30
31     public JEntity(String JavaDoc name, int modifiers) {
32         this.name = name;
33         this.modifiers = modifiers;
34     }
35
36     public JEntity getParent() {
37         return parent;
38     }
39
40     public void setParent(JEntity parent) {
41         this.parent = parent;
42     }
43
44     public String JavaDoc getName() {
45         return name;
46     }
47
48     public void setName(String JavaDoc val) {
49         name = val;
50     }
51
52     /*
53      * if value is true, then the modifier will be set,
54      * if value is false, then the modifier will be unset.
55      */

56     protected void adjustModifier(int modifier, boolean value) {
57         if (value) {
58             modifiers = (modifiers | modifier);
59         } else {
60             if ((modifiers & modifier) == modifier) {
61                 modifiers = (modifiers ^ modifier);
62             }
63         }
64     }
65
66     public void setModifier( int modifier )
67     {
68         adjustModifier( modifier, true );
69     }
70
71     public void unsetModifier( int modifier )
72     {
73         adjustModifier( modifier, false );
74     }
75
76     /*
77      * Sets all the modifiers in one set
78      *
79      * Example: setModifiers(Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL);
80      */

81     public void setModifiers(int modifiers) {
82         this.modifiers = modifiers;
83     }
84
85     public int getModifiers() {
86         return modifiers;
87     }
88 }
89
Popular Tags