获取对象指定字段值

@param source     对象
@param fieldnames 属性名数组
@return 对象的字符串数组，和属性名对应
@throws Exception
960490
private static String[] getObjValues(Object source, String... fieldnames) throws Exception {
        String[] results = new String[fieldnames.length];
        Field field;
        String value;
        Object obj;
        for (int i = 0; i < fieldnames.length; i++) {
            field = FieldUtil.getField(source, fieldnames[i]);
            if (field == null) {
                continue;
            }
            obj = field.get(source);
            if (obj == null) {
                value = "";
            } else if (obj instanceof Date) {
                value = DateUtil.smartFormat((Date) obj);
            } else {
                value = String.valueOf(obj);
            }
            results[i] = value;
        }
        return results;
    }
407768
private Object getObjectValue(String fieldname, boolean fromSource) throws Exception {
        Object sourceObject = fromSource ? source : target;
        Object result = null;
        for (String part : StringUtils.split(fieldname, ".")) {
            if (isTemporaryField(part)) {
                result = loadObjectFromTemporary(part, fieldname);
            } else {
                result = loadObjectFromField(part, result, sourceObject);
            }
        }
        return result;
    }
253661
static FieldPath fromDotSeparatedString(String field) {
    if (PROHIBITED_CHARACTERS.matcher(field).matches()) {
      throw new IllegalArgumentException("Use FieldPath.of() for field names containing '˜*/[]'.");
    }
    return empty().append(field);
  }
751242
public static void copyFromTo(Object from, Object to, String... fieldNames) {
        for (String field : fieldNames) {
            copyFromTo(from, to, field);
        }
    }
1352602
public String[] generateFieldNameCodes(final String objectName, final String field) {
        
        final List<String> codeList = new ArrayList<String>();
        codeList.addAll(Arrays.asList(generateCodes(null, objectName, field, null)));
        
        // オブジェクト名の最後の値を取得する
        final int dotIndex = objectName.lastIndexOf('.');
        if(dotIndex > 0) {
            final String subName = objectName.substring(dotIndex + 1);
            for(String code : generateCodes(null, subName, field, null)) {
                if(!codeList.contains(code)) {
                    codeList.add(code);
                }
            }
            
        }
        
        return codeList.toArray(new String[codeList.size()]);
    }
823373
@Override public final String getHeaderField(String fieldName) {
    try {
      return fieldName == null
          ? StatusLine.get(getResponse().getResponse()).toString()
          : getHeaders().get(fieldName);
    } catch (IOException e) {
      return null;
    }
  }
774744
public function setDefaultNull($fieldNames)
    {
        if (is_array($fieldNames))
        {
            foreach ($fieldNames as $field_name)
            {
                $this->setDefaultNull($field_name);
            }
        }
        else
        {
            if (isset($this->m_fields[$fieldNames]))
            {
                $this->m_fields[$fieldNames]->setDefault('NULL');
            }
            else
            {
                $err_msg = '[' . $fieldNames . '] field not found in table ' .
                           '[' . $this->m_name . '] when setting null fields';

                throw new \Exception($err_msg);
            }
        }
    }
630927
@SuppressWarnings("unchecked")
	public <T> T get(String fieldName) throws BeanException{
		if(Map.class.isAssignableFrom(beanClass)){
			return (T) ((Map<?, ?>)bean).get(fieldName);
		}else{
			try {
				final Method method = BeanUtil.getBeanDesc(beanClass).getGetter(fieldName);
				if(null == method){
					throw new BeanException("No get method for {}", fieldName);
				}
				return (T) method.invoke(this.bean);
			} catch (Exception e) {
				throw new BeanException(e);
			}
		}
	}
1263726
public static final String getter(Field field, String fieldName)
    {
        Class<?> type = field.getType();
        if (type.isPrimitive() && "boolean".equals(type.getName()))
        {
            return isser(fieldName);
        }
        else
        {
            return getter(fieldName);
        }
    }
9381
public Entity setFieldNames(String... fieldNames) {
		if (ArrayUtil.isNotEmpty(fieldNames)) {
			this.fieldNames = CollectionUtil.newHashSet(fieldNames);
		}
		return this;
	}
260520
public static <X> String createFieldId(Field field, Collection<Annotation> annotations) {
        StringBuilder builder = new StringBuilder();
        builder.append(field.getDeclaringClass().getName());
        builder.append('.');
        builder.append(field.getName());
        builder.append(createAnnotationCollectionId(annotations));
        return builder.toString();
    }
833791
public <T> T safeGet(String fieldName){
		try {
			return get(fieldName);
		} catch (Exception e) {
			return null;
		}
	}
1234389
private Set<String> collidingFieldNames(ImmutableList<Field> fields) {
    Set<String> fieldNames = new LinkedHashSet<>();
    Set<String> collidingNames = new LinkedHashSet<>();
    for (Field field : fields) {
      if (!fieldNames.add(field.name())) {
        collidingNames.add(field.name());
      }
    }
    return collidingNames;
  }
1353713
private static Document getProjection(List<String> fieldNames) {
		Document projection = new Document();
		for ( String column : fieldNames ) {
			projection.put( column, 1 );
		}

		return projection;
	}
151559
public void setName(String fieldName) {
        if (m_name != null) {
            throw new IllegalArgumentException("Field name is already set: " + m_name);
        }
        if (!isValidFieldName(fieldName)) {
            throw new IllegalArgumentException("Invalid field name: " + fieldName);
        }
        m_name = fieldName;
    }
801714
public String getString(final String fieldName) {
    try {
      return _jsonObject.getString(fieldName);
    } catch (JSONException ex) {
      throw new RuntimeException("Cannot find field", ex);
    }
  }
416459
public static base_responses delete(nitro_service client, String fieldname[]) throws Exception {
		base_responses result = null;
		if (fieldname != null && fieldname.length > 0) {
			appfwconfidfield deleteresources[] = new appfwconfidfield[fieldname.length];
			for (int i=0;i<fieldname.length;i++){
				deleteresources[i] = new appfwconfidfield();
				deleteresources[i].fieldname = fieldname[i];
			}
			result = delete_bulk_request(client, deleteresources);
		}
		return result;
	}