com.abstractics.xmlpanel.swing.componentcreator
Class GenericClassComponentCreator
java.lang.Object
com.abstractics.xmlpanel.swing.componentcreator.AbstractComponentCreator
com.abstractics.xmlpanel.swing.componentcreator.GenericClassComponentCreator
- All Implemented Interfaces:
- ComponentCreator
- public class GenericClassComponentCreator
- extends AbstractComponentCreator
This implementation of
AbstractComponentCreator
creates components based on a class that is given in the constructor. The use
of this ComponentCreator probably covers 95% of the creation needs for
components.
- Version:
- $Id: GenericClassComponentCreator.java,v 1.1 2006/03/01 03:18:23
andyman99 Exp $
- Author:
- Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache
License, Version 2.0
Method Summary |
java.awt.Component |
constructComponent(org.w3c.dom.Element element,
XmlPanel panel)
Instantiates an object using the no-argument constructor of the class
that was used to instatiate this object.
This implementation also takes into account any existing component in the
panel. |
java.lang.String[] |
getComponentTypes()
Returns the class name that was used to instantiate the object, along
with any otherTypeNames that were used in instantiation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericClassComponentCreator
public GenericClassComponentCreator(java.lang.String className)
throws java.lang.ClassNotFoundException
- Parameters:
className
- The name of the class to instantiate. Must be a subclass of
java.awt.Component
and must have a zero
argument constructor
- Throws:
java.lang.ClassNotFoundException
java.lang.IllegalArgumentException
- Thrown if the resulting class does not meet the criteria
mentioned above.
GenericClassComponentCreator
public GenericClassComponentCreator(java.lang.Class clazz)
- Parameters:
clazz
- The class to instantiate. Must be a subclass of
java.awt.Component
and must have a zero argument constructor
- Throws:
java.lang.IllegalArgumentException
- Thrown if the clazz
parameter does not meet
the criteria mentioned above.
GenericClassComponentCreator
public GenericClassComponentCreator(java.lang.Class clazz,
java.lang.String[] otherTypeNames)
- Parameters:
clazz
- The class to instantiate. Must be a subclass of
java.awt.Component
and must have a zero argument constructorotherTypeNames
- String array of other type names that this creator can be
known by
- Throws:
java.lang.IllegalArgumentException
- Thrown if the clazz
parameter does not meet
the criteria mentioned above.
getComponentTypes
public java.lang.String[] getComponentTypes()
- Returns the class name that was used to instantiate the object, along
with any otherTypeNames that were used in instantiation.
- Returns:
- Return the type name(s) that this XmlPanelComponentCreator is
known by. When cell tags are found with a type attribute that
matches one of these values (case-insensitive), then this
component creator will be used
- See Also:
GenericClassComponentCreator(Class, String[])
,
com.abstractics.xmlpanel.swing.componentcreator.ComponentCreator#getComponentType()
constructComponent
public java.awt.Component constructComponent(org.w3c.dom.Element element,
XmlPanel panel)
- Instantiates an object using the no-argument constructor of the class
that was used to instatiate this object.
This implementation also takes into account any existing component in the
panel. If the XmlPanel already has a component with the same name that we
want, and it is of the same class then we will use that component instead
of creating a new one. This is done to preserve components when doing
runtime editing.
- Specified by:
constructComponent
in class AbstractComponentCreator
- Parameters:
element
- XML element to parse throughpanel
- The XmlPanel that this component is being placed into - for
reference only!. This method should not mutate the panel
in any way. It is also possible that this parameter could be
null, so always check first.
- Returns:
- The resulting
java.awt.Component
- See Also:
GenericClassComponentCreator(Class)
,
AbstractComponentCreator.constructComponent(Element, XmlPanel)