- java.lang.Object
-
- java.beans.FeatureDescriptor
-
- java.beans.PropertyDescriptor
-
- 已知直接子类:
-
IndexedPropertyDescriptor
public class PropertyDescriptor extends FeatureDescriptor
PropertyDescriptor描述了Java Bean通过一对存取方法导出的一个属性。- 从以下版本开始:
- 1.1
-
-
构造方法摘要
构造方法 构造器 描述 PropertyDescriptor(String propertyName, 类<?> beanClass)通过使用getFoo和setFoo访问器方法为遵循标准Java约定的属性构造PropertyDescriptor。PropertyDescriptor(String propertyName, 类<?> beanClass, String readMethodName, String writeMethodName)此构造函数采用简单属性的名称,以及用于读取和写入属性的方法名称。PropertyDescriptor(String propertyName, 方法 readMethod, 方法 writeMethod)此构造函数采用简单属性的名称,而Method对象用于读取和写入属性。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 PropertyEditorcreatePropertyEditor(Object bean)使用当前属性编辑器类构造属性编辑器的实例。booleanequals(Object obj)将此PropertyDescriptor与指定的对象进行比较。类<?>getPropertyEditorClass()获取已为此属性注册的任何显式PropertyEditor类。类<?>getPropertyType()返回属性的Java类型信息。方法getReadMethod()获取应该用于读取属性值的方法。方法getWriteMethod()获取应该用于写入属性值的方法。inthashCode()返回对象的哈希码值。booleanisBound()对“绑定”属性的更新将导致在更改属性时触发“PropertyChange”事件。booleanisConstrained()尝试更新“Constrained”属性将导致在更改属性时触发“VetoableChange”事件。voidsetBound(boolean bound)对“绑定”属性的更新将导致在更改属性时触发“PropertyChange”事件。voidsetConstrained(boolean constrained)尝试更新“Constrained”属性将导致在更改属性时触发“VetoableChange”事件。voidsetPropertyEditorClass(类<?> propertyEditorClass)通常使用PropertyEditorManager找到PropertyEditors。voidsetReadMethod(方法 readMethod)设置应该用于读取属性值的方法。voidsetWriteMethod(方法 writeMethod)设置应该用于写入属性值的方法。-
声明方法的类 java.beans.FeatureDescriptor
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue, toString
-
-
-
-
构造方法详细信息
-
PropertyDescriptor
public PropertyDescriptor(String propertyName, 类<?> beanClass) throws IntrospectionException
通过使用getFoo和setFoo访问器方法为遵循标准Java约定的属性构造PropertyDescriptor。 因此,如果参数名称是“fred”,则它将假定writer方法是“setFred”并且reader方法是“getFred”(或者对于boolean属性是“isFred”)。 请注意,属性名称应以小写字符开头,该字符将在方法名称中大写。- 参数
-
propertyName- 属性的编程名称。 -
beanClass- 目标bean的Class对象。 例如sun.beans.OurButton.class。 - 异常
-
IntrospectionException- 如果IntrospectionException期间发生异常。
-
PropertyDescriptor
public PropertyDescriptor(String propertyName, 类<?> beanClass, String readMethodName, String writeMethodName) throws IntrospectionException
此构造函数采用简单属性的名称,以及用于读取和写入属性的方法名称。- 参数
-
propertyName- 属性的编程名称。 -
beanClass- 目标bean的Class对象。 例如sun.beans.OurButton.class。 -
readMethodName- 用于读取属性值的方法的名称。 如果属性是只写的,则可以为null。 -
writeMethodName- 用于写入属性值的方法的名称。 如果属性是只读的,则可以为null。 - 异常
-
IntrospectionException- 如果IntrospectionException期间发生异常。
-
PropertyDescriptor
public PropertyDescriptor(String propertyName, 方法 readMethod, 方法 writeMethod) throws IntrospectionException
此构造函数采用简单属性的名称,而Method对象用于读取和写入属性。- 参数
-
propertyName- 属性的编程名称。 -
readMethod- 用于读取属性值的方法。 如果属性是只写的,则可以为null。 -
writeMethod- 用于写入属性值的方法。 如果属性是只读的,则可以为null。 - 异常
-
IntrospectionException- 如果IntrospectionException期间发生异常。
-
-
方法详细信息
-
getPropertyType
public 类<?> getPropertyType()
返回属性的Java类型信息。 请注意,类对象可能描述原始Java类型,例如int。 此类型由read方法返回,或用作write方法的参数类型。 如果类型是不支持非索引访问的索引属性,则返回null。- 结果
-
表示Java类型信息的
类对象,如果无法确定类型,null
-
getReadMethod
public 方法 getReadMethod()
获取应该用于读取属性值的方法。- 结果
- 应该用于读取属性值的方法。 如果无法读取属性,则可能返回null。
-
setReadMethod
public void setReadMethod(方法 readMethod) throws IntrospectionException
设置应该用于读取属性值的方法。- 参数
-
readMethod- 新的读取方法。 - 异常
-
IntrospectionException- 如果read方法无效 - 从以下版本开始:
- 1.2
-
getWriteMethod
public 方法 getWriteMethod()
获取应该用于写入属性值的方法。- 结果
- 应该用于写入属性值的方法。 如果无法写入属性,则可能返回null。
-
setWriteMethod
public void setWriteMethod(方法 writeMethod) throws IntrospectionException
设置应该用于写入属性值的方法。- 参数
-
writeMethod- 新的写入方法。 - 异常
-
IntrospectionException- 如果write方法无效 - 从以下版本开始:
- 1.2
-
isBound
public boolean isBound()
对“绑定”属性的更新将导致在更改属性时触发“PropertyChange”事件。- 结果
- 如果这是绑定属性,则为True。
-
setBound
public void setBound(boolean bound)
对“绑定”属性的更新将导致在更改属性时触发“PropertyChange”事件。- 参数
-
bound- 如果这是绑定属性,boundTrue。
-
isConstrained
public boolean isConstrained()
尝试更新“Constrained”属性将导致在更改属性时触发“VetoableChange”事件。- 结果
- 如果这是受约束的属性,则为True。
-
setConstrained
public void setConstrained(boolean constrained)
尝试更新“Constrained”属性将导致在更改属性时触发“VetoableChange”事件。- 参数
-
constrained- 如果这是受约束的属性,constrainedTrue。
-
setPropertyEditorClass
public void setPropertyEditorClass(类<?> propertyEditorClass)
通常使用PropertyEditorManager找到PropertyEditors。 但是,如果由于某种原因您希望将特定PropertyEditor与给定属性相关联,则可以使用此方法执行此操作。- 参数
-
propertyEditorClass- 所需PropertyEditor的类。
-
getPropertyEditorClass
public 类<?> getPropertyEditorClass()
获取已为此属性注册的任何显式PropertyEditor类。- 结果
- 已为此属性注册的任何显式PropertyEditor类。 通常这将返回“null”,表示没有注册特殊编辑器,因此应使用PropertyEditorManager来定位合适的PropertyEditor。
-
createPropertyEditor
public PropertyEditor createPropertyEditor(Object bean)
使用当前属性编辑器类构造属性编辑器的实例。如果属性编辑器类具有接受Object参数的公共构造函数,那么将使用bean参数作为参数调用它。 否则,将调用默认构造函数。
- 参数
-
bean- 源对象 - 结果
- 属性编辑器实例,如果尚未定义或无法创建属性编辑器,则返回null
- 从以下版本开始:
- 1.5
-
equals
public boolean equals(Object obj)
将此PropertyDescriptor与指定的对象进行比较。 如果对象相同,则返回true。 如果read,write,属性类型,属性编辑器和标志是等效的,则两个PropertyDescriptor是相同的。- 重写:
-
equals在类Object - 参数
-
obj- 要与之比较的引用对象。 - 结果
-
true如果此对象与obj参数相同; 否则为false。 - 从以下版本开始:
- 1.4
- 另请参见:
-
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
返回对象的哈希码值。 有关完整说明,请参见Object.hashCode()。- 重写:
-
hashCode类Object - 结果
- 此对象的哈希码值。
- 从以下版本开始:
- 1.5
- 另请参见:
-
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
-
-