jfun.yan.xml.nut
Class NutDescriptor

java.lang.Object
  extended by jfun.yan.xml.nut.NutDescriptor
All Implemented Interfaces:
java.io.Serializable

public class NutDescriptor
extends java.lang.Object
implements java.io.Serializable

This class is the descriptor for a Nut class.

Author:
Ben Yu Nov 9, 2005 11:16:17 PM
See Also:
Serialized Form

Method Summary
 java.lang.Object createNut()
          To create a Nut object represented by this descriptor.
 boolean equals(java.lang.Object obj)
           
 java.lang.reflect.Method getAdder(java.lang.String name)
          To get the adder method for a given name.
 java.lang.Class getAdderType(java.lang.String name)
          To get the parameter type for a given adder method.
 java.lang.reflect.Method getAnonymousAdder(java.lang.Object arg)
          Get the adder method for adding sub-elements anonymously.
 Evaluator getEvaluator()
          Get the Evaluator object that evaluates a Nut object.
 java.util.Map getPropertyDescriptors()
          Get a map of the property descriptors for this type.
 java.lang.reflect.Method getSetter()
          If the Nut is a collection nut, get the method corresponding to the set method.
 java.lang.Class getSetterElementType()
          If the Nut is a collection nut, get the element type of the array parameter for the set method.
 NutDescriptor getSubDescriptor(java.lang.String name)
          Get the NutDescriptor object for a given sub-element.
 java.lang.Class getType()
          Get the Nut type.
 int hashCode()
           
 boolean isCollectionNut()
          Is this a collection nut?
 void setFactory(Factory factory)
          To set the factory object that is responsible for creating the nut instance instead of invoking the default constructor.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getAdder

public java.lang.reflect.Method getAdder(java.lang.String name)
To get the adder method for a given name.

Parameters:
name - the name of the adder.
Returns:
the adder method. null is returned if not found.

getAnonymousAdder

public java.lang.reflect.Method getAnonymousAdder(java.lang.Object arg)
Get the adder method for adding sub-elements anonymously.

Parameters:
arg - the argument to be added.
Returns:
the method.
Throws:
java.lang.IllegalArgumentException - if a method cannot be found for the given argument or if ambiguity happens.

getAdderType

public java.lang.Class getAdderType(java.lang.String name)
To get the parameter type for a given adder method.

Parameters:
name - the name of the adder.
Returns:
the parameter type. null is returned if not found.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isCollectionNut

public boolean isCollectionNut()
Is this a collection nut?

A collection nut is one that has a set with an array parameter.


getEvaluator

public Evaluator getEvaluator()
Get the Evaluator object that evaluates a Nut object.


getType

public java.lang.Class getType()
Get the Nut type.


getPropertyDescriptors

public java.util.Map getPropertyDescriptors()
Get a map of the property descriptors for this type.


getSubDescriptor

public NutDescriptor getSubDescriptor(java.lang.String name)
Get the NutDescriptor object for a given sub-element.

Parameters:
name - the name of the sub-element.
Returns:
the NutDescriptor. null if not found.

getSetter

public java.lang.reflect.Method getSetter()
If the Nut is a collection nut, get the method corresponding to the set method.

Returns:
the setter method.

getSetterElementType

public java.lang.Class getSetterElementType()
If the Nut is a collection nut, get the element type of the array parameter for the set method. For example, getSetterElementType() returns String if the type has a public void set(String[]) method.

Returns:
the element type.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

createNut

public java.lang.Object createNut()
                           throws java.lang.IllegalAccessException,
                                  java.lang.InstantiationException
To create a Nut object represented by this descriptor.

Returns:
the nut object.
Throws:
java.lang.IllegalAccessException - if access is denied.
java.lang.InstantiationException - if instantiation failed.

setFactory

public void setFactory(Factory factory)
To set the factory object that is responsible for creating the nut instance instead of invoking the default constructor.

Parameters:
factory - the factory object. Setting it to null means that the default constructor is used.