com.ibm.commons.iloader.node.loaders
Class JavaBeanLoader

java.lang.Object
  extended by com.ibm.commons.iloader.node.loaders.AbstractLoader
      extended by com.ibm.commons.iloader.node.loaders.JavaBeanLoader
All Implemented Interfaces:
ILoader

public class JavaBeanLoader
extends AbstractLoader

An ILoader that adapts to a JavaBean model.


Constructor Summary
JavaBeanLoader(JavaBeanLoader parent, java.lang.String namespace)
          Creates a new instance of this class.
JavaBeanLoader(java.lang.String namespace)
          Creates a new instance of this class.
 
Method Summary
protected  boolean acceptClass(java.lang.Class c)
           
protected  boolean acceptProperty(java.lang.Class clazz, java.beans.PropertyDescriptor pd)
           
protected  IMember createMember(IClassDef parent, java.lang.Class clazz, java.beans.PropertyDescriptor pd)
           
 java.lang.ClassLoader getClassLoader()
          Returns the class loader that is used by this JavaBeanLoader
 IClassDef getClassOf(java.lang.Object object)
          Get the class for a particular object.
static JavaBeanLoader getDefault()
           
 java.util.Iterator getInheritingClassesOf(IClassDef classDef)
          Returns a iterator of all of the classes that inherit from the provided IClassDef.
 java.lang.String[] getNamespaces()
          Get the list of namespaces handled by this loader.
 java.lang.Object getObject(java.lang.Object instance, IAttribute attribute)
          Get an object value for the given attribute.
 IObjectCollection getObjectCollection(java.lang.Object instance, ICollection collection)
          Get an object collection based on the provided property (ICollection).
 java.lang.String getValue(java.lang.Object instance, IAttribute attribute)
          Returns a string value for the given attribute.
 IValueCollection getValueCollection(java.lang.Object instance, ICollection collection)
          Get a value collection based on the provided property (ICollection).
 boolean handleNamespace(java.lang.String namespace)
          Check if the loader is using a particular namespace
 boolean isInstanceOf(java.lang.Object object, IClassDef classDef)
          Returns whether or not the provided object is an instance of the given classdef object.
 boolean isNativeClass(java.lang.Object o)
          Check is an object is a native class.
 boolean isNativeObject(java.lang.Object o)
          Determines if the provided object is supported by the current ILoader instance.
 IClassDef loadClass(java.lang.String namespace, java.lang.String className)
          Load a class giving a name.
 IClassDef loadNativeClass(java.lang.Class nativeClass)
          Loads a IClassDef object for the given native class.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the class loader to be used by this JavaBeanLoader
 void setObject(java.lang.Object instance, IAttribute attribute, java.lang.Object value, DataChangeNotifier dataChangeNotifier)
          Sets an object value for the given attribute.
 void setValue(java.lang.Object instance, IAttribute attribute, java.lang.String value, DataChangeNotifier dataChangeNotifier)
          Sets the given attribute's value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaBeanLoader

public JavaBeanLoader(JavaBeanLoader parent,
                      java.lang.String namespace)
Creates a new instance of this class.

Parameters:
parent - the parent JavaBeanLoader of this loader.
namespace - the namespace that this loader can handle

JavaBeanLoader

public JavaBeanLoader(java.lang.String namespace)
Creates a new instance of this class.

Parameters:
namespace - the namespace that this loader can handle
Method Detail

getDefault

public static JavaBeanLoader getDefault()

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns the class loader that is used by this JavaBeanLoader

Returns:

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the class loader to be used by this JavaBeanLoader

Parameters:
classLoader -

acceptClass

protected boolean acceptClass(java.lang.Class c)

acceptProperty

protected boolean acceptProperty(java.lang.Class clazz,
                                 java.beans.PropertyDescriptor pd)

createMember

protected IMember createMember(IClassDef parent,
                               java.lang.Class clazz,
                               java.beans.PropertyDescriptor pd)
                        throws com.ibm.commons.iloader.node.NodeException
Throws:
com.ibm.commons.iloader.node.NodeException

handleNamespace

public boolean handleNamespace(java.lang.String namespace)
Description copied from interface: ILoader
Check if the loader is using a particular namespace

Returns:
returns true if the provided namespace is supported by the current loader

getNamespaces

public java.lang.String[] getNamespaces()
Description copied from interface: ILoader
Get the list of namespaces handled by this loader.

Returns:
returns the qualified names of all supported namespaces

isNativeClass

public boolean isNativeClass(java.lang.Object o)
Description copied from interface: ILoader
Check is an object is a native class.

Returns:
returns true if the object provided is assignable from the current loader.

loadClass

