1 package jodd.bean.modifiers; 2 3 import jodd.bean.BeanUtil; 4 5 8 public class TrimStrings implements jodd.bean.PropertyCallback { 9 10 public void onProperty(Object obj, String name) { 11 if (obj != null) { 12 Object value = BeanUtil.getProperty(obj, name); 13 if (value != null) { 14 if (value instanceof String) { value = ((String)value).trim(); 16 BeanUtil.setProperty(obj, name, value); 17 } else if (value.getClass().isArray() == true) { 18 if (value instanceof String[]) { String[] valueArray = (String[]) value; 20 for (int i = 0; i < valueArray.length; i++) { 21 valueArray[i] = valueArray[i].trim(); 22 } 23 } else { 24 Object[] valueArray = (Object[]) value; for (int i = 0; i < valueArray.length; i++) { 26 if (valueArray[i] instanceof String) { 27 valueArray[i] = ((String)valueArray[i]).trim(); 28 } 29 } 30 } 31 } 32 } 33 } 34 return; 35 } 36 } 37 | Popular Tags |