1 33 34 package net.percederberg.grammatica.code.csharp; 35 36 44 abstract class CSharpModifier { 45 46 49 public static final int PUBLIC = 1; 50 51 54 public static final int PROTECTED_INTERNAL = 2; 55 56 59 public static final int PROTECTED = 3; 60 61 64 public static final int INTERNAL = 4; 65 66 69 public static final int PRIVATE = 5; 70 71 74 public static final int STATIC = 8; 75 76 79 public static final int NEW = 16; 80 81 84 public static final int VIRTUAL = 32; 85 86 89 public static final int SEALED = 64; 90 91 94 public static final int OVERRIDE = 128; 95 96 99 public static final int ABSTRACT = 256; 100 101 104 public static final int EXTERN = 512; 105 106 109 public static final int CONST = 1024; 110 111 114 public static final int READONLY = 2048; 115 116 119 public static final int VOLATILE = 4096; 120 121 128 public static String createModifierDecl(int modifiers) { 129 StringBuffer res = new StringBuffer (); 130 131 switch (modifiers % 8) { 133 case PUBLIC: 134 res.append("public "); 135 break; 136 case PROTECTED_INTERNAL: 137 res.append("protected internal "); 138 break; 139 case PROTECTED: 140 res.append("protected "); 141 break; 142 case INTERNAL: 143 res.append("internal "); 144 break; 145 case PRIVATE: 146 res.append("private "); 147 break; 148 } 149 150 if ((modifiers & STATIC) > 0) { 152 res.append("static "); 153 } 154 if ((modifiers & NEW) > 0) { 155 res.append("new "); 156 } 157 if ((modifiers & VIRTUAL) > 0) { 158 res.append("virtual "); 159 } 160 if ((modifiers & SEALED) > 0) { 161 res.append("sealed "); 162 } 163 if ((modifiers & OVERRIDE) > 0) { 164 res.append("override "); 165 } 166 if ((modifiers & ABSTRACT) > 0) { 167 res.append("abstract "); 168 } 169 if ((modifiers & EXTERN) > 0) { 170 res.append("extern "); 171 } 172 if ((modifiers & CONST) > 0) { 173 res.append("const "); 174 } 175 if ((modifiers & READONLY) > 0) { 176 res.append("readonly "); 177 } 178 if ((modifiers & VOLATILE) > 0) { 179 res.append("volatile "); 180 } 181 182 return res.toString(); 183 } 184 } 185 | Popular Tags |