* 欄位名稱
* @return Object
*/
public Object get(String fieldId) {
if (CapString.isEmpty(fieldId)) {
throw new CapException("field [" + fieldId + "] is empty!!",
getClass());
}
try {
String field = fieldId;
int index = fieldId.indexOf(".");
if (index > 0) {
field = fieldId.substring(0, index);
Object keyClazz = get(field);
if (keyClazz instanceof GenericBean) {
return ((GenericBean) keyClazz).get(fieldId
.substring(index + 1));
}
} else {
String getter = new StringBuffer("get")
.append(String.valueOf(field.charAt(0)).toUpperCase())
.append(field.substring(1)).toString();
Method method = ReflectionUtils.findMethod(getClass(), getter);
if (method == null) {
getter = "is" + getter.substring(3);
method = ReflectionUtils.findMethod(getClass(), getter);
}
if (method != null) {
return method.invoke(this);
} else {
Field f = ReflectionUtils.findField(getClass(), field);
if (f != null) {
f.setAccessible(true);
return f.get(this);
}
}
}
throw new CapException(new StringBuffer("field:").append(field)
.append(" is not exist!!").toString(), getClass());
} catch (Exception e) {
throw new CapException(e, getClass());
}
}// ;