标签:rgs 不同的 访问 trim 不同 append cte round div
public class java.lang.reflect.Modifier extends Object
public static boolean isPublic(int mod) {
return (mod & PUBLIC) != 0;
}
private static final int CLASS_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
Modifier.STRICT;
public static int classModifiers() {
return CLASS_MODIFIERS;
}
private static final int INTERFACE_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.ABSTRACT | Modifier.STATIC | Modifier.STRICT;
public static int interfaceModifiers() {
return INTERFACE_MODIFIERS;
}
private static final int CONSTRUCTOR_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
public static int constructorModifiers() {
return CONSTRUCTOR_MODIFIERS;
}
private static final int METHOD_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT;
public static int methodModifiers() {
return METHOD_MODIFIERS;
}
private static final int FIELD_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT |
Modifier.VOLATILE;
public static int fieldModifiers() {
return FIELD_MODIFIERS;
}
private static final int PARAMETER_MODIFIERS =
Modifier.FINAL;
public static int parameterModifiers() {
return PARAMETER_MODIFIERS;
}
public static String toString(int mod) {
StringBuilder sb = new StringBuilder();
int len;
if ((mod & PUBLIC) != 0) sb.append("public ");
if ((mod & PROTECTED) != 0) sb.append("protected ");
if ((mod & PRIVATE) != 0) sb.append("private ");
/* Canonical典范、规范 order */
if ((mod & ABSTRACT) != 0) sb.append("abstract ");
if ((mod & STATIC) != 0) sb.append("static ");
if ((mod & FINAL) != 0) sb.append("final ");
if ((mod & TRANSIENT) != 0) sb.append("transient ");
if ((mod & VOLATILE) != 0) sb.append("volatile ");
if ((mod & SYNCHRONIZED) != 0) sb.append("synchronized ");
if ((mod & NATIVE) != 0) sb.append("native ");
if ((mod & STRICT) != 0) sb.append("strictfp ");
if ((mod & INTERFACE) != 0) sb.append("interface ");
/* trim trailing space */
if ((len = sb.length()) > 0) return sb.toString().substring(0, len-1);
return "";
}
public class Test {
private static final transient int temp = 1;
public static void main(String[] args) throws Exception {
testModifier(Test.class.getDeclaredField("temp").getModifiers());//154。private static final transient
testModifier(Test.class.getMethod("main", String[].class).getModifiers());//9。public static
}
public static void testModifier(int mod) {
System.out.println("----------------------【mod=" + mod + "】----------------------");
System.out.println("【toString】" + Modifier.toString(mod));
System.out.println("【isPublic】" + Modifier.isPublic(mod));
System.out.println("【isPrivate】" + Modifier.isPrivate(mod));
System.out.println("【isProtected】" + Modifier.isProtected(mod));
System.out.println("【isStatic】" + Modifier.isStatic(mod));
System.out.println("【isFinal】" + Modifier.isFinal(mod));
System.out.println("【isSynchronized】" + Modifier.isSynchronized(mod));
System.out.println("【isVolatile】" + Modifier.isVolatile(mod));
System.out.println("【isTransient】" + Modifier.isTransient(mod));
System.out.println("【isNative】" + Modifier.isNative(mod));
System.out.println("【isInterface】" + Modifier.isInterface(mod));
System.out.println("【isAbstract】" + Modifier.isAbstract(mod));
System.out.println("【isStrict】" + Modifier.isStrict(mod));
}
}
System.out.println(Modifier.toString(Modifier.classModifiers()));//public protected private abstract static final strictfp
System.out.println(Modifier.toString(Modifier.interfaceModifiers()));//public protected private abstract static strictfp
System.out.println(Modifier.toString(Modifier.constructorModifiers()));//public protected private
System.out.println(Modifier.toString(Modifier.methodModifiers()));//public protected private abstract static final synchronized native strictfp
System.out.println(Modifier.toString(Modifier.fieldModifiers()));//public protected private static final transient volatile
System.out.println(Modifier.toString(Modifier.parameterModifiers()));//final
标签:rgs 不同的 访问 trim 不同 append cte round div
原文地址:http://www.cnblogs.com/baiqiantao/p/7478523.html