List<TempPrintChildInfo> printInfo = formTempServers.getTempPrintChildByType(type);
Iterator<TempPrintChildInfo> it = printInfo.iterator();
TempPrintChildInfo info = it.next();
while(it.hasNext()){
TempPrintChildInfo info = it.next();
String key = info.getHtmlType();
if(StringUtils.isBlank(key)){
continue;
}
String msg = (String) getFieldValue(key,badbean);
if(msg!=null){
if("sickage".contains(key)){
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher m = p.matcher(msg);
if (m.find()) {
info.setValue(msg);
} else {
info.setValue(msg+"岁");
}
continue;
}
}
public class TempPrintChildInfo {
private Integer id;
private String tempType;
private String htmlType;
private String title;
private String value;
private Object valueObject;
private String compareStr;
private Integer endsWith;
private String endsWithStr;
private Integer index;
private Integer lineNo;
private Integer titleColspan;
private Integer valueColspan;
private String titleStyle;
private String valueStyle;
private String onlyShowFlag;
}
private Object getFieldValue(String key, Object t) throws InvocationTargetException, IllegalAccessException {
if(t == null){
return null;
}
Object obj = null;
Class<?> clazz = t.getClass();
Method method;
try {
method = clazz.getDeclaredMethod("get" + captureName(key));
}catch (NoSuchMethodException e){
method = null;
}
if(method!=null){
obj = method.invoke(t);
}
return obj;
}
public static String captureName(String name) {
char[] cs=name.toCharArray();
cs[0]-=32;
return String.valueOf(cs);
}