当前位置: 首页>>代码示例>>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;未经允许,请勿转载。