public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor _toolTipText =
          new PropertyDescriptor("toolTipText", beanClass, "getToolTipText", "setToolTipText");
      _toolTipText.setDisplayName("toolTipText");
      _toolTipText.setShortDescription("toolTipText");
      PropertyDescriptor _fillColor =
          new PropertyDescriptor("fillColor", beanClass, "getFillColor", "setFillColor");
      _fillColor.setDisplayName("fillColor");
      _fillColor.setShortDescription("fillColor");
      _fillColor.setPropertyEditorClass(GeColorEditor.class);
      PropertyDescriptor _borderColor =
          new PropertyDescriptor("borderColor", beanClass, "getBorderColor", "setBorderColor");
      _borderColor.setDisplayName("borderColor");
      _borderColor.setShortDescription("borderColor");
      _borderColor.setPropertyEditorClass(GeColorEditor.class);
      PropertyDescriptor _colorTone =
          new PropertyDescriptor("colorTone", beanClass, "getColorTone", "setColorTone");
      _colorTone.setDisplayName("colorTone");
      _colorTone.setShortDescription("colorTone");
      _colorTone.setPropertyEditorClass(GeColorToneEditor.class);
      PropertyDescriptor _colorShift =
          new PropertyDescriptor("colorShift", beanClass, "getColorShift", "setColorShift");
      _colorShift.setDisplayName("colorShift");
      _colorShift.setShortDescription("colorShift");
      _colorShift.setPropertyEditorClass(GeColorShiftEditor.class);
      PropertyDescriptor _colorBrightness =
          new PropertyDescriptor(
              "colorBrightness", beanClass, "getColorBrightness", "setColorBrightness");
      _colorBrightness.setDisplayName("colorBrightness");
      _colorBrightness.setShortDescription("colorBrightness");
      _colorBrightness.setPropertyEditorClass(GeColorBrightnessEditor.class);
      PropertyDescriptor _colorIntensity =
          new PropertyDescriptor(
              "colorIntensity", beanClass, "getColorIntensity", "setColorIntensity");
      _colorIntensity.setDisplayName("colorIntensity");
      _colorIntensity.setShortDescription("colorIntensity");
      _colorIntensity.setPropertyEditorClass(GeColorIntensityEditor.class);
      PropertyDescriptor _rotate =
          new PropertyDescriptor("rotate", beanClass, "getRotate", "setRotate");
      _rotate.setDisplayName("rotate");
      _rotate.setShortDescription("rotate");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _toolTipText,
            _fillColor,
            _borderColor,
            _colorTone,
            _colorShift,
            _colorBrightness,
            _colorIntensity,
            _rotate
          };
      return pds;

    } catch (IntrospectionException ex) {
      ex.printStackTrace();
      return null;
    }
  }
Example #2
0
 @Override
 public String buildPrimaryConditionSql(Object entity) throws SQLException {
   AnnotationUtil annotationUtil = AnnotationUtil.getInstance();
   Map<String, Object> primary = annotationUtil.getPrimaryValue(entity);
   String sql = "";
   Map<String, PropertyDescriptor> beanMap = null;
   try {
     beanMap = annotationUtil.getBeanInfo(entity.getClass());
   } catch (IntrospectionException e1) {
     throw new SQLException("查询失败:" + e1.getMessage());
   }
   Set<String> primaryNames = primary.keySet();
   String joinWord = " where ";
   for (Iterator<String> it = primaryNames.iterator(); it.hasNext(); ) {
     String primaryName = it.next();
     if (primary.get(primaryName) == null) {
       continue;
     }
     if (sql.indexOf("where") != -1) {
       joinWord = " and ";
     }
     // 获取主键的数据类型
     String typeName = beanMap.get(primaryName).getPropertyType().getSimpleName().toLowerCase();
     // 若为字符类型
     sql += joinWord;
     if (typeName.equals("string")) {
       sql += primaryName + "='" + primary.get(primaryName) + "'";
     } else {
       sql += primaryName + "=" + primary.get(primaryName);
     }
   }
   return sql;
 }
  // ***** *****
  public MethodDescriptor[] getMethodDescriptors() {
    try {
      MethodDescriptor md1 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "processRequest"));
      String procReqDesc = res.getString("procReqDesc");
      md1.setShortDescription(procReqDesc);

      MethodDescriptor md2 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "doHPTransaction"));
      String doHPTransDesc = res.getString("doHPTransDesc");
      md2.setShortDescription(doHPTransDesc);

      // method for receiving event
      MethodDescriptor md3 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "hPubStartPerformed"));
      String hPubStartPerfDesc = res.getString("hPubStartPerfDesc");
      md3.setShortDescription(hPubStartPerfDesc);

      MethodDescriptor[] arrayOfMDs = {md1, md2, md3};
      return arrayOfMDs;

    } catch (IntrospectionException e) {
      e.printStackTrace();
    }
    return null;
  }
