/Users/lyon/j4p/src/javassist/bytecode/AccessFlag.java

1    /* 
2     * Javassist, a Java-bytecode translator toolkit. 
3     * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved. 
4     * 
5     * The contents of this file are subject to the Mozilla Public License Version 
6     * 1.1 (the "License"); you may not use this file except in compliance with 
7     * the License.  Alternatively, the contents of this file may be used under 
8     * the terms of the GNU Lesser General Public License Version 2.1 or later. 
9     * 
10    * Software distributed under the License is distributed on an "AS IS" basis, 
11    * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
12    * for the specific language governing rights and limitations under the 
13    * License. 
14    */ 
15    
16   package javassist.bytecode; 
17    
18   /** 
19    * A support class providing static methods and constants 
20    * for access modifiers such as public, rivate, ... 
21    */ 
22   public class AccessFlag { 
23       public static final int PUBLIC = 0x0001; 
24       public static final int PRIVATE = 0x0002; 
25       public static final int PROTECTED = 0x0004; 
26       public static final int STATIC = 0x0008; 
27       public static final int FINAL = 0x0010; 
28       public static final int SYNCHRONIZED = 0x0020; 
29       public static final int VOLATILE = 0x0040; 
30       public static final int TRANSIENT = 0x0080; 
31       public static final int NATIVE = 0x0100; 
32       public static final int INTERFACE = 0x0200; 
33       public static final int ABSTRACT = 0x0400; 
34       public static final int STRICT = 0x0800; 
35       public static final int SUPER = 0x0020; 
36    
37       // Note: 0x0020 is assigned to both ACC_SUPER and ACC_SYNCHRONIZED 
38       // although java.lang.reflect.Modifier does not recognize ACC_SUPER. 
39    
40       /** 
41        * Truns the public bit on.  The protected and private bits are 
42        * cleared. 
43        */ 
44       public static int setPublic(int accflags) { 
45           return (accflags & ~(PRIVATE | PROTECTED)) | PUBLIC; 
46       } 
47    
48       /** 
49        * Truns the protected bit on.  The protected and public bits are 
50        * cleared. 
51        */ 
52       public static int setProtected(int accflags) { 
53           return (accflags & ~(PRIVATE | PUBLIC)) | PROTECTED; 
54       } 
55    
56       /** 
57        * Truns the private bit on.  The protected and private bits are 
58        * cleared. 
59        */ 
60       public static int setPrivate(int accflags) { 
61           return (accflags & ~(PROTECTED | PUBLIC)) | PRIVATE; 
62       } 
63    
64       /** 
65        * Clears the public, protected, and private bits. 
66        */ 
67       public static int setPackage(int accflags) { 
68           return (accflags & ~(PROTECTED | PUBLIC | PRIVATE)); 
69       } 
70    
71       /** 
72        * Clears a specified bit in <code>accflags</code>. 
73        */ 
74       public static int clear(int accflags, int clearBit) { 
75           return accflags & ~clearBit; 
76       } 
77    
78       /** 
79        * Converts a javassist.Modifier into 
80        * a javassist.bytecode.AccessFlag. 
81        * 
82        * @param modifier          javassist.Modifier 
83        */ 
84       public static int of(int modifier) { 
85           return modifier; 
86       } 
87    
88       /** 
89        * Converts a javassist.bytecode.AccessFlag 
90        * into a javassist.Modifier. 
91        * 
92        * @param accflags          javassist.bytecode.Accessflag 
93        */ 
94       public static int toModifier(int accflags) { 
95           return accflags; 
96       } 
97   } 
98