net.xoetrope.registry
Class ComponentAdapter

java.lang.Object
  extended by net.xoetrope.registry.ComponentAdapter
Direct Known Subclasses:
ReflectionAdapter

public class ComponentAdapter
extends java.lang.Object

An adapter of component properties and settings for use with registered components. The class maintains a list of getter and setter methods and helps with invocation of those methods.

Copyright (c) Xoetrope Ltd., 2002-2004

$Revision: 1.18 $

License: see License.txt


Field Summary
protected  java.lang.String className
          The class name of the class being adapted e.g. com.myorg.MyClass
protected  java.lang.Class clazz
          The class being adapted
protected  java.util.Hashtable getters
          The getter methods
protected  java.util.Hashtable setters
          The setter methods
protected  java.lang.String UI
          The UI the type of user interface this component supports, e.g.
 
Constructor Summary
ComponentAdapter(java.lang.ClassLoader cl, java.lang.String clazzName, java.lang.String ui)
          Construct a new adapter for the specified class.
ComponentAdapter(java.lang.Class clazz, java.lang.String ui)
          Construct a new adapter for the specified class.
ComponentAdapter(java.lang.String clazzName, java.lang.String ui)
          Construct a new adapter for the specified class.
 
Method Summary
 java.lang.reflect.Method addProperty(java.lang.String type, java.lang.String name, java.lang.String methodName, java.lang.String paramType, boolean attributed, boolean warn, XmlElement paramNode)
          Try to get and register a method
 java.lang.Class getAdapterClass()
          Get the class being adapter
 java.lang.String getAdapterClassName()
          Get the class name of the class being adapter
 java.lang.Object getProperty(java.lang.Object comp, java.lang.String propertyName)
          Get a property value.
 java.lang.String getUI()
          Get the UI type for this component e.g.
 int setProperty(java.lang.Object comp, java.lang.String propertyName, java.lang.String content, java.lang.String paramType)
          Set a property value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clazz

protected java.lang.Class clazz
The class being adapted


UI

protected java.lang.String UI
The UI the type of user interface this component supports, e.g. "swing"


className

protected java.lang.String className
The class name of the class being adapted e.g. com.myorg.MyClass


setters

protected java.util.Hashtable setters
The setter methods


getters

protected java.util.Hashtable getters
The getter methods

Constructor Detail

ComponentAdapter

public ComponentAdapter(java.lang.Class clazz,
                        java.lang.String ui)
Construct a new adapter for the specified class.

Parameters:
clazz - the class being adapter
ui - the type of user interface this component supports, e.g. "swing"
Throws:
java.lang.ClassNotFoundException - Could not find the class
Since:
3.0

ComponentAdapter

public ComponentAdapter(java.lang.String clazzName,
                        java.lang.String ui)
                 throws java.lang.ClassNotFoundException
Construct a new adapter for the specified class.

Parameters:
clazzName - the class name e.g. com.myorg.MyClass
ui - the type of user interface this component supports, e.g. "swing"
Throws:
java.lang.ClassNotFoundException - Could not find the class

ComponentAdapter

public ComponentAdapter(java.lang.ClassLoader cl,
                        java.lang.String clazzName,
                        java.lang.String ui)
                 throws java.lang.ClassNotFoundException
Construct a new adapter for the specified class.

Parameters:
cl - the class loader to use to load the class
clazzName - the class name e.g. com.myorg.MyClass
ui - the type of user interface this component supports, e.g. "swing"
Throws:
java.lang.ClassNotFoundException - Could not find the class
Method Detail

getAdapterClass

public java.lang.Class getAdapterClass()
Get the class being adapter

Since:
3.0

getAdapterClassName

public java.lang.String getAdapterClassName()
Get the class name of the class being adapter

Since:
3.0

setProperty

public int setProperty(java.lang.Object comp,
                       java.lang.String propertyName,
                       java.lang.String content,
                       java.lang.String paramType)
Set a property value. If the method has not been registered an attempt will be made to get the method using the bean naming convention.

Parameters:
comp - the comp whose property is set
propertyName - the name of the property
paramType - the type of parameter (String, int, double, boolean, Object) or null for no parameter
content - the value to set
Returns:
0 if all is well, otherwise -1 is returned to indicate an error

getProperty

public java.lang.Object getProperty(java.lang.Object comp,
                                    java.lang.String propertyName)
Get a property value. If the method has not been registered an attempt will be made to get the method using the bean naming convention.

Parameters:
comp - the comp whose property is to be retrieved
propertyName - the name of the property
Returns:
the property value

addProperty

public java.lang.reflect.Method addProperty(java.lang.String type,
                                            java.lang.String name,
                                            java.lang.String methodName,
                                            java.lang.String paramType,
                                            boolean attributed,
                                            boolean warn,
                                            XmlElement paramNode)
Try to get and register a method

Parameters:
type - either "get" or "set"
name - the name by which the method is referred to in the page XML
methodName - the method name
paramType - the type of parameter (String, int, double, boolean, Object)
attributed - is the property set via the XAttributedComponent interface
warn - true to warn of failure to add the property - the method is
paramNode - the parameters node called when a page specifies a new property and generally such properties are set with the setAttribute method. In other cases the property is being registered so we do want to warn of a failure.
Returns:
the method or null if not found

getUI

public java.lang.String getUI()
Get the UI type for this component e.g. "swing" or "awt"

Returns:
the UI name