1 33 34 package net.percederberg.grammatica.code.java; 35 36 44 abstract class JavaModifier { 45 46 49 public static final int PUBLIC = 0; 50 51 54 public static final int PROTECTED = 1; 55 56 59 public static final int PACKAGE_LOCAL = 2; 60 61 64 public static final int PRIVATE = 3; 65 66 69 public static final int STATIC = 4; 70 71 74 public static final int ABSTRACT = 8; 75 76 79 public static final int FINAL = 16; 80 81 84 public static final int SYNCHRONIZED = 32; 85 86 89 public static final int NATIVE = 64; 90 91 94 public static final int TRANSIENT = 128; 95 96 99 public static final int VOLATILE = 256; 100 101 104 public static final int STRICTFP = 512; 105 106 113 public static String createModifierDecl(int modifiers) { 114 StringBuffer res = new StringBuffer (); 115 116 switch (modifiers % 4) { 118 case PUBLIC: 119 res.append("public "); 120 break; 121 case PROTECTED: 122 res.append("protected "); 123 break; 124 case PACKAGE_LOCAL: 125 break; 126 case PRIVATE: 127 res.append("private "); 128 break; 129 } 130 131 if ((modifiers & STATIC) > 0) { 133 res.append("static "); 134 } 135 if ((modifiers & ABSTRACT) > 0) { 136 res.append("abstract "); 137 } 138 if ((modifiers & FINAL) > 0) { 139 res.append("final "); 140 } 141 if ((modifiers & SYNCHRONIZED) > 0) { 142 res.append("synchronized "); 143 } 144 if ((modifiers & NATIVE) > 0) { 145 res.append("native "); 146 } 147 if ((modifiers & TRANSIENT) > 0) { 148 res.append("transient "); 149 } 150 if ((modifiers & VOLATILE) > 0) { 151 res.append("volatile "); 152 } 153 if ((modifiers & STRICTFP) > 0) { 154 res.append("strictfp "); 155 } 156 157 return res.toString(); 158 } 159 } 160 | Popular Tags |