예제 #1
0
 private void printArrayProperty(StringBuffer sb, String prefix, Object array) {
   int length = Array.getLength(array);
   for (int i = 0; i < length; i++) {
     Object obj = Array.get(array, i);
     printProperty(sb, prefix + "[" + i + "]", obj);
   }
 }
예제 #2
0
 /**
  * Returns the String representation of the bean given in the constructor.
  *
  * <p>
  *
  * @param prefix to use for bean properties.
  * @return bean object String representation.
  */
 private String toString(String prefix) {
   StringBuffer sb = new StringBuffer(128);
   try {
     PropertyDescriptor[] pds = BeanIntrospector.getPropertyDescriptors(_beanClass);
     if (pds != null) {
       for (int i = 0; i < pds.length; i++) {
         String pName = pds[i].getName();
         Method pReadMethod = pds[i].getReadMethod();
         if (pReadMethod != null
             && // ensure it has a getter method
             pReadMethod.getDeclaringClass() != Object.class
             && // filter Object.class getter methods
             pReadMethod.getParameterTypes().length
                 == 0) { // filter getter methods that take parameters
           Object value = pReadMethod.invoke(_obj, NO_PARAMS);
           printProperty(sb, prefix + "." + pName, value);
         }
       }
     }
   } catch (Exception ex) {
     sb.append(
         "\n\nEXCEPTION: Could not complete "
             + _obj.getClass()
             + ".toString(): "
             + ex.getMessage()
             + "\n");
   }
   return sb.toString();
 }