|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.sns.xal.model.elem.ElementFactory
Utility class for instantiated XAL Model Elements. It is the class factory for all IElement based objects.
Every element class exposing the IElement interface should register itself
in the static class-loader code (static {} block) in order to be recognized by this class
factory. The requirements for registration are that the registering class expose the
IElement interface and have a constructor taking the single argument of
a DataAdaptor object. The constructor should fully initialize the object
according to the data available in the data adaptor.
The factory is useful in parsing XML files in using the XAL Model Lattice DTD format. Every IElement has a type code (in String format) which may be used to identify the class.
DataAdaptor| Field Summary | |
static java.lang.String |
s_strAttrType
string name of 'type' attribute in DataAdaptors |
| Method Summary | |
static IElement |
createIElement(java.lang.String strType)
Create a IElement object based on information stored in a DataAdaptor
object. |
static java.lang.Class[] |
getRegisteredClasses()
Get array of class types for registered IElement classes. |
static int |
getRegisteredCount()
Get the total number of registered elements, both thin and thick. |
static java.lang.String[] |
getRegisteredTypes()
Get array of all element type strings, both thin and thick, that are registered to class factory. |
static void |
main(java.lang.String[] arrArgs)
Class test driver |
static boolean |
registerIElement(java.lang.String strType,
java.lang.Class clsType)
Register the IElement exposing class with the class factory. |
static void |
testCreation(java.io.PrintWriter os,
java.lang.String strType)
Test element creation mechanism |
static void |
testRegistration(java.io.PrintWriter os)
Test element registration mechanism |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String s_strAttrType
| Method Detail |
public static int getRegisteredCount()
public static java.lang.String[] getRegisteredTypes()
public static java.lang.Class[] getRegisteredClasses()
public static boolean registerIElement(java.lang.String strType,
java.lang.Class clsType)
Element(DataAdaptor daptInit).
The type string in the argument strType must be the same string
returned by the IElement method getType():String.
The argument clsType is the Class class of the
class being registered with this factory. The class must expose the
IElement interface.
Example:
For the derived class ThinLens the static block should
include the following:
static {
...
registerElement(ThinLens.s_strType, ThinLens.class)
...
}
strType - type identifier of the classclsType - Class class for registered class
public static IElement createIElement(java.lang.String strType)
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException
DataAdaptor
object.
strType - string type identifier for IElement concrete class
IElement exposing object
java.lang.ClassNotFoundException - unknown class or class does not have proper constructor
DataFormatException - data in adaptor does not conform to DTD
java.lang.NumberFormatException - corrupted position field
java.lang.InstantiationException - unknown error occurred during element constructionpublic static void main(java.lang.String[] arrArgs)
public static void testRegistration(java.io.PrintWriter os)
os - output stream
public static void testCreation(java.io.PrintWriter os,
java.lang.String strType)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||