Ejemplo n.º 1
0
 public static Class getNestedPropertyType(DynaClass bean, String name)
     throws IllegalAccessException, InvocationTargetException, NoSuchMethodException,
         ClassNotFoundException, NoSuchFieldException {
   // Resolve nested references
   while (resolver.hasNested(name)) {
     String next = resolver.next(name);
     if (resolver.isIndexed(next) || resolver.isMapped(next)) {
       String property = resolver.getProperty(next);
       Class<?> clazz = Class.forName(bean.getName());
       Class<?> detectTypeParameter =
           detectTypeParameter(clazz, property, resolver.isIndexed(name) ? 0 : 1);
       bean = WrapDynaClass.createDynaClass(detectTypeParameter);
       return getNestedPropertyType(bean, resolver.remove(name));
     }
     DynaProperty db = bean.getDynaProperty(next);
     bean = WrapDynaClass.createDynaClass(db.getType());
     name = resolver.remove(name);
   }
   if (resolver.isMapped(name) || resolver.isIndexed(name)) {
     String property = resolver.getProperty(name);
     Class<?> clazz = Class.forName(bean.getName());
     return detectTypeParameter(clazz, property, resolver.isIndexed(name) ? 0 : 1);
   }
   Class<?> type = bean.getDynaProperty(name).getType();
   return type;
 }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public String toString() {
    StringBuffer result = new StringBuffer();
    DynaClass type = getDynaClass();
    DynaProperty[] props = type.getDynaProperties();

    result.append(type.getName());
    result.append(": ");
    for (int idx = 0; idx < props.length; idx++) {
      if (idx > 0) {
        result.append(", ");
      }
      result.append(props[idx].getName());
      result.append(" = ");
      result.append(get(props[idx].getName()));
    }
    return result.toString();
  }