Top Description Fields Constructors Methods
com.sun.beans.decoder

pack-priv final Class FieldElementHandler

extends AccessorElementHandler
Class Inheritance
Imports
com.sun.beans.finder.FieldFinder, java.lang.reflect.Field

This class is intended to handle <field> element. This element simplifies access to the fields. If the class attribute is specified this element accesses static field of specified class. This element defines getter if it contains no argument. It returns the value of the field in this case. For example:
<field name="TYPE" class="java.lang.Long"/>
is equivalent to Long.TYPE in Java code. This element defines setter if it contains one argument. It does not return the value of the field in this case. For example:
<field name="id"><int>0</int></field>
is equivalent to id = 0 in Java code.

The following attributes are supported:

name
the field name
class
the type is used for static fields only
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
private Class<?>

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 Field

Returns:

field object that represents found field
findField
(Object
the context bean that contains field
bean
,
String
the name of the field
name
)

Performs the search of the field with specified name in specified context.

protected Object

Returns:

the context of the field
getContextBean
()

Overrides com.sun.beans.decoder.ElementHandler.getContextBean.

Returns the context of the field.
pack-priv static Object

Returns:

the value of the field
getFieldValue
(Object
the context bean that contains field
bean
,
String
the name of the field
name
)

Performs the search of the field with specified name in specified context and returns its value.

protected Object

Returns:

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

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

Returns the value of the field 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
setFieldValue(Object
the context bean that contains field
bean
,
String
the name of the field
name
,
Object
the new value for the field
value
)

Performs the search of the field with specified name in specified context and updates its value.

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

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

Sets the new value for the field with specified name.
Inherited from com.sun.beans.decoder.AccessorElementHandler:
addArgumentgetValueObject

Field Detail

typeback to summary
private Class<?> type

Constructor Detail

FieldElementHandlerback to summary
pack-priv FieldElementHandler()

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 field name
class
the type is used for static fields only
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
findFieldback to summary
private static Field findField(Object bean, String name) throws NoSuchFieldException

Performs the search of the field with specified name in specified context.

Parameters
bean:Object

the context bean that contains field

name:String

the name of the field

Returns:Field

field object that represents found field

Exceptions
NoSuchFieldException:
if the field is not found
getContextBeanback to summary
protected Object getContextBean()

Overrides com.sun.beans.decoder.ElementHandler.getContextBean.

Returns the context of the field. The context of the static field is the class object. The context of the non-static field is the value of the parent element.

Returns:Object

the context of the field

Annotations
@Override
getFieldValueback to summary
pack-priv static Object getFieldValue(Object bean, String name) throws IllegalAccessException, NoSuchFieldException

Performs the search of the field with specified name in specified context and returns its value.

Parameters
bean:Object

the context bean that contains field

name:String

the name of the field

Returns:Object

the value of the field

Exceptions
IllegalAccessException:
if the field is not accessible
NoSuchFieldException:
if the field is not found
getValueback to summary
protected Object getValue(String name)

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

Returns the value of the field with specified name.

Parameters
name:String

the name of the field

Returns:Object

the value of the specified field

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
setFieldValueback to summary
private static void setFieldValue(Object bean, String name, Object value) throws IllegalAccessException, NoSuchFieldException

Performs the search of the field with specified name in specified context and updates its value.

Parameters
bean:Object

the context bean that contains field

name:String

the name of the field

value:Object

the new value for the field

Exceptions
IllegalAccessException:
if the field is not accessible
NoSuchFieldException:
if the field 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 field with specified name.

Parameters
name:String

the name of the field

value:Object

the new value for the specified field

Annotations
@Override