APIdia Launch Partner
Top Description Fields Constructors Methods
java.beans

public Class PropertyDescriptor

extends FeatureDescriptor
Class Inheritance
Known Direct Subclasses
java.beans.IndexedPropertyDescriptor
Imports
java.lang.ref.Reference, java.lang.reflect.Method, .Constructor, java.util.Map.Entry, com.sun.beans.introspect.PropertyInfo

A PropertyDescriptor describes one property that a Java Bean exports via a pair of accessor methods.
Since
1.1

Field Summary

Modifier and TypeField and Description
private String
private boolean
private boolean
private Reference<? extends Class<?>>
private Reference<? extends Class<?>>
private String
private final MethodRef
private String
private final MethodRef

Constructor Summary

AccessConstructor and Description
public
PropertyDescriptor(String
The programmatic name of the property.
propertyName
,
Class<?>
The Class object for the target bean. For example sun.beans.OurButton.class.
beanClass
)

Constructs a PropertyDescriptor for a property that follows the standard Java convention by having getFoo and setFoo accessor methods.

public
PropertyDescriptor(String
The programmatic name of the property.
propertyName
,
Class<?>
The Class object for the target bean. For example sun.beans.OurButton.class.
beanClass
,
String
The name of the method used for reading the property value. May be null if the property is write-only.
readMethodName
,
String
The name of the method used for writing the property value. May be null if the property is read-only.
writeMethodName
)

This constructor takes the name of a simple property, and method names for reading and writing the property.

public
PropertyDescriptor(String
The programmatic name of the property.
propertyName
,
Method
The method used for reading the property value. May be null if the property is write-only.
readMethod
,
Method
The method used for writing the property value. May be null if the property is read-only.
writeMethod
)

This constructor takes the name of a simple property, and Method objects for reading and writing the property.

pack-priv
PropertyDescriptor(Map.Entry<String, PropertyInfo>
the pair of values, where the key is the base name of the property (the rest of the method name) and the value is the automatically generated property info
entry
,
boolean
the flag indicating whether it is possible to treat this property as a bound property
bound
)

Creates PropertyDescriptor from the specified property info.

pack-priv
PropertyDescriptor(PropertyDescriptor
The first (lower priority) PropertyDescriptor
x
,
PropertyDescriptor
The second (higher priority) PropertyDescriptor
y
)

Package-private constructor.

pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv boolean

Returns:

boolean to indicate that the methods are equivalent
compareMethods
(Method
first method to compare
a
,
Method
second method to compare
b
)

Package private helper method for Descriptor .equals methods.

public PropertyEditor

Returns:

a property editor instance or null if a property editor has not been defined or cannot be created
createPropertyEditor
(Object
the source object
bean
)

Constructs an instance of a property editor using the current property editor class.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Compares this PropertyDescriptor against the specified object.

private Class<?>

Returns:

the type of the property descriptor or null if both read and write methods are null.
findPropertyType
(Method readMethod, Method writeMethod)

Returns the property type that corresponds to the read and write method.

pack-priv String
public Class<?>

Returns:

Any explicit PropertyEditor Class that has been registered for this property. Normally this will return "null", indicating that no special editor has been registered, so the PropertyEditorManager should be used to locate a suitable PropertyEditor.
getPropertyEditorClass
()

Gets any explicit PropertyEditor Class that has been registered for this property.

public synchronized Class<?>

Returns:

the Class object that represents the Java type info, or null if the type cannot be determined
getPropertyType
()

Returns the Java type info for the property.

private Class<?>
public synchronized Method

Returns:

The method that should be used to read the property value. May return null if the property can't be read.
getReadMethod
()

Gets the method that should be used to read the property value.

public synchronized Method

Returns:

The method that should be used to write the property value. May return null if the property can't be written.
getWriteMethod
()

Gets the method that should be used to write the property value.

public int

Returns:

a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.

pack-priv boolean
public boolean

Returns:

True if this is a bound property.
isBound
()

Updates to "bound" properties will cause a "PropertyChange" event to get fired when the property is changed.

public boolean

Returns:

True if this is a constrained property.
isConstrained
()

Attempted updates to "Constrained" properties will cause a "VetoableChange" event to get fired when the property is changed.

public void
setBound(boolean
True if this is a bound property.
bound
)

Updates to "bound" properties will cause a "PropertyChange" event to get fired when the property is changed.

pack-priv void
setClass0(Class<?> clz)

Overrides java.beans.FeatureDescriptor.setClass0.

Overridden to ensure that a super class doesn't take precedent

public void
setConstrained(boolean
True if this is a constrained property.
constrained
)

Attempted updates to "Constrained" properties will cause a "VetoableChange" event to get fired when the property is changed.

