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

pack-priv Class NewElementHandler

extends ElementHandler
Class Inheritance
Known Direct Subclasses
com.sun.beans.decoder.ObjectElementHandler, com.sun.beans.decoder.ArrayElementHandler, com.sun.beans.decoder.MethodElementHandler
Imports
com.sun.beans.finder.ConstructorFinder, java.lang.reflect.Array, .Constructor, java.util.ArrayList, .List

This class is intended to handle <new> element. It describes instantiation of the object. The class attribute denotes the name of the class to instantiate. The inner elements specifies the arguments of the constructor. For example:
<new class="java.lang.Long">
    <string>10</string>
</new>
is equivalent to Long.valueOf("10") in Java code.

The following attributes are supported:

class
the type of object for instantiation
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 List<Object>
private Class<?>
private ValueObject

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected final void
addArgument(Object
the value of the element that contained in this one
argument
)

Overrides com.sun.beans.decoder.ElementHandler.addArgument.

Adds the argument to the list of arguments that is used to calculate the value of this element.

public void
addAttribute(String
the attribute name
name
,
String
the attribute value
value
)

Overrides com.sun.beans.decoder.ElementHandler.addAttribute.

Parses attributes of the element.

pack-priv static Object[]

Returns:

the resolved array of arguments
getArguments
(Object[]
the array of arguments
arguments
,
Class<?>[]
the array of parameter types
types
)

Resolves variable arguments.

pack-priv static Class<?>[]

Returns:

the array of corresponding classes
getArgumentTypes
(Object[]
the array of arguments
arguments
)

Converts the array of arguments to the array of corresponding classes.

protected final Object

Returns:

the context of the method
getContextBean
()

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

Returns the context of the method.

protected final ValueObject

Returns:

the value of this element
getValueObject
()

Implements abstract com.sun.beans.decoder.ElementHandler.getValueObject.

Returns the value of this element.

pack-priv ValueObject

Returns:

the value of this element
getValueObject
(Class<?>
the base class
type
,
Object[]
the array of arguments
args
)

Calculates the value of this element using the base class and the array of arguments.

Inherited from com.sun.beans.decoder.ElementHandler:
addCharacterendElementgetOwnergetParentgetVariableisArgumentsetOwnersetParentstartElement

Field Detail

argumentsback to summary
private List<Object> arguments
typeback to summary
private Class<?> type
valueback to summary
private ValueObject value

Constructor Detail

NewElementHandlerback to summary
pack-priv NewElementHandler()

Method Detail

addArgumentback to summary
protected final void addArgument(Object argument)

Overrides com.sun.beans.decoder.ElementHandler.addArgument.

Adds the argument to the list of arguments that is used to calculate the value of this element.

Parameters
argument:Object

the value of the element that contained in this one

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

Overrides com.sun.beans.decoder.ElementHandler.addAttribute.

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

class
the type of object for instantiation
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
getArgumentsback to summary
pack-priv static Object[] getArguments(Object[] arguments, Class<?>[] types)

Resolves variable arguments.

Parameters
arguments:Object[]

the array of arguments

types:Class<?>[]

the array of parameter types

Returns:Object[]

the resolved array of arguments

getArgumentTypesback to summary
pack-priv static Class<?>[] getArgumentTypes(Object[] arguments)

Converts the array of arguments to the array of corresponding classes. If argument is null the class is null too.

Parameters
arguments:Object[]

the array of arguments

Returns:Class<?>[]

the array of corresponding classes

getContextBeanback to summary
protected final Object getContextBean()

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

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

Returns:Object

the context of the method

Annotations
@Override
getValueObjectback to summary
protected final ValueObject getValueObject()

Implements abstract com.sun.beans.decoder.ElementHandler.getValueObject.

Returns the value of this element.

Returns:ValueObject

the value of this element

Annotations
@Override
getValueObjectback to summary
pack-priv ValueObject getValueObject(Class<?> type, Object[] args) throws Exception

Calculates the value of this element using the base class and the array of arguments. By default, it creates an instance of the base class. This method should be overridden in those handlers that extend behavior of this element.

Parameters
type:Class<?>

the base class

args:Object[]

the array of arguments

Returns:ValueObject

the value of this element

Exceptions
Exception:
if calculation is failed