本文整理匯總了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);
}