Example #4
0
 /**
  * Wrap the given {@link BeanInfo} instance; copy all its existing property descriptors locally,
  * wrapping each in a custom {@link SimpleIndexedPropertyDescriptor indexed} or {@link
  * SimplePropertyDescriptor non-indexed} {@code PropertyDescriptor} variant that bypasses default
  * JDK weak/soft reference management; then search through its method descriptors to find any
  * non-void returning write methods and update or create the corresponding {@link
  * PropertyDescriptor} for each one found.
  *
  * @param delegate the wrapped {@code BeanInfo}, which is never modified
  * @throws IntrospectionException if any problems occur creating and adding new property
  *     descriptors
  * @see #getPropertyDescriptors()
  */
 public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
   this.delegate = delegate;
   for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
     try {
       this.propertyDescriptors.add(
           pd instanceof IndexedPropertyDescriptor
               ? new SimpleIndexedPropertyDescriptor((IndexedPropertyDescriptor) pd)
               : new SimplePropertyDescriptor(pd));
     } catch (IntrospectionException ex) {
       // Probably simply a method that wasn't meant to follow the JavaBeans pattern...
       if (logger.isDebugEnabled()) {
         logger.debug("Ignoring invalid bean property '" + pd.getName() + "': " + ex.getMessage());
       }
     }
   }
   MethodDescriptor[] methodDescriptors = delegate.getMethodDescriptors();
   if (methodDescriptors != null) {
     for (Method method : findCandidateWriteMethods(methodDescriptors)) {
       try {
         handleCandidateWriteMethod(method);
       } catch (IntrospectionException ex) {
         // We're only trying to find candidates, can easily ignore extra ones here...
         if (logger.isDebugEnabled()) {
           logger.debug("Ignoring candidate write method [" + method + "]: " + ex.getMessage());
         }
       }
     }
   }
 }
  /*lazy PropertyDescriptor*/
  private static PropertyDescriptor[] getPdescriptor() {
    PropertyDescriptor[] properties = new PropertyDescriptor[2];

    try {
      properties[PROPERTY_columnName] =
          new PropertyDescriptor(
              "columnName",
              com.openitech.db.components.JDbStatusBox.class,
              "getColumnName",
              "setColumnName"); // NOI18N
      properties[PROPERTY_columnName].setPreferred(true);
      properties[PROPERTY_dataSource] =
          new PropertyDescriptor(
              "dataSource",
              com.openitech.db.components.JDbStatusBox.class,
              "getDataSource",
              "setDataSource"); // NOI18N
      properties[PROPERTY_dataSource].setPreferred(true);
    } catch (IntrospectionException e) {
      Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.getMessage(), e);
    } // GEN-HEADEREND:Properties

    // Here you can add code for customizing the properties array.

    return properties;
  } // GEN-LAST:Properties
  /**
   * Load bean information into a cache, because this operation will be slow.
   *
   * @param clazz
   * @throws IntrospectionException
   */
  protected PropertyDescriptor[] loadIntrospectionForClass(Class<?> clazz) {
    if (null == clazz) {
      throw new IllegalArgumentException("No bean class specified");
    }

    PropertyDescriptor[] descriptors = null;
    descriptors = introspectionCache.get(clazz);
    if (descriptors != null) {
      return descriptors;
    }

    BeanInfo beanInfo = null;
    try {
      beanInfo = Introspector.getBeanInfo(clazz);

      descriptors = beanInfo.getPropertyDescriptors();
      if (null == descriptors) {
        descriptors = new PropertyDescriptor[0];
      }
    } catch (IntrospectionException e) {
      e.printStackTrace();
      descriptors = new PropertyDescriptor[0];
    }

    introspectionCache.put(clazz, descriptors);
    return descriptors;
  }
  public void setBeanInfo() {
    BeanInfo info = null;
    try {
      info = Introspector.getBeanInfo(bean.getClass());
    } catch (IntrospectionException ex) {
      ex.printStackTrace();
    }

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
      if (!pd.getName().equals("class")) {
        try {
          Object value = null;
          if (properties.get(pd.getName()) != null) {
            value = properties.get(pd.getName());
            if (value.equals("false") || value.equals("true")) {
              pd.getWriteMethod().invoke(bean, new Object[] {Boolean.valueOf((String) value)});
            } else {
              pd.getWriteMethod().invoke(bean, new Object[] {value});
            }
          } else {
            value = pd.getReadMethod().invoke(bean, new Object[] {});
            pd.getWriteMethod().invoke(bean, new Object[] {value});
          }
        } catch (IllegalArgumentException ex) {
          ex.printStackTrace();
        } catch (IllegalAccessException ex) {
          ex.printStackTrace();
        } catch (InvocationTargetException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor rootDirStr =
          new PropertyDescriptor("rootDirStr", getBeanDescriptor().getBeanClass());
      rootDirStr.setBound(true);
      rootDirStr.setPropertyEditorClass(JTextFieldEditor.class);
      rootDirStr.setDisplayName("<html><font color='green'>root dir:");
      rootDirStr.setShortDescription("The directory root to search for change sets. ");

      PropertyDescriptor validateChangeSets =
          new PropertyDescriptor("validateChangeSets", getBeanDescriptor().getBeanClass());
      validateChangeSets.setBound(true);
      validateChangeSets.setPropertyEditorClass(CheckboxEditor.class);
      validateChangeSets.setDisplayName("<html><font color='green'>validate:");
      validateChangeSets.setShortDescription("Select if you want to validate change sets. ");

      PropertyDescriptor validators =
          new PropertyDescriptor("validators", getBeanDescriptor().getBeanClass());
      validators.setBound(true);
      validators.setPropertyEditorClass(JTextFieldEditor.class);
      validators.setDisplayName("<html><font color='green'>validators:");
      validators.setShortDescription("The validators used on the change sets. ");

      PropertyDescriptor rv[] = {rootDirStr, validateChangeSets, validators};
      return rv;
    } catch (IntrospectionException e) {
      throw new Error(e.toString());
    }
  }
    public ComponentDomainClass(Class type) {
      super(type, "");

      PropertyDescriptor[] descriptors;

      try {
        descriptors = java.beans.Introspector.getBeanInfo(type).getPropertyDescriptors();
      } catch (IntrospectionException e) {
        throw new GrailsDomainException(
            "Failed to use class ["
                + type
                + "] as a component. Cannot introspect! "
                + e.getMessage());
      }

      List tmp =
          (List)
              getPropertyOrStaticPropertyOrFieldValue(
                  GrailsDomainClassProperty.TRANSIENT, List.class);
      if (tmp != null) this.transients = tmp;
      this.properties = createDomainClassProperties(this, descriptors);
      try {
        this.constraints =
            GrailsDomainConfigurationUtil.evaluateConstraints(
                getReference().getWrappedInstance(), properties);
      } catch (IntrospectionException e) {
        LOG.error(
            "Error reading embedded component [" + getClazz() + "] constraints: " + e.getMessage(),
            e);
      }
    }
  /**
   * Descripción de Método
   *
   * @return
   */
  public PropertyDescriptor[] getPropertyDescriptors() {

    try {

      PropertyDescriptor _background =
          new PropertyDescriptor("background", beanClass, null, "setBackground");
      PropertyDescriptor _display =
          new PropertyDescriptor("display", beanClass, "getDisplay", null);
      PropertyDescriptor _mandatory =
          new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory");
      PropertyDescriptor _readWrite =
          new PropertyDescriptor("readWrite", beanClass, "isReadWrite", "setReadWrite");
      PropertyDescriptor _value =
          new PropertyDescriptor("value", beanClass, "getValue", "setValue");
      PropertyDescriptor _visible =
          new PropertyDescriptor("visible", beanClass, null, "setVisible");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _background, _display, _mandatory, _readWrite, _value, _visible
          };

      return pds;

    } catch (IntrospectionException ex) {

      ex.printStackTrace();

      return null;
    }
  }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor _background =
          new PropertyDescriptor("background", beanClass, null, "setBackground");
      PropertyDescriptor _border = new PropertyDescriptor("border", beanClass, null, "setBorder");
      PropertyDescriptor _display =
          new PropertyDescriptor("display", beanClass, "getDisplay", null);
      PropertyDescriptor _editable =
          new PropertyDescriptor("editable", beanClass, "isEditable", "setEditable");
      PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, null, "setFont");
      PropertyDescriptor _foreground =
          new PropertyDescriptor("foreground", beanClass, null, "setForeground");
      PropertyDescriptor _mandatory =
          new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory");
      PropertyDescriptor _value =
          new PropertyDescriptor("value", beanClass, "getValue", "setValue");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _background, _border, _display, _editable, _font, _foreground, _mandatory, _value
          };
      return pds;

    } catch (IntrospectionException ex) {
      ex.printStackTrace();
      return null;
    }
  }
