KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > javadoc > JavaDocUtils


1 package org.netbeans.modules.tasklist.javadoc;
2
3 import java.lang.reflect.Modifier JavaDoc;
4 import org.openide.src.ClassElement;
5 import org.openide.src.MemberElement;
6
7 /**
8  *
9  */

10 public class JavaDocUtils {
11     /**
12      * Creates a new instance of JavaDocUtils
13      */

14     private JavaDocUtils() {
15     }
16
17     public static int getEffectiveAccess(MemberElement el) {
18         int access = el.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
19         if (access == Modifier.PRIVATE)
20             return access;
21         ClassElement decl = el.getDeclaringClass();
22         if (decl == null)
23             // it is a top-level class
24
return access;
25         if (!decl.isClassOrInterface())
26             // interface members must be public
27
access = Modifier.PUBLIC;
28         
29         int parentAccess = getEffectiveAccess(decl);
30         switch (parentAccess) {
31             case Modifier.PRIVATE:
32             case 0:
33                 // private members were handled above, everything else is
34
// constrained by parent's privacy
35
return parentAccess;
36             case Modifier.PROTECTED:
37                 // member can be restricted to only the package
38
return access == 0 ? 0 : parentAccess;
39             case Modifier.PUBLIC:
40             default:
41                 return access;
42         }
43     }
44 }
45
Popular Tags