java.beans.IndexedPropertyDescriptor#getIndexedPropertyType ( )源码实例Demo

下面列出了java.beans.IndexedPropertyDescriptor#getIndexedPropertyType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spring-analysis-note   文件: ExtendedBeanInfo.java
@Nullable
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
源代码2 项目: spring4-understanding   文件: ExtendedBeanInfo.java
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
源代码3 项目: blog_demos   文件: ExtendedBeanInfo.java
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
	for (PropertyDescriptor pd : this.propertyDescriptors) {
		final Class<?> candidateType;
		final String candidateName = pd.getName();
		if (pd instanceof IndexedPropertyDescriptor) {
			IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
			candidateType = ipd.getIndexedPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) {
				return pd;
			}
		}
		else {
			candidateType = pd.getPropertyType();
			if (candidateName.equals(propertyName) &&
					(candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) {
				return pd;
			}
		}
	}
	return null;
}
 
源代码4 项目: jdk8u-jdk   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码5 项目: dragonwell8_jdk   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码6 项目: TencentKona-8   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码7 项目: TencentKona-8   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码8 项目: jdk8u_jdk   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码9 项目: openjdk-jdk8u   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码10 项目: pentaho-reporting   文件: BeanUtility.java
public static Class getPropertyType( final PropertyDescriptor pd ) throws BeanException {
  final Class typeFromDescriptor = pd.getPropertyType();
  if ( typeFromDescriptor != null ) {
    return typeFromDescriptor;
  }
  if ( pd instanceof IndexedPropertyDescriptor ) {
    final IndexedPropertyDescriptor idx = (IndexedPropertyDescriptor) pd;
    return idx.getIndexedPropertyType();
  }
  throw new BeanException( "Unable to determine the property type." );
}
 
源代码11 项目: jdk8u-dev-jdk   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码14 项目: hottub   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码15 项目: hortonmachine   文件: BeanBuilder.java
public void setProperty(Object instance, String property, int index, Object value)
            throws IllegalAccessException, InvocationTargetException {
        IndexedPropertyDescriptor desc = (IndexedPropertyDescriptor) propertyMap.get(property);
        if (desc == null) {
            throw new IllegalArgumentException("Invalid property '" + property + "'");
        }
        Method meth = desc.getIndexedWriteMethod();
        Class propertyType = desc.getIndexedPropertyType();
        Object arg = getPropertyTypeValue(propertyType, value);
//        System.out.println("Invoking: " + meth.getName() + " Index = " + index + " arg = " + arg);
        meth.invoke(instance, new Object[]{new Integer(index), arg});
    }
 
源代码16 项目: jdk8u-jdk   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码17 项目: openjdk-8   文件: Test4619536.java
public static boolean hasIPD(IndexedPropertyDescriptor ipd) {
    if (null == ipd.getIndexedPropertyType()) {
        return false;
    }
    return (null != ipd.getIndexedReadMethod())
        || (null != ipd.getIndexedWriteMethod());
}
 
源代码18 项目: hottub   文件: Test8027648.java
private static Class<?> getPropertyType(Class<?> type, boolean indexed) {
    PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type, indexed ? "index" : "value");
    if (pd instanceof IndexedPropertyDescriptor) {
        IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
        return ipd.getIndexedPropertyType();
    }
    return pd.getPropertyType();
}
 
源代码19 项目: commons-bsf   文件: ReflectionUtils.java
/**
 * Set a property of a bean to a given value.
 *
 * @param target    the object whose prop is to be set
 * @param propName  name of the property to set
 * @param index     index to set (if property is indexed)
 * @param value     the property value
 * @param valueType the type of the above (needed when its null)
 * @param tcr       type convertor registry to use to convert value type to
 *                  property type if necessary
 *
 * @exception IntrospectionException if unable to introspect
 * @exception IllegalArgumentException if problems with args: if the
 *            property is unknown, or if the property is given an index
 *            when its not, or if the property is not writeable, or if
 *            the given value cannot be assigned to the it (type mismatch).
 * @exception IllegalAccessException if write method is not accessible
 * @exception InvocationTargetException if write method excepts
 */
