APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.beans.decoder

pack-priv final Class PropertyElementHandler

extends AccessorElementHandler
Class Inheritance
Imports
com.sun.beans.finder.MethodFinder, java.beans.IndexedPropertyDescriptor, .IntrospectionException, .Introspector, .PropertyDescriptor, java.lang.reflect.Array, .InvocationTargetException, .Method, sun.reflect.misc.MethodUtil

This class is intended to handle <property> element. This element simplifies access to the properties. If the index attribute is specified this element uses additional int parameter. If the name attribute is not specified this element uses method "get" as getter and method "set" as setter. This element defines getter if it contains no argument. It returns the value of the property in this case. For example:
<property name="object" index="10"/>
is shortcut to
<method name="getObject">
    <int>10</int>
</method>
which is equivalent to getObject(10) in Java code. This element defines setter if it contains one argument. It does not return the value of the property in this case. For example:
<property><int>0</int></property>
is shortcut to
<method name="set">
    <int>0</int>
</method>
which is equivalent to set(0) in Java code.

The following attributes are supported:

name
the property name
index
the property index
id
the identifier of the variable that is intended to store the result
Author
Sergey A. Malenkov
Since
1.7

Field Summary

Modifier and TypeField and Description
pack-priv static final String
private Integer
pack-priv static final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(String
the attribute name
name
,
String
the attribute value
value
)

Overrides com.sun.beans.decoder.AccessorElementHandler.addAttribute.

Parses attributes of the element.

private static Method

Returns:

method object that represents found getter
findGetter
(Class<?>
the class that contains method
type
,
String
the name of the property
name
,
Class<?>...
the method arguments
args
)

Performs the search of the getter for the property with specified name in specified class.

private static Method

Returns:

method object that represents found setter
findSetter
(Class<?>
the class that contains method
type
,
String
the name of the property
name
,
Class<?>...
the method arguments
args
)

Performs the search of the setter for the property with specified name in specified class.

private static PropertyDescriptor

Returns:

descriptor for the named property
getProperty
(Class<?>
the class to introspect
type
,
String
the property name
name
)

Performs the search of the descriptor for the property with specified name in specified class.

private static Object

Returns:

the value of the property
getPropertyValue
(Object
the context bean that contains property
bean
,
String
the name of the property
name
,
Integer
the index of the indexed property
index
)

Performs the search of the getter for the property with specified name in specified class and returns value of the property.

protected Object

Returns:

the value of the specified property
getValue
(String
the name of the property
name
)

Implements abstract com.sun.beans.decoder.AccessorElementHandler.getValue.

Returns the value of the property with specified name.

protected boolean

Returns:

true if the value of this element should be used as an argument of the element that contained in this one, false otherwise
isArgument
()

Overrides com.sun.beans.decoder.ElementHandler.isArgument.

Tests whether the value of this element can be used as an argument of the element that contained in this one.

private static void
setPropertyValue(Object
the context bean that contains property
bean
,
String
the name of the property
name
,
Integer
the index of the indexed property
index
,
Object
the new value for the property
value
)

Performs the search of the setter for the property with specified name in specified class and updates value of the property.

protected void
setValue(String
the name of the property
name
,
Object
the new value for the specified property
value
)

Implements abstract com.sun.beans.decoder.AccessorElementHandler.setValue.

Sets the new value for the property with specified name.

Inherited from com.sun.beans.decoder.AccessorElementHandler:
addArgumentgetValueObject

Field Detail

GETTERback to summary
pack-priv static final String GETTER
indexback to summary
private Integer index
SETTERback to summary
pack-priv static final String SETTER

Constructor Detail

PropertyElementHandlerback to summary
pack-priv PropertyElementHandler()

Method Detail

addAttributeback to summary
public void addAttribute(String name, String value)

Overrides com.sun.beans.decoder.AccessorElementHandler.addAttribute.

Parses attributes of the element. The following attributes are supported:

name
the property name
index
the property index
id
the identifier of the variable that is intended to store the result
Parameters
name:String

the attribute name

value:String

the attribute value

Annotations
@Override
findGetterback to summary
private static Method findGetter(Class<?> type, String name, Class<?>... args) throws IntrospectionException, NoSuchMethodException

Performs the search of the getter for the property with specified name in specified class.

Parameters
type:Class<?>

the class that contains method

name:String

the name of the property

args:Class<?>[]

the method arguments

Returns:Method

method object that represents found getter

Exceptions
IntrospectionException:
if the bean introspection is failed
NoSuchMethodException:
if method is not found
findSetterback to summary
private static Method findSetter(Class<?> type, String name, Class<?>... args) throws IntrospectionException, NoSuchMethodException

Performs the search of the setter for the property with specified name in specified class.

Parameters
type:Class<?>

the class that contains method

name:String

the name of the property

args:Class<?>[]

the method arguments

Returns:Method

method object that represents found setter

Exceptions
IntrospectionException:
if the bean introspection is failed
NoSuchMethodException:
if method is not found
getPropertyback to summary
private static PropertyDescriptor getProperty(Class<?> type, String name) throws IntrospectionException

Performs the search of the descriptor for the property with specified name in specified class.

Parameters
type:Class<?>

the class to introspect

name:String

the property name

Returns:PropertyDescriptor

descriptor for the named property

Exceptions
IntrospectionException:
if property descriptor is not found
getPropertyValueback to summary
private static Object getPropertyValue(Object bean, String name, Integer index) throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException

Performs the search of the getter for the property with specified name in specified class and returns value of the property.

Parameters
bean:Object

the context bean that contains property

name:String

the name of the property

index:Integer

the index of the indexed property

Returns:Object

the value of the property

Exceptions
IllegalAccessException:
if the property is not accessible
IntrospectionException:
if the bean introspection is failed
InvocationTargetException:
if the getter cannot be invoked
NoSuchMethodException:
if the getter is not found
getValueback to summary
protected Object getValue(String name)

Implements abstract com.sun.beans.decoder.AccessorElementHandler.getValue.

Returns the value of the property with specified name.

Parameters
name:String

the name of the property

Returns:Object

the value of the specified property

Annotations
@Override
isArgumentback to summary
protected boolean isArgument()

Overrides com.sun.beans.decoder.ElementHandler.isArgument.

Tests whether the value of this element can be used as an argument of the element that contained in this one.

Returns:boolean

true if the value of this element should be used as an argument of the element that contained in this one, false otherwise

Annotations
@Override
setPropertyValueback to summary
private static void setPropertyValue(Object bean, String name, Integer index, Object value) throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException

Performs the search of the setter for the property with specified name in specified class and updates value of the property.

Parameters
bean:Object

the context bean that contains property

name:String

the name of the property

index:Integer

the index of the indexed property

value:Object

the new value for the property

Exceptions
IllegalAccessException:
if the property is not accessible
IntrospectionException:
if the bean introspection is failed
InvocationTargetException:
if the setter cannot be invoked
NoSuchMethodException:
if the setter is not found
setValueback to summary
protected void setValue(String name, Object value)

Implements abstract com.sun.beans.decoder.AccessorElementHandler.setValue.

Sets the new value for the property with specified name.

Parameters
name:String

the name of the property

value:Object

the new value for the specified property

Annotations
@Override