Esempio n. 1
0
  public void printAll(Class c) {

    Constructor[] cs = this.getAllConstructorsFromClass(c);
    System.out.println("  Constructors:");
    for (Constructor constructor : cs) {
      System.out.print("    " + constructor);
      if (constructor.getDeclaringClass() != c)
        System.out.println(" (inherited from " + constructor.getDeclaringClass().getName() + ")");
      else System.out.println();
    }

    System.out.println("  Methods:");
    Method[] ms = this.getAllMethodsFromClass(c);
    for (Method method : ms) {
      System.out.print("    " + method);
      if (method.getDeclaringClass() != c)
        System.out.println(" (inherited from " + method.getDeclaringClass().getName() + ")");
      else System.out.println();
    }

    System.out.println("  Classes:");
    Class[] cls = this.getClassesFromClass(c);
    for (Class class1 : cls) {
      System.out.println("    " + class1);
    }

    System.out.println("  Fields:");
    Field[] fs = this.getFieldsFromClass(c);
    for (Field field : fs) {
      System.out.print("    " + field);
      if (field.getDeclaringClass() != c)
        System.out.println(" (inherited from " + field.getDeclaringClass().getName() + ")");
      else System.out.println();
    }

    System.out.println("  Interfaces:");
    Class[] is = this.getInterfacesFromClass(c);
    for (Class class2 : is) {
      System.out.println("    " + class2);
    }

    System.out.println("  Local Methods:");
    Method[] mls = this.getLocalMethodsFromClass(c);
    for (Method method2 : mls) {
      System.out.print("    " + method2);
      if (method2.getDeclaringClass() != c)
        System.out.println(" (inherited from " + method2.getDeclaringClass().getName() + ")");
      else System.out.println();
    }
  }
 /** {@inheritDoc} */
 public T convert(F from) {
   Object[] initArgs = new Object[argumentConverters.size()];
   int i = 0;
   for (ArgumentConverter<F, Object> argumentConverter : argumentConverters) {
     initArgs[i++] = argumentConverter.convert(from);
   }
   try {
     return constructor.newInstance(initArgs);
   } catch (Exception e) {
     throw new IntrospectionException(
         "Unable to create an object of class " + constructor.getDeclaringClass().getName(), e);
   }
 }
Esempio n. 3
0
 public static <T> T newInstance(
     Constructor<T> constructor, boolean strict, Object... parameters) {
   if (!strict) parameters = convertArray(parameters, constructor.getParameterTypes());
   Class<T> type = constructor.getDeclaringClass();
   if (deprecated(type))
     escalator.escalate(
         "Instantiating a deprecated class: " + type.getName(), BeanUtil.class, null);
   try {
     return constructor.newInstance(parameters);
   } catch (InstantiationException e) {
     throw ExceptionMapper.configurationException(e, type);
   } catch (IllegalAccessException e) {
     throw ExceptionMapper.configurationException(e, type);
   } catch (InvocationTargetException e) {
     throw ExceptionMapper.configurationException(e, type);
   }
 }