JavaAPI之PropertyDescriptor
来源:互联网 发布:java流媒体服务器 编辑:程序博客网 时间:2024/05/01 19:29
结构
java.beans
类 PropertyDescriptor
java.lang.Object java.beans.FeatureDescriptor java.beans.PropertyDescriptor
- 直接已知子类:
- IndexedPropertyDescriptor
描述
public class PropertyDescriptor extends FeatureDescriptor
PropertyDescriptor 描述 Java Bean 通过一对存储器方法导出的一个属性。
构造方法
1、public PropertyDescriptor(String propertyName, Class<?> beanClass) throwsIntrospectionException
通过调用 getFoo 和 setFoo 存取方法,为符合标准 Java 约定的属性构造一个 PropertyDescriptor。因此如果参数名为 "fred",则假定 writer 方法为 "setFred",reader 方法为 "getFred"(对于 boolean 属性则为 "isFred")。注意,属性名应该以小写字母开头,而方法名称中的首写字母将是大写的。
参数:propertyName
- 属性的编程名称。
beanClass
- 目标 bean 的 Class 对象。例如 sun.beans.OurButton.class。
抛出:IntrospectionException
- 如果在内省期间发生异常。
2、public PropertyDescriptor(String propertyName, Class<?> beanClass, String readMethodName, String writeMethodName) throwsIntrospectionException
此构造方法带有一个简单属性的名称和用于读写属性的方法名称。
参数:propertyName
- 属性的编程名称。
beanClass
- 目标 bean 的 Class 对象。例如 sun.beans.OurButton.class。
readMethodName
- 用于读取属性值的方法名称。如果属性是只写的,则该参数可能为 null。
writeMethodName
- 用于写入属性值的方法名称。如果属性是只读的,则该参数可能为 null。
抛出:IntrospectionException
- 如果在内省期间发生异常。
3、public PropertyDescriptor(String propertyName, Method readMethod,Method writeMethod)throwsIntrospectionException
此构造方法带有某一简单属性的名称,以及用来读取和写入属性的 Method 对象。
参数:propertyName
- 属性的编程名称。
readMethod
- 用于读取属性值的方法。如果属性是只写的,则该参数可能为 null。
writeMethod
- 用于写入属性值的方法。如果属性是只读的,则该参数可能为 null。
抛出:IntrospectionException
- 如果在内省期间发生异常。
方法详细
1、public Class<?>getPropertyType() 获得属性的 Class 对象。
返回:属性的 Java 类型信息。注意,"Class" 对象可以描述内置 Java 类型,比如 "int"。如果此属性是一个不支持非索引访问的索引 (indexed) 属性,则结果可能是 "null"。
而这里的类型是由 ReadMethod 返回的类型。
2、publicMethodgetReadMethod() 获得应该用于读取属性值的方法。
返回:应该用于读取属性值的方法。如果无法读取该属性,则可能返回。
3、public void setReadMethod(Method readMethod) throwsIntrospectionException 设置应该用于读取属性值的方法。
参数:readMethod
- 新的读取方法。
抛出:IntrospectionException
4、publicMethodgetWriteMethod() 获得应该用于写入属性值的方法。
返回:应该用于写入属性值的方法。如果无法写入该属性,则可能返回。
5、public void setWriteMethod(Method writeMethod) throwsIntrospectionException
设置应该用于写入属性值的方法。
参数:writeMethod
- 新的写入方法。
抛出:IntrospectionException
6、public boolean isBound() 更新 "bound" 属性将导致更改该属性时激发 "PropertyChange" 事件。
返回:如果该属性是绑定 (bound) 属性,则返回 true。
7、public void setBound(boolean bound)
更新 "bound" 属性将导致更改该属性时激发 "PropertyChange" 事件。
参数:bound
- 如果该属性是绑定属性,则该属性为 true。
8、public boolean isConstrained()
试图更新 "Constrained" 属性将导致更改该属性时激发 "VetoableChange" 事件。
返回:如果该属性是约束 (constrained) 属性,则返回 true。
9、public void setConstrained(boolean constrained)
试图更新 "Constrained" 属性将导致更改该属性时激发 "VetoableChange" 事件。
参数:constrained
- 如果该属性是约束属性,则该属性为 true。
10、public void setPropertyEditorClass(Class<?> propertyEditorClass)
通常 PropertyEditor 是使用 PropertyEditorManager 找到的。不过,如果出于某些原因想将特定 PropertyEditor 与某一给定属性相关联,那么可以使用此方法做到这一点。
参数:propertyEditorClass
- 所需 PropertyEditor 的 Class。
11、public Class<?>getPropertyEditorClass() 获得已为此属性注册的任何显式 PropertyEditor Class。
返回:已为此属性注册的任何显式 PropertyEditor Class。通常此方法将返回 "null",指示没有注册特殊编辑器,所以 PropertyEditorManager 应该用于查找合适的 PropertyEditor。
12、public PropertyEditorcreatePropertyEditor(Object bean)
使用当前属性编辑器类构造一个属性编辑器实例。如果属性编辑器类拥有一个带有 Object 参数的公共构造方法,则将通过使用 bean 参数作为变量来调用它。否则将调用默认构造方法。
参数:bean
- 源对象
返回:属性编辑器实例,如果没有定义或无法创建属性编辑器,则返回 null
从以下版本开始:1.5
13、public boolean equals(Object obj)
将此 PropertyDescriptor
与指定对象进行比较。如果对象是相同的,则返回 true。如果读取、写入、属性类型、属性编辑器和标记都是等同的,则两个PropertyDescriptor
是相同的。
覆盖:类 Object
中的 equals
参数:obj
- 要与之比较的引用对象。
返回:如果此对象与 obj 参数相同,则返回 true
;否则返回false
。
从以下版本开始:1.4
另请参见:Object.hashCode()
, Hashtable
14、public int hashCode()
返回对象的哈希码。关于完整的描述,请参阅 Object.hashCode()
。
覆盖:类 Object
中的 hashCode
返回:此对象的哈希码值。
从以下版本开始:1.5
另请参见:Object.equals(java.lang.Object)
,Hashtable
- JavaAPI之PropertyDescriptor
- PropertyDescriptor
- Mongo之javaAPI
- javaAPI之Properties
- javaAPI之Field
- JavaAPI之AnnotatedElement接口
- JavaAPI之AccessibleObject
- JavaAPI之ThreadLocal
- JavaAPI之PreDestroy
- JavaAPI之BeanInfo接口
- JavaAPI之Introspector
- JavaAPI之FeatureDescriptor
- JavaAPI之ConcurrentHashMap
- JavaAPI之CopyOnWriteArrayList
- JavaAPI之AtomicInteger
- JavaAPI之Type接口
- JavaAPI之AtomicLong
- JavaAPI之AtomicBoolean
- gemgem 更换国内淘宝源
- UE4 -- C++ 创建UInterface接口
- Ruby学习笔记之gem 命令详解
- 新手配置springmvc+freemarker过程
- 编译原理—语法分析
- JavaAPI之PropertyDescriptor
- Win7环境下安装MySQL5.7.13(Zip版)过程记录
- ACM:蓝桥杯:1的个数
- 以initwith开头的实例方法必须调用父类的方法
- 数据表的修改
- iOS 【Third-Masonry(自动布局)使用介绍以及简写形式】
- JSONModel 使用特性
- USACO-Zero Sum
- JSONModel几个属性