1 15 16 package javassist; 17 18 import javassist.bytecode.AccessFlag; 19 20 30 public class Modifier { 31 public static final int PUBLIC = AccessFlag.PUBLIC; 32 public static final int PRIVATE = AccessFlag.PRIVATE; 33 public static final int PROTECTED = AccessFlag.PROTECTED; 34 public static final int STATIC = AccessFlag.STATIC; 35 public static final int FINAL = AccessFlag.FINAL; 36 public static final int SYNCHRONIZED = AccessFlag.SYNCHRONIZED; 37 public static final int VOLATILE = AccessFlag.VOLATILE; 38 public static final int TRANSIENT = AccessFlag.TRANSIENT; 39 public static final int NATIVE = AccessFlag.NATIVE; 40 public static final int INTERFACE = AccessFlag.INTERFACE; 41 public static final int ABSTRACT = AccessFlag.ABSTRACT; 42 public static final int STRICT = AccessFlag.STRICT; 43 44 48 public static boolean isPublic(int mod) { 49 return (mod & PUBLIC) != 0; 50 } 51 52 56 public static boolean isPrivate(int mod) { 57 return (mod & PRIVATE) != 0; 58 } 59 60 64 public static boolean isProtected(int mod) { 65 return (mod & PROTECTED) != 0; 66 } 67 68 72 public static boolean isStatic(int mod) { 73 return (mod & STATIC) != 0; 74 } 75 76 80 public static boolean isFinal(int mod) { 81 return (mod & FINAL) != 0; 82 } 83 84 88 public static boolean isSynchronized(int mod) { 89 return (mod & SYNCHRONIZED) != 0; 90 } 91 92 96 public static boolean isVolatile(int mod) { 97 return (mod & VOLATILE) != 0; 98 } 99 100 104 public static boolean isTransient(int mod) { 105 return (mod & TRANSIENT) != 0; 106 } 107 108 112 public static boolean isNative(int mod) { 113 return (mod & NATIVE) != 0; 114 } 115 116 120 public static boolean isInterface(int mod) { 121 return (mod & INTERFACE) != 0; 122 } 123 124 128 public static boolean isAbstract(int mod) { 129 return (mod & ABSTRACT) != 0; 130 } 131 132 136 public static boolean isStrict(int mod) { 137 return (mod & STRICT) != 0; 138 } 139 140 144 public static int setPublic(int mod) { 145 return (mod & ~(PRIVATE | PROTECTED)) | PUBLIC; 146 } 147 148 152 public static int setProtected(int mod) { 153 return (mod & ~(PRIVATE | PUBLIC)) | PROTECTED; 154 } 155 156 160 public static int setPrivate(int mod) { 161 return (mod & ~(PROTECTED | PUBLIC)) | PRIVATE; 162 } 163 164 167 public static int setPackage(int mod) { 168 return (mod & ~(PROTECTED | PUBLIC | PRIVATE)); 169 } 170 171 174 public static int clear(int mod, int clearBit) { 175 return mod & ~clearBit; 176 } 177 178 public static String toString(int mod) { 179 return java.lang.reflect.Modifier.toString(mod); 180 } 181 } 182 | Popular Tags |