Example #12
0
  @Override
  public PropertyDescriptor[] getPropertyDescriptors() {
    List<PropertyDescriptor> descs = new LinkedList<PropertyDescriptor>();
    Field[] fields = OFMatch.class.getDeclaredFields();
    String name;
    for (int i = 0; i < fields.length; i++) {
      int mod = fields[i].getModifiers();
      if (Modifier.isFinal(mod)
          || // don't expose static or final fields
          Modifier.isStatic(mod)) continue;

      name = fields[i].getName();
      Class<?> type = fields[i].getType();

      try {
        descs.add(
            new PropertyDescriptor(
                name, name2getter(OFMatch.class, name), name2setter(OFMatch.class, name, type)));
      } catch (IntrospectionException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
      }
    }

    return descs.toArray(new PropertyDescriptor[0]);
  }
  /**
   * Implementation of getPropertyDescriptors.
   *
   * @see java.beans.BeanInfo#getPropertyDescriptors()
   */
  public PropertyDescriptor[] getPropertyDescriptors() {
    PropertyDescriptor[] pd2 = super.getPropertyDescriptors();
    ResourceBundle resourceBundle = getResourceBundle(PointLineAbstractValidation.class);

    if (pd2 == null) {
      pd2 = new PropertyDescriptor[0];
    }

    PropertyDescriptor[] pd = new PropertyDescriptor[pd2.length + 2];
    int i = 0;

    for (; i < pd2.length; i++) pd[i] = pd2[i];

    try {
      pd[i] =
          createPropertyDescriptor(
              "restrictedLineTypeRef", PointLineAbstractValidation.class, resourceBundle);
      pd[i].setExpert(false);
      pd[i + 1] =
          createPropertyDescriptor(
              "pointTypeRef", PointLineAbstractValidation.class, resourceBundle);
      pd[i + 1].setExpert(false);
    } catch (IntrospectionException e) {
      pd = pd2;

      // TODO error, log here
      e.printStackTrace();
    }

    return pd;
  }
 public PropertyDescriptor[] getPropertyDescriptors() {
   try {
     PropertyDescriptor _domainId =
         new PropertyDescriptor("domainId", beanClass, "getDomainId", "setDomainId");
     PropertyDescriptor _leftMargin =
         new PropertyDescriptor("leftMargin", beanClass, "getLeftMargin", "setLeftMargin");
     PropertyDescriptor _rightMargin =
         new PropertyDescriptor("rightMargin", beanClass, "getRightMargin", "setRightMargin");
     PropertyDescriptor _topMargin =
         new PropertyDescriptor("topMargin", beanClass, "getTopMargin", "setTopMargin");
     PropertyDescriptor _bottomMargin =
         new PropertyDescriptor("bottomMargin", beanClass, "getBottomMargin", "setBottomMargin");
     PropertyDescriptor _columnName =
         new PropertyDescriptor("columnName", beanClass, "getColumnName", "setColumnName");
     _columnName.setPropertyEditorClass(AttributeNameEditor.class);
     PropertyDescriptor[] pds =
         new PropertyDescriptor[] {
           _bottomMargin, _columnName, _domainId, _leftMargin, _rightMargin, _topMargin
         };
     return pds;
   } catch (IntrospectionException ex) {
     ex.printStackTrace();
     return null;
   }
 }
 public BeanInfo[] getAdditionalBeanInfo() {
   try {
     // Do not pick up general stuff from ProcessExecutor:
     return new BeanInfo[] {Introspector.getBeanInfo(org.openide.execution.Executor.class)};
   } catch (IntrospectionException ie) {
     if (Boolean.getBoolean("netbeans.debug.exceptions")) ie.printStackTrace();
     return null;
   }
 }
 public BeanInfo[] getAdditionalBeanInfo() {
   Class superclass = beanClass.getSuperclass();
   try {
     BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);
     return new BeanInfo[] {superBeanInfo};
   } catch (IntrospectionException ex) {
     ex.printStackTrace();
     return null;
   }
 }
