1 25 26 package net.killingar; 27 28 import java.beans.PropertyDescriptor ; 29 import java.lang.reflect.Method ; 30 31 public class BeanUtil extends webwork.util.BeanUtil 32 { 33 private static final Object [] readParameters = new Object [0]; 34 35 public static Object getProperty(String key, Object from) throws IllegalArgumentException 36 { 37 try 38 { 39 PropertyDescriptor pdFrom = new PropertyDescriptor (key, from.getClass()); 40 41 Method readMethod = pdFrom.getReadMethod(); 42 if (readMethod != null) 43 return pdFrom.getReadMethod().invoke(from, readParameters); 44 45 throw new IllegalArgumentException ("Bean copy failed, read method for "+key+" not found"); 46 } 47 catch (Exception e) 48 { 49 e.printStackTrace(); 50 throw new IllegalArgumentException ("Bean copy failed:" + e); 51 } 52 } 53 } | Popular Tags |