本文整理汇总了Java中org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField方法的典型用法代码示例。如果您正苦于以下问题:Java FieldUtils.readDeclaredField方法的具体用法?Java FieldUtils.readDeclaredField怎么用?Java FieldUtils.readDeclaredField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.reflect.FieldUtils
的用法示例。
在下文中一共展示了FieldUtils.readDeclaredField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callAdditionalPassVisitor
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* This is temporary workaround to bypass the validation stage of the
* compiler while *still* doing the additional_validate stage. We are
* bypassing the validation stage because it does a deep validation that we
* don't have all the parts for yet in the offline compiler. Rather than
* stop all work on that, we bypass it so that we can still do useful things
* like find all your types, find all your methods, etc.
*
*/
@SuppressWarnings("unchecked")
private void callAdditionalPassVisitor(ApexCompiler compiler) {
try {
List<CodeUnit> allUnits = (List<CodeUnit>) FieldUtils.readDeclaredField(compiler, "allUnits", true);
CompilerContext compilerContext = (CompilerContext) FieldUtils.readDeclaredField(compiler,
"compilerContext", true);
for (CodeUnit unit : allUnits) {
Method getOperation = CompilerStage.ADDITIONAL_VALIDATE.getDeclaringClass()
.getDeclaredMethod("getOperation");
getOperation.setAccessible(true);
CompilerOperation operation = (CompilerOperation) getOperation
.invoke(CompilerStage.ADDITIONAL_VALIDATE);
operation.invoke(compilerContext, unit);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
}
}
示例2: sqlMapGenerated
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
@Override
public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
try {
// use reflect to fix the root comment
Document document = (Document) FieldUtils.readDeclaredField(sqlMap, "document", true);
ExtendedDocument extendedDocument = new ExtendedDocument(document);
FieldUtils.writeDeclaredField(sqlMap, "document", extendedDocument, true);
if (context.getCommentGenerator() instanceof CommentGenerator) {
CommentGenerator cg = (CommentGenerator) context.getCommentGenerator();
cg.addSqlMapFileComment(extendedDocument);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return true;
}
示例3: callAdditionalPassVisitor
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* This is temporary workaround to bypass the validation stage of the compiler while *still* doing the
* additional_validate stage. We are bypassing the validation stage because it does a deep validation that we don't
* have all the parts for yet in the offline compiler. Rather than stop all work on that, we bypass it so that we
* can still do useful things like find all your types, find all your methods, etc.
*
*/
@SuppressWarnings("unchecked")
private void callAdditionalPassVisitor(ApexCompiler compiler) {
try {
List<CodeUnit> allUnits = (List<CodeUnit>) FieldUtils.readDeclaredField(compiler, "allUnits", true);
CompilerContext compilerContext =
(CompilerContext) FieldUtils.readDeclaredField(compiler, "compilerContext", true);
for (CodeUnit unit : allUnits) {
Method getOperation =
CompilerStage.ADDITIONAL_VALIDATE.getDeclaringClass().getDeclaredMethod("getOperation");
getOperation.setAccessible(true);
CompilerOperation operation =
(CompilerOperation) getOperation.invoke(CompilerStage.ADDITIONAL_VALIDATE);
operation.invoke(compilerContext, unit);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
logger.error("Failed to inokve additional validator", e);
}
}
示例4: getLockInProcessQueue
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private ReadWriteLock getLockInProcessQueue(ProcessQueue pq) {
try {
return (ReadWriteLock) FieldUtils.readDeclaredField(pq, "lockTreeMap", true);
} catch (IllegalAccessException e) {
return null;
}
}
示例5: sqlMapGenerated
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
@Override
public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {
SqlMapGeneratorConfiguration smgc = context.getSqlMapGeneratorConfiguration();
try {
Document document = (Document) FieldUtils.readDeclaredField(sqlMap, "document", true);
File targetFile = getTargetFile(smgc.getTargetPackage(), sqlMap.getFileName());
if (!targetFile.exists()) { // 第一次生成直接使用当前生成的文件
return true;
}
visitAndMerge(document, targetFile);
} catch (ShellException | IOException | IllegalAccessException | DocumentException e) {
e.printStackTrace();
}
return true;
}
示例6: readField
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public Object readField(Object target, String fieldName)
{
if(usesMap)
return ((Map) target).get(fieldName);
try
{
return FieldUtils.readDeclaredField(target, fieldName, true);
}
catch(IllegalAccessException e)
{
throw new RuntimeException(e);
}
}
示例7: field
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
public static Object field(Object o, String name)
{
try
{
return FieldUtils.readDeclaredField(o, name, true);
}
catch (Exception e)
{
return null;//throw new SyntaxException(e);
}
}
示例8: findConfiguration
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
private BeanTesterConfiguration findConfiguration()
throws IllegalAccessException {
BeanTesterConfiguration config = (BeanTesterConfiguration)
FieldUtils.readDeclaredField(beanTester, "configuration", true);
return config;
}
示例9: getShortFromArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 获取对象数组字段中目标索引的<code>short</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @return 目标索引的值
*/
public static short getShortFromArrayVolatile(Object object, String fieldName, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = shortArrayIndexOffset(index);
return unsafe.getShortVolatile(array, offset);
}
示例10: getBooleanFromArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 获取对象数组字段中目标索引的<code>boolean</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @return 目标索引的值
*/
public static boolean getBooleanFromArrayVolatile(Object object, String fieldName, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = booleanArrayIndexOffset(index);
return unsafe.getBooleanVolatile(array, offset);
}
示例11: getDoubleFromArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 获取对象数组字段中目标索引的<code>double</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @return 目标索引的值
*/
public static double getDoubleFromArrayVolatile(Object object, String fieldName, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = doubleArrayIndexOffset(index);
return unsafe.getDoubleVolatile(array, offset);
}
示例12: putOrderedObjectIntoArray
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 给指定对象的字段设置给定的<code>java.lang.Object</code>值(顺序写入)
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @param value
* <code>java.lang.Object</code>值
* @throws IllegalArgumentException
* 参考{@link ReflectionUtils#assertArrayType(Object)}
* @throws ArrayIndexOutOfBoundsException
* 当<code>index</code>小于0,或者大于或等于数组长度
*/
public static void putOrderedObjectIntoArray(Object object, String fieldName, int index, Object value) throws IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = objectArrayIndexOffset(index);
unsafe.putOrderedObject(array, offset, value);
}
示例13: getCharFromArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 获取对象数组字段中目标索引的<code>char</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @return 目标索引的值
* @throws IllegalArgumentException
* 参考{@link ReflectionUtils#assertArrayType(Object)}
* @throws ArrayIndexOutOfBoundsException
* 当<code>index</code>小于0,或者大于或等于数组长度
*/
public static char getCharFromArrayVolatile(Object object, String fieldName, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = charArrayIndexOffset(index);
return unsafe.getCharVolatile(array, offset);
}
示例14: getObjectFromArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 获取对象数组字段中目标索引的<code>java.lang.Object</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @return 目标索引的值
* @throws IllegalArgumentException
* 参考{@link ReflectionUtils#assertArrayType(Object)}
* @throws ArrayIndexOutOfBoundsException
* 当<code>index</code>小于0,或者大于或等于数组长度
*/
public static Object getObjectFromArrayVolatile(Object object, String fieldName, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
assertArrayIndex(array, index);
long offset = objectArrayIndexOffset(index);
return unsafe.getObjectVolatile(array, offset);
}
示例15: putLongIntoArrayVolatile
import org.apache.commons.lang3.reflect.FieldUtils; //导入方法依赖的package包/类
/**
* 给指定对象的字段设置给定的<code>long</code>值
*
* @param object
* 对象
* @param fieldName
* 字段名称
* @param index
* 元素索引
* @param value
* <code>long</code>值
* @throws IllegalArgumentException
* 参考{@link ReflectionUtils#assertArrayType(Object)}
* @throws ArrayIndexOutOfBoundsException
* 当<code>index</code>小于0,或者大于或等于数组长度
*/
public static void putLongIntoArrayVolatile(Object object, String fieldName, int index, long value) throws IllegalArgumentException, ArrayIndexOutOfBoundsException, IllegalAccessException {
Object array = FieldUtils.readDeclaredField(object, fieldName, true);
ReflectionUtils.assertArrayIndex(array, index);
long offset = longArrayIndexOffset(index);
unsafe.putLongVolatile(array, offset, value);
}