JavaTM Platform
Standard Ed. 6

java.beans
类 IndexedPropertyDescriptor

java.lang.Object
  继承者 java.beans.FeatureDescriptor
      继承者 java.beans.PropertyDescriptor
          继承者 java.beans.IndexedPropertyDescriptor

public class IndexedPropertyDescriptor
extends PropertyDescriptor

IndexedPropertyDescriptor 描述了类似数组行为的属性,且有一种访问数组特定元素的索引读和/或索引写方法。

索引 (indexed) 属性还可以提供简单的非索引读和写方法。如果存在这些方法,它们可读取和写入索引读方法所返回类型的读写数组。


构造方法摘要
IndexedPropertyDescriptor(String propertyName, Class<?> beanClass)
          此构造方法通过 getFoo 和 setFoo 存取方法为符合标准 Java 约定的属性构造 IndexedPropertyDescriptor,将其用于索引访问和数组访问。
IndexedPropertyDescriptor(String propertyName, Class<?> beanClass, String readMethodName, String writeMethodName, String indexedReadMethodName, String indexedWriteMethodName)
          此构造方法带有一个简单属性的名称和用于读写属性的方法名称,它们都是带索引的或不带索引的。
IndexedPropertyDescriptor(String propertyName, Method readMethod, Method writeMethod, Method indexedReadMethod, Method indexedWriteMethod)
          此构造方法带有某一简单属性的名称,以及用来读取和写入属性的 Method 对象。
 
方法摘要
 boolean equals(Object obj)
          将此 PropertyDescriptor 与指定对象比较。
 Class<?> getIndexedPropertyType()
          获得索引属性类型的 Class 对象。
 Method getIndexedReadMethod()
          获得应该用于读取索引属性值的方法。
 Method getIndexedWriteMethod()
          获得应该用于写入索引属性值的方法。
 int hashCode()
          返回对象的哈希码值。
 void setIndexedReadMethod(Method readMethod)
          设置应该用于读取索引属性值的方法。
 void setIndexedWriteMethod(Method writeMethod)
          设置应该用于写入索引属性值的方法。
 
从类 java.beans.PropertyDescriptor 继承的方法
createPropertyEditor, getPropertyEditorClass, getPropertyType, getReadMethod, getWriteMethod, isBound, isConstrained, setBound, setConstrained, setPropertyEditorClass, setReadMethod, setWriteMethod
 
从类 java.beans.FeatureDescriptor 继承的方法
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue
 
从类 java.lang.Object 继承的方法
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

IndexedPropertyDescriptor

public IndexedPropertyDescriptor(String propertyName,
                                 Class<?> beanClass)
                          throws IntrospectionException
此构造方法通过 getFoo 和 setFoo 存取方法为符合标准 Java 约定的属性构造 IndexedPropertyDescriptor,将其用于索引访问和数组访问。

因此,如果参数名为 "fred",则假定有一个索引 reader 方法 "getFred"、一个也称为 "getFred" 的非索引(数组)reader 方法、一个索引 writer 方法 "setFred" 和一个非索引 writer 方法 "setFred"。

参数:
propertyName - 属性的编程名称。
beanClass - 目标 bean 的 Class 对象。
抛出:
IntrospectionException - 如果在内省期间发生异常。

IndexedPropertyDescriptor

public IndexedPropertyDescriptor(String propertyName,
                                 Class<?> beanClass,
                                 String readMethodName,
                                 String writeMethodName,
                                 String indexedReadMethodName,
                                 String indexedWriteMethodName)
                          throws IntrospectionException
此构造方法带有一个简单属性的名称和用于读写属性的方法名称,它们都是带索引的或不带索引的。

参数:
propertyName - 属性的编程名称。
beanClass - 目标 bean 的 Class 对象。
readMethodName - 用来以数组形式读取属性值的方法的名称。如果该属性是只写的或是必须建立索引的,则可能返回 null。
writeMethodName - 用来以数组形式写入属性值的方法的名称。如果该属性是只读的或是必须建立索引的,则可能返回 null。
indexedReadMethodName - 用于读取索引属性值的方法的名称。如果属性是只写的,则该参数可能为 null。
indexedWriteMethodName - 用于写入索引属性值的方法的名称。如果属性是只读的,则该参数可能为 null。
抛出:
IntrospectionException - 如果在内省期间发生异常。

IndexedPropertyDescriptor

public IndexedPropertyDescriptor(String propertyName,
                                 Method readMethod,
                                 Method writeMethod,
                                 Method indexedReadMethod,
                                 Method indexedWriteMethod)
                          throws IntrospectionException
此构造方法带有某一简单属性的名称,以及用来读取和写入属性的 Method 对象。

参数:
propertyName - 属性的编程名称。
readMethod - 用来以数组形式读取属性值的方法。如果该属性是只写的或是必须建立索引的,则可能返回 null。
writeMethod - 用来以数组形式写入属性值的方法。如果该属性是只读的或是必须建立索引的,则可能返回 null。
indexedReadMethod - 用于读取索引属性值的方法。如果属性是只写的,则该参数可能为 null。
indexedWriteMethod - 用于写入索引属性值的方法。如果属性是只读的,则该参数可能为 null。
抛出:
IntrospectionException - 如果在内省期间发生异常。
方法详细信息

getIndexedReadMethod

public Method getIndexedReadMethod()
获得应该用于读取索引属性值的方法。

返回:
应该用于读取索引属性值的方法。如果该属性没有建立索引或是只写的,则可能返回 null。

setIndexedReadMethod

public void setIndexedReadMethod(Method readMethod)
                          throws IntrospectionException
设置应该用于读取索引属性值的方法。

参数:
readMethod - 新的索引读取方法。
抛出:
IntrospectionException

getIndexedWriteMethod

public Method getIndexedWriteMethod()
获得应该用于写入索引属性值的方法。

返回:
应该用于写入索引属性值的方法。如果该属性没有建立索引或是只读的,则可能返回 null。

setIndexedWriteMethod

public void setIndexedWriteMethod(Method writeMethod)
                           throws IntrospectionException
设置应该用于写入索引属性值的方法。

参数:
writeMethod - 新的索引写入方法。
抛出:
IntrospectionException

getIndexedPropertyType

public Class<?> getIndexedPropertyType()
获得索引属性类型的 Class 对象。返回的 Class 可能描述诸如 int 的基本类型。

返回:
用于索引属性类型的 Class;如果类型无法确定,则可能返回 null

equals

public boolean equals(Object obj)
将此 PropertyDescriptor 与指定对象比较。如果对象是相同的,则返回 true。如果读取、写入、属性类型、属性编辑器和标记都是等同的,则两个 PropertyDescriptor 是相同的。

覆盖:
PropertyDescriptor 中的 equals
参数:
obj - 要与之比较的引用对象。
返回:
如果此对象与 obj 参数相同,则返回 true;否则返回 false
从以下版本开始:
1.4
另请参见:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
返回对象的哈希码值。关于完整的描述,请参阅 Object.hashCode()

覆盖:
PropertyDescriptor 中的 hashCode
返回:
此对象的哈希码值。
从以下版本开始:
1.5
另请参见:
Object.equals(java.lang.Object), Hashtable

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策