List of usage examples for java.beans IntrospectionException toString
public String toString()
From source file:BeanUtility.java
/** This method takes a JavaBean and generates a standard toString() type result for it. * @param o JavaBean object to stringinate * @return STRINGIATION! Stringingating the countryside. Stringinating all the peasants. */// www . ja v a 2s . c o m public static String beanToString(Object o) { StringBuffer result = new StringBuffer(); if (o == null) return "--- null"; result.append("--- begin"); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\r\n"); try { PropertyDescriptor[] pds = Introspector.getBeanInfo(o.getClass()).getPropertyDescriptors(); for (int pdi = 0; pdi < pds.length; pdi++) { try { result.append( "Property: " + pds[pdi].getName() + " Value: " + pds[pdi].getReadMethod().invoke(o)); } catch (IllegalAccessException iae) { result.append("Property: " + pds[pdi].getName() + " (Illegal Access to Value) "); } catch (InvocationTargetException iae) { result.append( "Property: " + pds[pdi].getName() + " (InvocationTargetException) " + iae.toString()); } catch (Exception e) { result.append("Property: " + pds[pdi].getName() + " (Other Exception )" + e.toString()); } result.append("\r\n"); } } catch (IntrospectionException ie) { result.append("Introspection Exception: " + ie.toString()); result.append("\r\n"); } result.append("--- end "); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\n"); return result.toString(); }
From source file:com.kangdainfo.common.util.BeanUtil.java
/** This method takes a JavaBean and generates a standard toString() type result for it. * @param o JavaBean object to stringinate * @return STRINGIATION! Stringingating the countryside. Stringinating all the peasants. *///from ww w.ja v a 2 s . co m public static String beanToString(Object o) { StringBuffer result = new StringBuffer(); if (o == null) { return "--- null"; } result.append("--- begin"); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\r\n"); try { PropertyDescriptor[] pds = Introspector.getBeanInfo(o.getClass()).getPropertyDescriptors(); for (int pdi = 0; pdi < pds.length; pdi++) { try { result.append( "Property: " + pds[pdi].getName() + " Value: " + pds[pdi].getReadMethod().invoke(o)); } catch (IllegalAccessException iae) { result.append("Property: " + pds[pdi].getName() + " (Illegal Access to Value) "); } catch (InvocationTargetException iae) { result.append( "Property: " + pds[pdi].getName() + " (InvocationTargetException) " + iae.toString()); } catch (Exception e) { result.append("Property: " + pds[pdi].getName() + " (Other Exception )" + e.toString()); } result.append("\r\n"); } } catch (IntrospectionException ie) { result.append("Introspection Exception: " + ie.toString()); result.append("\r\n"); } result.append("--- end "); result.append(o.getClass().getName()); result.append(" hash: "); result.append(o.hashCode()); result.append("\n"); return result.toString(); }