public static void main(String[] args) throws IntrospectionException {
    BeanInfo beanInfo = Introspector.getBeanInfo(User.class);

    System.out.println("==>MethodDescriptor");
    MethodDescriptor[] methodDescs = beanInfo.getMethodDescriptors();
    for (MethodDescriptor method : methodDescs) {
      System.out.println(method.getName());
      System.out.println(method.getDisplayName());
      System.out.println(method.getShortDescription());
      System.out.println(method.getValue("getName"));

      System.out.println("==>MethodDescriptor/ReflectionMethod");
      Method reflectMethod = method.getMethod();
      System.out.println(reflectMethod.getName());

      System.out.println("==>MethodDescriptor/ParameterDescriptor");
      ParameterDescriptor[] paramDescs = method.getParameterDescriptors();
      if (paramDescs != null) {
        for (ParameterDescriptor paramDesc : paramDescs) {
          System.out.println(paramDesc.getName());
          System.out.println(paramDesc.getDisplayName());
          System.out.println(paramDesc.getShortDescription());
          System.out.println(paramDesc.getValue("name"));
        }
      }
    }
  }
 /**
  * Gets the firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) method
  * descriptor.
  *
  * @return java.beans.MethodDescriptor
  */
 public java.beans.MethodDescriptor
     firePropertyChange_javalangString_javalangObject_javalangObjectMethodDescriptor() {
   java.beans.MethodDescriptor aDescriptor = null;
   try {
     /* Create and return the firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) method descriptor. */
     java.lang.reflect.Method aMethod = null;
     try {
       /* Attempt to find the method using getMethod with parameter types. */
       java.lang.Class aParameterTypes[] = {
         java.lang.String.class, java.lang.Object.class, java.lang.Object.class
       };
       aMethod = getBeanClass().getMethod("firePropertyChange", aParameterTypes);
     } catch (java.lang.Throwable exception) {
       /* Since getMethod failed, call findMethod. */
       handleException(exception);
       aMethod = findMethod(getBeanClass(), "firePropertyChange", 3);
     }
     ;
     try {
       /* Try creating the method descriptor with parameter descriptors. */
       java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
       aParameterDescriptor1.setName("arg1");
       aParameterDescriptor1.setDisplayName("propertyName");
       java.beans.ParameterDescriptor aParameterDescriptor2 = new java.beans.ParameterDescriptor();
       aParameterDescriptor2.setName("arg2");
       aParameterDescriptor2.setDisplayName("oldValue");
       java.beans.ParameterDescriptor aParameterDescriptor3 = new java.beans.ParameterDescriptor();
       aParameterDescriptor3.setName("arg3");
       aParameterDescriptor3.setDisplayName("newValue");
       java.beans.ParameterDescriptor aParameterDescriptors[] = {
         aParameterDescriptor1, aParameterDescriptor2, aParameterDescriptor3
       };
       aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
     } catch (java.lang.Throwable exception) {
       /* Try creating the method descriptor without parameter descriptors. */
       handleException(exception);
       aDescriptor = new java.beans.MethodDescriptor(aMethod);
     }
     ;
     /* aDescriptor.setDisplayName("firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)"); */
     /* aDescriptor.setShortDescription("firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)"); */
     /* aDescriptor.setExpert(false); */
     /* aDescriptor.setHidden(false); */
     /* aDescriptor.setValue("preferred", new java.lang.Boolean(false)); */
   } catch (java.lang.Throwable exception) {
     handleException(exception);
   }
   ;
   return aDescriptor;
 }
 /**
  * Gets the setAddressDataSelectionModel(com.javadude.articles.vaddmvc2.AddressDataSelectionModel)
  * method descriptor.
  *
  * @return java.beans.MethodDescriptor
  */
 public java.beans.MethodDescriptor
     setAddressDataSelectionModel_comjavadudearticlesvaddmvc2AddressDataSelectionModelMethodDescriptor() {
   java.beans.MethodDescriptor aDescriptor = null;
   try {
     /* Create and return the setAddressDataSelectionModel(com.javadude.articles.vaddmvc2.AddressDataSelectionModel) method descriptor. */
     java.lang.reflect.Method aMethod = null;
     try {
       /* Attempt to find the method using getMethod with parameter types. */
       java.lang.Class aParameterTypes[] = {
         com.javadude.articles.vaddmvc2.AddressDataSelectionModel.class
       };
       aMethod = getBeanClass().getMethod("setAddressDataSelectionModel", aParameterTypes);
     } catch (java.lang.Throwable exception) {
       /* Since getMethod failed, call findMethod. */
       handleException(exception);
       aMethod = findMethod(getBeanClass(), "setAddressDataSelectionModel", 1);
     }
     ;
     try {
       /* Try creating the method descriptor with parameter descriptors. */
       java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
       aParameterDescriptor1.setName("arg1");
       aParameterDescriptor1.setDisplayName("arg1");
       java.beans.ParameterDescriptor aParameterDescriptors[] = {aParameterDescriptor1};
       aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
     } catch (java.lang.Throwable exception) {
       /* Try creating the method descriptor without parameter descriptors. */
       handleException(exception);
       aDescriptor = new java.beans.MethodDescriptor(aMethod);
     }
     ;
     /* aDescriptor.setDisplayName("setAddressDataSelectionModel(com.javadude.articles.vaddmvc2.AddressDataSelectionModel)"); */
     /* aDescriptor.setShortDescription("setAddressDataSelectionModel(com.javadude.articles.vaddmvc2.AddressDataSelectionModel)"); */
     /* aDescriptor.setExpert(false); */
     /* aDescriptor.setHidden(false); */
     /* aDescriptor.setValue("preferred", new java.lang.Boolean(false)); */
   } catch (java.lang.Throwable exception) {
     handleException(exception);
   }
   ;
   return aDescriptor;
 }
 /**
  * Gets the propertyChange.propertyChange(java.beans.PropertyChangeEvent) method descriptor.
  *
  * @return java.beans.MethodDescriptor
  */
 public java.beans.MethodDescriptor
     propertyChangepropertyChange_javabeansPropertyChangeEventMethodEventDescriptor() {
   java.beans.MethodDescriptor aDescriptor = null;
   try {
     /* Create and return the propertyChange.propertyChange(java.beans.PropertyChangeEvent) method descriptor. */
     java.lang.reflect.Method aMethod = null;
     try {
       /* Attempt to find the method using getMethod with parameter types. */
       java.lang.Class aParameterTypes[] = {java.beans.PropertyChangeEvent.class};
       aMethod =
           (java.beans.PropertyChangeListener.class).getMethod("propertyChange", aParameterTypes);
     } catch (java.lang.Throwable exception) {
       /* Since getMethod failed, call findMethod. */
       handleException(exception);
       aMethod = findMethod((java.beans.PropertyChangeListener.class), "propertyChange", 1);
     }
     ;
     try {
       /* Try creating the method descriptor with parameter descriptors. */
       java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
       aParameterDescriptor1.setName("arg1");
       aParameterDescriptor1.setDisplayName("evt");
       java.beans.ParameterDescriptor aParameterDescriptors[] = {aParameterDescriptor1};
       aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
     } catch (java.lang.Throwable exception) {
       /* Try creating the method descriptor without parameter descriptors. */
       handleException(exception);
       aDescriptor = new java.beans.MethodDescriptor(aMethod);
     }
     ;
     /* aDescriptor.setDisplayName("propertyChange"); */
     /* aDescriptor.setShortDescription("propertyChange"); */
     /* aDescriptor.setExpert(false); */
     /* aDescriptor.setHidden(false); */
     /* aDescriptor.setValue("preferred", new java.lang.Boolean(false)); */
   } catch (java.lang.Throwable exception) {
     handleException(exception);
   }
   ;
   return aDescriptor;
 }
 /**
  * Gets the main(java.lang.String[]) method descriptor.
  *
  * @return java.beans.MethodDescriptor
  */
 public java.beans.MethodDescriptor main_javalangString__MethodDescriptor() {
   java.beans.MethodDescriptor aDescriptor = null;
   try {
     /* Create and return the main(java.lang.String[]) method descriptor. */
     java.lang.reflect.Method aMethod = null;
     try {
       /* Attempt to find the method using getMethod with parameter types. */
       java.lang.Class aParameterTypes[] = {java.lang.String[].class};
       aMethod = getBeanClass().getMethod("main", aParameterTypes);
     } catch (java.lang.Throwable exception) {
       /* Since getMethod failed, call findMethod. */
       handleException(exception);
       aMethod = findMethod(getBeanClass(), "main", 1);
     }
     ;
     try {
       /* Try creating the method descriptor with parameter descriptors. */
       java.beans.ParameterDescriptor aParameterDescriptor1 = new java.beans.ParameterDescriptor();
       aParameterDescriptor1.setName("arg1");
       aParameterDescriptor1.setDisplayName("args");
       java.beans.ParameterDescriptor aParameterDescriptors[] = {aParameterDescriptor1};
       aDescriptor = new java.beans.MethodDescriptor(aMethod, aParameterDescriptors);
     } catch (java.lang.Throwable exception) {
       /* Try creating the method descriptor without parameter descriptors. */
       handleException(exception);
       aDescriptor = new java.beans.MethodDescriptor(aMethod);
     }
     ;
     /* aDescriptor.setDisplayName("main(java.lang.String[])"); */
     /* aDescriptor.setShortDescription("main(java.lang.String[])"); */
     /* aDescriptor.setExpert(false); */
     /* aDescriptor.setHidden(false); */
     /* aDescriptor.setValue("preferred", new java.lang.Boolean(false)); */
   } catch (java.lang.Throwable exception) {
     handleException(exception);
   }
   ;
   return aDescriptor;
 }
示例#6
0
    private ParameterInfo(ResourceInfo.MethodInfo info, int idx, ParameterDescriptor old) {
      this.info = info;
      this.idx = idx;
      setExpert(old.isExpert());
      setHidden(old.isHidden());
      setPreferred(old.isPreferred());
      setName(old.getName());
      setShortDescription(old.getShortDescription());
      setDisplayName(old.getDisplayName());

      Enumeration<String> names = old.attributeNames();
      while (names.hasMoreElements()) {
        String name = names.nextElement();
        setValue(name, old.getValue(name));
      }
    }