public static void setProperty (Object target, String propName,
                Integer index, Object value,
                Class valueType, TypeConvertorRegistry tcr)
     throws IntrospectionException, IllegalArgumentException,
            IllegalAccessException, InvocationTargetException {
  // find the property descriptor
  BeanInfo bi = Introspector.getBeanInfo (target.getClass ());
  PropertyDescriptor pd = (PropertyDescriptor)
    findFeatureByName ("property", propName, bi.getPropertyDescriptors ());
  if (pd == null) {
    throw new IllegalArgumentException ("property '" + propName + "' is " +
                        "unknown for '" + target + "'");
  }

  // get write method and type of property
  Method wm;
  Class propType;
  if (index != null) {
    // if index != null, then property is indexed - pd better be so too
    if (!(pd instanceof IndexedPropertyDescriptor)) {
      throw new IllegalArgumentException ("attempt to set non-indexed " +
                          "property '" + propName +
                                          "' as being indexed");
    }
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    wm = ipd.getIndexedWriteMethod ();
    propType = ipd.getIndexedPropertyType ();
  } else {
    wm = pd.getWriteMethod ();
    propType = pd.getPropertyType ();
  }

  if (wm == null) {
    throw new IllegalArgumentException ("property '" + propName +
                        "' is not writeable");
  }

  // type convert the value if necessary
  Object propVal = null;
  boolean okeydokey = true;
  if (propType.isAssignableFrom (valueType)) {
    propVal = value;
  } else if (tcr != null) {
    TypeConvertor cvtor = tcr.lookup (valueType, propType);
    if (cvtor != null) {
      propVal = cvtor.convert (valueType, propType, value);
    } else {
      okeydokey = false;
    }
  } else {
    okeydokey = false;
  }
  if (!okeydokey) {
    throw new IllegalArgumentException ("unable to assign '" + value +
                        "' to property '" + propName + "'");
  }

  // now set the value
  if (index != null) {
    wm.invoke (target, new Object[] {index, propVal});
  } else {
    wm.invoke (target, new Object[] {propVal});
  }
}
 
源代码20 项目: commons-bsf   文件: ReflectionUtils.java
/**
 * Get a property of a bean.
 *
 * @param target    the object whose prop is to be gotten
 * @param propName  name of the property to set
 * @param index     index to get (if property is indexed)
 *
 * @exception IntrospectionException if unable to introspect
 * @exception IllegalArgumentException if problems with args: if the
 *            property is unknown, or if the property is given an index
 *            when its not, or if the property is not writeable, or if
 *            the given value cannot be assigned to the it (type mismatch).
 * @exception IllegalAccessException if read method is not accessible
 * @exception InvocationTargetException if read method excepts
 */
public static Bean getProperty (Object target, String propName,
                Integer index)
     throws IntrospectionException, IllegalArgumentException,
            IllegalAccessException, InvocationTargetException {
  // find the property descriptor
  BeanInfo bi = Introspector.getBeanInfo (target.getClass ());
  PropertyDescriptor pd = (PropertyDescriptor)
    findFeatureByName ("property", propName, bi.getPropertyDescriptors ());
  if (pd == null) {
    throw new IllegalArgumentException ("property '" + propName + "' is " +
                        "unknown for '" + target + "'");
  }

  // get read method and type of property
  Method rm;
  Class propType;
  if (index != null) {
    // if index != null, then property is indexed - pd better be so too
    if (!(pd instanceof IndexedPropertyDescriptor)) {
      throw new IllegalArgumentException ("attempt to get non-indexed " +
                          "property '" + propName +
                          "' as being indexed");
    }
    IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
    rm = ipd.getIndexedReadMethod ();
    propType = ipd.getIndexedPropertyType ();
  } else {
    rm = pd.getReadMethod ();
    propType = pd.getPropertyType ();
  }

  if (rm == null) {
    throw new IllegalArgumentException ("property '" + propName +
                        "' is not readable");
  }

  // now get the value
  Object propVal = null;
  if (index != null) {
    propVal = rm.invoke (target, new Object[] {index});
  } else {
    propVal = rm.invoke (target, null);
  }
  return new Bean (propType, propVal);
}