public void
setPropertyEditorClass(Class<?>
The Class for the desired PropertyEditor.
propertyEditorClass
)

Normally PropertyEditors will be found using the PropertyEditorManager.

private void
public synchronized void
setReadMethod(Method
The new read method.
readMethod
)

Sets the method that should be used to read the property value.

private void
setReadMethod0(Method readMethod)

public synchronized void
setWriteMethod(Method
The new write method.
writeMethod
)

Sets the method that should be used to write the property value.

private void
setWriteMethod0(Method writeMethod)

pack-priv void
Inherited from java.beans.FeatureDescriptor:
appendToappendToappendToattributeNamesgetClass0getDisplayNamegetNamegetParameterTypesgetReturnTypegetShortDescriptiongetSoftReferencegetValuegetWeakReferenceisExpertisHiddenisPreferredisTransientsetDisplayNamesetExpertsetHiddensetNamesetPreferredsetShortDescriptionsetTransientsetValuetoString

Field Detail

baseNameback to summary
private String baseName
boundback to summary
private boolean bound
constrainedback to summary
private boolean constrained
propertyEditorClassRefback to summary
private Reference<? extends Class<?>> propertyEditorClassRef
propertyTypeRefback to summary
private Reference<? extends Class<?>> propertyTypeRef
readMethodNameback to summary
private String readMethodName
readMethodRefback to summary
private final MethodRef readMethodRef
writeMethodNameback to summary
private String writeMethodName
writeMethodRefback to summary
private final MethodRef writeMethodRef

Constructor Detail

PropertyDescriptorback to summary
public PropertyDescriptor(String propertyName, Class<?> beanClass) throws IntrospectionException

Constructs a PropertyDescriptor for a property that follows the standard Java convention by having getFoo and setFoo accessor methods. Thus if the argument name is "fred", it will assume that the writer method is "setFred" and the reader method is "getFred" (or "isFred" for a boolean property). Note that the property name should start with a lower case character, which will be capitalized in the method names.

Parameters
propertyName:String

The programmatic name of the property.

beanClass:Class<?>

The Class object for the target bean. For example sun.beans.OurButton.class.

Exceptions
IntrospectionException:
if an exception occurs during introspection.
PropertyDescriptorback to summary
public PropertyDescriptor(String propertyName, Class<?> beanClass, String readMethodName, String writeMethodName) throws IntrospectionException

This constructor takes the name of a simple property, and method names for reading and writing the property.

Parameters
propertyName:String

The programmatic name of the property.

beanClass:Class<?>

The Class object for the target bean. For example sun.beans.OurButton.class.

readMethodName:String

The name of the method used for reading the property value. May be null if the property is write-only.

writeMethodName:String

The name of the method used for writing the property value. May be null if the property is read-only.

Exceptions
IntrospectionException:
if an exception occurs during introspection.
PropertyDescriptorback to summary
public PropertyDescriptor(String propertyName, Method readMethod, Method writeMethod) throws IntrospectionException

This constructor takes the name of a simple property, and Method objects for reading and writing the property.

Parameters
propertyName:String

The programmatic name of the property.

readMethod:Method

The method used for reading the property value. May be null if the property is write-only.

writeMethod:Method

The method used for writing the property value. May be null if the property is read-only.

Exceptions
IntrospectionException:
if an exception occurs during introspection.
PropertyDescriptorback to summary
pack-priv PropertyDescriptor(Map.Entry<String, PropertyInfo> entry, boolean bound)

Creates PropertyDescriptor from the specified property info.

Parameters
entry:Map.Entry<String, PropertyInfo>

the pair of values, where the key is the base name of the property (the rest of the method name) and the value is the automatically generated property info

bound:boolean

the flag indicating whether it is possible to treat this property as a bound property

Since
9
PropertyDescriptorback to summary
pack-priv PropertyDescriptor(PropertyDescriptor x, PropertyDescriptor y)

Package-private constructor. Merge two property descriptors. Where they conflict, give the second argument (y) priority over the first argument (x).

Parameters
x:PropertyDescriptor

The first (lower priority) PropertyDescriptor

y:PropertyDescriptor

The second (higher priority) PropertyDescriptor

PropertyDescriptorback to summary
pack-priv PropertyDescriptor(PropertyDescriptor old)

Method Detail

appendToback to summary
pack-priv void appendTo(StringBuilder sb)

Overrides java.beans.FeatureDescriptor.appendTo.

Annotations
@Override
compareMethodsback to summary
pack-priv boolean compareMethods(Method a, Method b)

Package private helper method for Descriptor .equals methods.

Parameters
a:Method

first method to compare

b:Method

second method to compare

Returns:boolean

boolean to indicate that the methods are equivalent

