/* (non-Javadoc) */
 @SuppressWarnings("unchecked")
 private <T> T getFieldValue(
     final Object source, final String fieldName, final Class<T> targetType) {
   Field field = ReflectionUtils.findField(source.getClass(), fieldName, targetType);
   ReflectionUtils.makeAccessible(field);
   return (T) ReflectionUtils.getField(field, source);
 }
 @Override
 public boolean call(Object entity) {
   Object fieldval = ReflectionUtils.getField(field, entity);
   if (fieldval instanceof Closure) {
     return resolveReturnValue(callClosure(entity, (Closure) fieldval));
   }
   log.error("Field " + field + " is not Closure or method.");
   return false;
 }
 @Override
 protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
   Workbook workbook = super.getTemplateSource(url, request);
   Field field = WorkbookParser.class.getDeclaredField("settings");
   field.setAccessible(true);
   WorkbookSettings settings = (WorkbookSettings) ReflectionUtils.getField(field, workbook);
   settings.setWriteAccess(null);
   return workbook;
 }
示例#4
0
 private static Object getField(Object target, String name) {
   if (target != null) {
     Field field = ReflectionUtils.findField(target.getClass(), name);
     if (field != null) {
       ReflectionUtils.makeAccessible(field);
       return ReflectionUtils.getField(field, target);
     }
   }
   return null;
 }
  private static Object getField(Object target, String name) {
    Assert.notNull(target, "Target object must not be null");
    Field field = ReflectionUtils.findField(target.getClass(), name);
    if (field == null) {
      throw new IllegalArgumentException(
          "Could not find field [" + name + "] on target [" + target + "]");
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Getting field [" + name + "] from target [" + target + "]");
    }
    ReflectionUtils.makeAccessible(field);
    return ReflectionUtils.getField(field, target);
  }
 public Map<String, Object> parseFields(Object condition, Class clazz) {
   Map<String, Object> params = new HashMap<>();
   Class superClass = clazz.getSuperclass();
   if (superClass != null) {
     params.putAll(parseFields(condition, superClass));
   }
   Field[] fieldses = clazz.getDeclaredFields();
   for (Field field : fieldses) {
     field.setAccessible(true);
     Object value = ReflectionUtils.getField(field, condition);
     if (value != null) {
       String name = field.getName();
       params.put(name, value);
     }
   }
   return params;
 }
  public SqlMapRepositoryFactory(SqlMapClient sqlMapClient) {
    Assert.notNull(sqlMapClient, "SqlMapClient must not be null!");

    this.sqlMapClient = (SqlMapClientImpl) sqlMapClient;
    this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);

    if (ExtendedSqlMapClient.class.isAssignableFrom(sqlMapClient.getClass())) {
      this.sqlMapExecutorDelegate = ((ExtendedSqlMapClient) sqlMapClient).getDelegate();
    } else if (hasSqlMapExecutorDelegate(sqlMapClient)) {
      Field field = findSqlMapExecutorDelegate(sqlMapClient);
      field.setAccessible(true);

      this.sqlMapExecutorDelegate =
          (SqlMapExecutorDelegate) ReflectionUtils.getField(field, sqlMapClient);
    } else {
      throw new IllegalArgumentException("not found SqlMapExecutorDelegate in SqlMapClient.");
    }
  }
 @SuppressWarnings("unchecked")
 public static <T> T getField(Class<?> target, String name) {
   Field field = ReflectionUtils.findField(target, name, null);
   ReflectionUtils.makeAccessible(field);
   return (T) ReflectionUtils.getField(field, target);
 }