本文整理了Java中org.kaazing.gateway.util.Utils.loadClass()
方法的一些代码示例,展示了Utils.loadClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.loadClass()
方法的具体详情如下:
包路径:org.kaazing.gateway.util.Utils
类名称:Utils
方法名:loadClass
[英]Load the specified class, which can be a (public static) inner class provided the physical name is used ("my.package.MyClass$MyInnerClass") rather than the canonical name ("my.package.MyClass.MyInnerClass")
[中]加载指定的类,如果使用的是物理名称(“my.package.MyClass$MyInnerClass”)而不是规范名称(“my.package.MyClass.MyInnerClass”),则该类可以是(公共静态)内部类
代码示例来源:origin: kaazing/gateway
/**
* Gets the value of a static int field (static final constant), given its fully qualified name.
* The owner class can be a (public static) inner class provided the physical name is used
* (e.g. "my.package.MyClass$MyInnerClass.INT_FIELD").
* @param fullyQualifiedFieldName
* @return the value of the field
* @throws ClassNotFoundException
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws IllegalArgumentException - if the given name is invalid
*/
public static int loadStaticInt(String fullyQualifiedFieldName)
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
int lastDotPos = fullyQualifiedFieldName.lastIndexOf('.');
// Name must contain "." but not as first or last character
if (lastDotPos <= 0 || lastDotPos + 1 >= fullyQualifiedFieldName.length()) {
throw new IllegalArgumentException(fullyQualifiedFieldName);
}
String className = fullyQualifiedFieldName.substring(0, lastDotPos);
String fieldName = fullyQualifiedFieldName.substring(lastDotPos + 1);
Class<?> clazz = loadClass(className);
Field field = clazz.getField(fieldName);
int mode = field.getInt(clazz);
return mode;
}
代码示例来源:origin: kaazing/gateway
Class<?> principalClass = Utils.loadClass(principalClassName);
Class<?> userPrincipalClass = Utils.loadClass(principal.getValue());
代码示例来源:origin: kaazing/gateway
Class<?> untypedClass;
try {
untypedClass = org.kaazing.gateway.util.Utils.loadClass(className);
if ( !(Principal.class.isAssignableFrom(untypedClass)) ) {
String message = className + " is not of type Principal";
内容来源于网络,如有侵权,请联系作者删除!