createPropertyEditorback to summary
public PropertyEditor createPropertyEditor(Object bean)

Constructs an instance of a property editor using the current property editor class.

If the property editor class has a public constructor that takes an Object argument then it will be invoked using the bean parameter as the argument. Otherwise, the default constructor will be invoked.

Parameters
bean:Object

the source object

Returns:PropertyEditor

a property editor instance or null if a property editor has not been defined or cannot be created

Annotations
@SuppressWarnings:deprecation
Since
1.5
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this PropertyDescriptor against the specified object. Returns true if the objects are the same. Two PropertyDescriptors are the same if the read, write, property types, property editor and flags are equivalent.

Annotations
@Override
Since
1.4
findPropertyTypeback to summary
private Class<?> findPropertyType(Method readMethod, Method writeMethod) throws IntrospectionException

Returns the property type that corresponds to the read and write method. The type precedence is given to the readMethod.

Returns:Class<?>

the type of the property descriptor or null if both read and write methods are null.

Exceptions
IntrospectionException:
if the read or write method is invalid
getBaseNameback to summary
pack-priv String getBaseName()
getPropertyEditorClassback to summary
public Class<?> getPropertyEditorClass()

Gets any explicit PropertyEditor Class that has been registered for this property.

Returns:Class<?>

Any explicit PropertyEditor Class that has been registered for this property. Normally this will return "null", indicating that no special editor has been registered, so the PropertyEditorManager should be used to locate a suitable PropertyEditor.

getPropertyTypeback to summary
public synchronized Class<?> getPropertyType()

Returns the Java type info for the property. Note that the Class object may describe primitive Java types such as int. This type is returned by the read method or is used as the parameter type of the write method. Returns null if the type is an indexed property that does not support non-indexed access.

Returns:Class<?>

the Class object that represents the Java type info, or null if the type cannot be determined

getPropertyType0back to summary
private Class<?> getPropertyType0()
getReadMethodback to summary
public synchronized Method getReadMethod()

Gets the method that should be used to read the property value.

Returns:Method

The method that should be used to read the property value. May return null if the property can't be read.

getWriteMethodback to summary
public synchronized Method getWriteMethod()

Gets the method that should be used to write the property value.

Returns:Method

The method that should be used to write the property value. May return null if the property can't be written.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object. See java.lang.Object#hashCode for a complete description.

Returns:int

a hash code value for this object.

Annotations
@Override
Since
1.5
isAssignableback to summary
pack-priv boolean isAssignable(Method m1, Method m2)
isBoundback to summary
public boolean isBound()

Updates to "bound" properties will cause a "PropertyChange" event to get fired when the property is changed.

Returns:boolean

True if this is a bound property.

isConstrainedback to summary
public boolean isConstrained()

Attempted updates to "Constrained" properties will cause a "VetoableChange" event to get fired when the property is changed.

Returns:boolean

True if this is a constrained property.

setBoundback to summary
public void setBound(boolean bound)

Updates to "bound" properties will cause a "PropertyChange" event to get fired when the property is changed.

Parameters
bound:boolean

True if this is a bound property.

setClass0back to summary
pack-priv void setClass0(Class<?> clz)

Overrides java.beans.FeatureDescriptor.setClass0.

Overridden to ensure that a super class doesn't take precedent

Annotations
@Override
setConstrainedback to summary
public void setConstrained(boolean constrained)

Attempted updates to "Constrained" properties will cause a "VetoableChange" event to get fired when the property is changed.

Parameters
constrained:boolean

True if this is a constrained property.

setPropertyEditorClassback to summary
public void setPropertyEditorClass(Class<?> propertyEditorClass)

Normally PropertyEditors will be found using the PropertyEditorManager. However if for some reason you want to associate a particular PropertyEditor with a given property, then you can do it with this method.

Parameters
propertyEditorClass:Class<?>

The Class for the desired PropertyEditor.

setPropertyTypeback to summary
private void setPropertyType(Class<?> type)
setReadMethodback to summary
public synchronized void setReadMethod(Method readMethod) throws IntrospectionException

Sets the method that should be used to read the property value.

Parameters
readMethod:Method

The new read method.

Exceptions
IntrospectionException:
if the read method is invalid
Since
1.2
setReadMethod0back to summary
private void setReadMethod0(Method readMethod)
setWriteMethodback to summary
public synchronized void setWriteMethod(Method writeMethod) throws IntrospectionException

Sets the method that should be used to write the property value.

Parameters
writeMethod:Method

The new write method.

Exceptions
IntrospectionException:
if the write method is invalid
Since
1.2
setWriteMethod0back to summary
private void setWriteMethod0(Method writeMethod)
updateGenericsForback to summary
pack-priv void updateGenericsFor(Class<?> type)