當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldUtils.readDeclaredField方法代碼示例

本文整理匯總了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) {
	}
}
 
開發者ID:vazexqi,項目名稱:ApexJorjeExample,代碼行數:28,代碼來源:CompilerService.java

示例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;
}
 
開發者ID:beihaifeiwu,項目名稱:dolphin,代碼行數:17,代碼來源:CommentsWavePlugin.java

示例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);
    }
}
 
開發者ID:forcedotcom,項目名稱:idecore,代碼行數:27,代碼來源:CompilerService.java

示例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;
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:8,代碼來源:LocalMessageCache.java

示例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;
}
 
開發者ID:beihaifeiwu,項目名稱:dolphin,代碼行數:16,代碼來源:ContentMergePlugin.java

示例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);
	}
}
 
開發者ID:justin-espedal,項目名稱:polydes,代碼行數:15,代碼來源:PropertiesSheetSupport.java

示例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);
	}
}
 
開發者ID:justin-espedal,項目名稱:polydes,代碼行數:12,代碼來源:RuntimeLanguage.java

示例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;
}
 
開發者ID:Force66,項目名稱:BeanTester,代碼行數:7,代碼來源:BeanTesterTest.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:18,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:18,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:18,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:23,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:22,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:22,代碼來源:UnsafeUtils.java

示例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);
}
 
開發者ID:mercyblitz,項目名稱:confucius-commons,代碼行數:23,代碼來源:UnsafeUtils.java


注:本文中的org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。