Example #17
0
 /**
  * 获取PropertyDescriptor[]对象
  *
  * @param clazz : 对象
  */
 public static <T> PropertyDescriptor[] getPropertyDescriptor(Class<T> clazz) {
   BeanInfo bi = null;
   try {
     bi = Introspector.getBeanInfo(clazz, Object.class);
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
   PropertyDescriptor[] props = bi.getPropertyDescriptors();
   return props;
 }
 public void refreshConstraints() {
   try {
     GrailsDomainClassProperty[] props = getPersistentProperties();
     this.constraints =
         GrailsDomainConfigurationUtil.evaluateConstraints(
             getReference().getWrappedInstance(), props);
   } catch (IntrospectionException e) {
     LOG.error("Error reading class [" + getClazz() + "] constraints: " + e.getMessage(), e);
   }
 }
Example #19
0
 /** @see java.beans.BeanInfo#getPropertyDescriptors() */
 public PropertyDescriptor[] getPropertyDescriptors() {
   try {
     return new PropertyDescriptor[] {
       describeAttribute("id", BEAN), describeAttribute("schemaLocation", BEAN)
     };
   } catch (IntrospectionException e) {
     Gloze.logger.error(e.getMessage());
     return null;
   }
 }
 private static void initializeDescriptors() {
   try {
     descriptors =
         new PropertyDescriptor[] {
           createDescriptor(
               "displayName", "getDisplayName", null, "PROP_Name", "HINT_Name"), // NOI18N
         };
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
 }
Example #21
0
  /**
   * Reads property descriptors of class
   *
   * @param clazz Class for which we are getting property descriptors
   * @return Array of Class PropertyDescriptors
   */
  public static PropertyDescriptor[] propertyDescriptors(Class<?> clazz) {
    BeanInfo beanInfo = null;
    try {
      beanInfo = Introspector.getBeanInfo(clazz);

    } catch (IntrospectionException ex) {
      throw new IllegalArgumentException("Bean introspection failed: " + ex.getMessage());
    }

    return beanInfo.getPropertyDescriptors();
  }
 /**
  * Ignores reflection exceptions while using reflection to fill public fields and Bean properties
  * of the target object from the source Map.
  */
 public static void tryFill(Object target, Map<String, Object> source) {
   try {
     fill(target, source);
   } catch (IntrospectionException ie) {
     ie.printStackTrace();
   } catch (IllegalAccessException iae) {
     iae.printStackTrace();
   } catch (InvocationTargetException ite) {
     ite.printStackTrace();
   }
 }
  public BeanInfo[] getAdditionalBeanInfo() {
    try {
      BeanInfo hPubBi1 = Introspector.getBeanInfo(LastActionHistoryResults.class.getSuperclass());

      BeanInfo[] arrayOfBIs = {hPubBi1};
      return arrayOfBIs;
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }

    return null;
  }
  public BeanInfo[] getAdditionalBeanInfo() {
    try {
      BeanInfo hPubBi1 = Introspector.getBeanInfo(RestitutionCompGetData.class.getSuperclass());

      BeanInfo[] arrayOfBIs = {hPubBi1};
      return arrayOfBIs;
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }

    return null;
  }
Example #25
0
 @Override
 public final PropertyDescriptor[] getPropertyDescriptors() {
   try {
     final PropertyDescriptor[] res = {
       expertProp("Visible", "whether this layer is visible", FORMAT),
     };
     return res;
   } catch (final IntrospectionException e) {
     e.printStackTrace();
     return super.getPropertyDescriptors();
   }
 }
Example #26
0
  /**
   * Returns a PropertyDescriptor[] for the given Class.
   *
   * @param c The Class to retrieve PropertyDescriptors for.
   * @return A PropertyDescriptor[] describing the Class.
   * @throws SQLException if introspection failed.
   */
  public static PropertyDescriptor[] propertyDescriptors(Class<?> c) throws SQLException {
    // Introspector caches BeanInfo classes for better performance
    BeanInfo beanInfo = null;
    try {
      beanInfo = Introspector.getBeanInfo(c);

    } catch (IntrospectionException e) {
      throw new SQLException("Bean introspection failed: " + e.getMessage());
    }

    return beanInfo.getPropertyDescriptors();
  }
Example #27
0
 public String toString() {
   try {
     updateDiffInfo();
     Iterator iter = getDifferences().iterator();
     StringBuffer sb = new StringBuffer();
     while (iter.hasNext()) {
       DiffEntry de = (DiffEntry) iter.next();
       sb.append(de.toString());
     }
     return sb.toString();
   } catch (IntrospectionException e) {
     return e.getMessage();
   }
 }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor queueType = new PropertyDescriptor("queueType", ToQueue.class);
      queueType.setBound(true);
      queueType.setPropertyEditorClass(ConceptLabelEditor.class);
      queueType.setDisplayName("Queue type:");
      queueType.setShortDescription("The type of queue to place this process into.");

      PropertyDescriptor rv[] = {queueType};
      return rv;
    } catch (IntrospectionException e) {
      throw new Error(e.toString());
    }
  }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor profilePropName =
          new PropertyDescriptor("profilePropName", getBeanDescriptor().getBeanClass());
      profilePropName.setBound(true);
      profilePropName.setPropertyEditorClass(PropertyNameLabelEditor.class);
      profilePropName.setDisplayName("<html><font color='green'>profile prop:");
      profilePropName.setShortDescription("The property that contains the working profile.");

      PropertyDescriptor rv[] = {profilePropName};
      return rv;
    } catch (IntrospectionException e) {
      throw new Error(e.toString());
    }
  }
 /**
  * @param name
  * @param clazz
  */
 private static PropertyDescriptor findPropertyDescriptor(Class<?> clazz, String name) {
   BeanInfo beanInfo = null;
   try {
     beanInfo = Introspector.getBeanInfo(clazz);
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
   PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
   for (PropertyDescriptor p : propertyDescriptors) {
     if (name.equals(p.getName())) {
       return p;
     }
   }
   return null;
 }