本文整理汇总了Java中java.lang.reflect.Modifier.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.toString方法的具体用法?Java Modifier.toString怎么用?Java Modifier.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.Modifier
的用法示例。
在下文中一共展示了Modifier.toString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGenericKInstance
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private K createGenericKInstance(Class z, View view) {
try {
Constructor constructor;
String buffer = Modifier.toString(z.getModifiers());
String className = z.getName();
if (className.contains("$") && !buffer.contains("static")) {
constructor = z.getDeclaredConstructor(getClass(), View.class);
return (K) constructor.newInstance(this, view);
} else {
constructor = z.getDeclaredConstructor(View.class);
return (K) constructor.newInstance(view);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: createGenericKInstance
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private K createGenericKInstance(Class z, View view) {
try {
Constructor constructor;
String buffer = Modifier.toString(z.getModifiers());
String className = z.getName();
if (className.contains("$") && !buffer.contains("static")) {
constructor = z.getDeclaredConstructor(getClass(), View.class);
return (K) constructor.newInstance(this, view);
} else {
constructor = z.getDeclaredConstructor(View.class);
return (K) constructor.newInstance(view);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例3: findObjectInR
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static Object findObjectInR(String packageName, String className) {
try {
Class managerClass = Class.forName(packageName + ".R");
Class[] classes = managerClass.getClasses();
Class[] clz = classes;
int length = classes.length;
for(int var5 = 0; var5 < length; ++var5) {
Class c = clz[var5];
int i = c.getModifiers();
String name = c.getName();
String s = Modifier.toString(i);
if(s.contains("static") && name.endsWith("$" + className)) {
return c.getConstructor(new Class[0]).newInstance(new Object[0]);
}
}
} catch (Exception e) {
Log.d(TAG, "exception: " + e.getMessage());
}
return null;
}
示例4: main
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, ClassNotFoundException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input;
while (!"HARVEST".equalsIgnoreCase(input = reader.readLine())){
Field[] theRichSoilLandFields = RichSoilLand.class.getDeclaredFields();
//Class.forName("pr01HarvestingFields.RichSoilLand");
for (Field field : theRichSoilLandFields) {
String modToString = Modifier.toString(field.getModifiers());
if(!"all".equalsIgnoreCase(input) && !modToString.equalsIgnoreCase(input)){
continue;
}
System.out.println(String.format("%s %s %s", modToString, field.getType().getSimpleName(), field.getName()));
}
}
}
示例5: getClassStaticFieldValue
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 获取Class所有静态字段的值
*/
public static List<Object> getClassStaticFieldValue(Class clazz) {
Field[] fields = clazz.getFields();
List<Object> ret = new ArrayList<>();
for (Field field : fields) {
String m = Modifier.toString(field.getModifiers());
if (m.contains("static")) {
try {
ret.add(field.get(null));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return ret;
}
示例6: toString
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
public String toString() {
Type type = getParameterizedType();
String typename = type.getTypeName();
if (isVarArgs()) {
typename = typename.replaceFirst("\\[\\]$", "...");
}
final StringBuilder sb = new StringBuilder(Modifier.toString(getModifiers()));
if (sb.length() != 0) {
sb.append(' ');
}
return sb.append(typename).append(' ').append(getName()).toString();
}
示例7: toString
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public String toString() {
return ("Method: "
+ Modifier.toString(method.getModifiers()) + " "
+ super.toString() + " "
+ method.getName());
}
示例8: getClassStaticField
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 获取Class所有的静态成员
*/
public static List<Field> getClassStaticField(Class clazz) {
Field[] fields = clazz.getFields();
List<Field> ret = new ArrayList<>();
for (Field field : fields) {
String m = Modifier.toString(field.getModifiers());
if (m.contains("static")) {
ret.add(field);
}
}
return ret;
}
示例9: getAsText
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/** @return textual representition of current value of the modifiers. */
@Override
public String getAsText() {
return Modifier.toString(getModifier());
}
示例10: modifiers
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Return the modifier string for this class. If it's an interface
* exclude 'abstract' keyword from the modifier string
*/
@Override
public String modifiers() {
return Modifier.toString(modifierSpecifier());
}
示例11: modifierString
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Return a string describing the access modifier flags.
* Don't include native or synchronized.
*
* The modifier names are returned in canonical order, as
* specified by <em>The Java Language Specification</em>.
*/
protected String modifierString(MemberDoc member) {
int ms = member.modifierSpecifier();
int no = Modifier.NATIVE | Modifier.SYNCHRONIZED;
return Modifier.toString(ms & ~no);
}