public IClassDef loadClass(java.lang.String namespace,
                           java.lang.String className)
                    throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Load a class giving a name.

Parameters:
namespace - the namespace that the IClassDef is to correspond to
className - the desired class
Returns:
a IClassDef object for the given classname and namespace
Throws:
com.ibm.commons.iloader.node.NodeException

getClassOf

public IClassDef getClassOf(java.lang.Object object)
                     throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Get the class for a particular object.

Parameters:
object - an object whose IClassDef is required
Returns:
returns the IClassDef for the given object
Throws:
NodeException - throws a NodeException if the provided object is supported by the ILoader.

isInstanceOf

public boolean isInstanceOf(java.lang.Object object,
                            IClassDef classDef)
                     throws com.ibm.commons.iloader.node.NodeException
Returns whether or not the provided object is an instance of the given classdef object.

Parameters:
object - the object under test
classDef - the classdef to test against
Returns:
returns true if the given object is an instance of the given classdef
Throws:
com.ibm.commons.iloader.node.NodeException

loadNativeClass

public IClassDef loadNativeClass(java.lang.Class nativeClass)
                          throws com.ibm.commons.iloader.node.NodeException
Loads a IClassDef object for the given native class.

Parameters:
nativeClass -
Returns:
Throws:
com.ibm.commons.iloader.node.NodeException - throws a NodeException if a IClassDef object cannot be loaded for the given nativeClass

isNativeObject

public boolean isNativeObject(java.lang.Object o)
Description copied from interface: ILoader
Determines if the provided object is supported by the current ILoader instance.

Returns:
returns true if the provided object is supported by the ILoader

getValue

public java.lang.String getValue(java.lang.Object instance,
                                 IAttribute attribute)
                          throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Returns a string value for the given attribute. The ILoader determines the value of the attribute in the model supported by the ILoader.

Parameters:
instance - an instance of the model that contains the given attribute
attribute - the attribute whose value is sought
Returns:
returns a string for the given attribute
Throws:
com.ibm.commons.iloader.node.NodeException
See Also:
IAttribute

setValue

public void setValue(java.lang.Object instance,
                     IAttribute attribute,
                     java.lang.String value,
                     DataChangeNotifier dataChangeNotifier)
              throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Sets the given attribute's value.

Parameters:
instance - an instance of the model that contains the given attribute
attribute - the attribute whose value is to be set
value - the value to set the attribute to
Throws:
NodeException - throws a NodeException if the given attribute is not supported by the ILoader
See Also:
IAttribute

getObject

public java.lang.Object getObject(java.lang.Object instance,
                                  IAttribute attribute)
                           throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Get an object value for the given attribute.

Parameters:
instance - an instance of the model that contains the given attribute
attribute - the attribute whose value is to be set
Returns:
returns a object for the given attribute
Throws:
NodeException - throws a NodeException if the particular object/attribute is not supported by the current ILoader
See Also:
IAttribute

setObject

public void setObject(java.lang.Object instance,
                      IAttribute attribute,
                      java.lang.Object value,
                      DataChangeNotifier dataChangeNotifier)
               throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Sets an object value for the given attribute.

Parameters:
instance - an instance of the model that contains the given attribute
attribute - the attribute whose value is to be set
value - the value that is to be set on the IAttribute
dataChangeNotifier - a notifier that should be notified when the value changes
Throws:
NodeException - throws a NodeException if the particular object/attribute is not supported by the current ILoader
See Also:
IAttribute

getValueCollection

public IValueCollection getValueCollection(java.lang.Object instance,
                                           ICollection collection)
                                    throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Get a value collection based on the provided property (ICollection).

Parameters:
instance - an instance of the model that contains the given collection
collection - the ICollection whose value is sought
Returns:
returns an IValueCollection
Throws:
NodeException - throws a NodeException if the particular object/attribute is not supported by the current ILoader
See Also:
ICollection

getObjectCollection

public IObjectCollection getObjectCollection(java.lang.Object instance,
                                             ICollection collection)
                                      throws com.ibm.commons.iloader.node.NodeException
Description copied from interface: ILoader
Get an object collection based on the provided property (ICollection).

Parameters:
instance - an instance of the model that contains the given collection
collection - the ICollection whose value is sought
Returns:
returns an IObjectCollection
Throws:
NodeException - throws a NodeException if the particular object/attribute is not supported by the current ILoader
See Also:
ICollection

getInheritingClassesOf

public java.util.Iterator getInheritingClassesOf(IClassDef classDef)
Description copied from interface: ILoader
Returns a iterator of all of the classes that inherit from the provided IClassDef.

Returns:
an Iterator of IClassDef containing concrete classes that implements and IClassDef