|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ashridgetech.jamda.uml.AbstractElementFactory
A base implementation of Model.ElementFactory
.
com.ashridgetech.jamda.uml package. Allows
the Class of ModelElement
produced for a particular
MModelElement
class or stereotype name
to be set. More complex rules may be implemented by
overriding createCustom(ru.novosoft.uml.foundation.core.MModelElement, com.ashridgetech.jamda.uml.ModelElement)
.
Constructor Summary | |
protected |
AbstractElementFactory()
Default constructor for use by instances which are to be used as prototypes. |
protected |
AbstractElementFactory(AbstractElementFactory prototype,
Model model)
Constructor for use when creating a copy of an existing factory for a specific Model . |
Method Summary | |
abstract Model.ElementFactory |
createCopy(Model model)
Create the correct ElementFactory for
model . |
protected ModelElement |
createCustom(ru.novosoft.uml.foundation.core.MModelElement me,
ModelElement parent)
May be overridden by subclasses to create the required ModelElement ,
for any or all MModelElement s. |
ModelElement |
createElement(ru.novosoft.uml.foundation.core.MModelElement me,
ModelElement parent)
Create the appropriate subclass of ModelElement . |
protected java.lang.reflect.Constructor |
getConstructor(ru.novosoft.uml.foundation.core.MModelElement me)
Obtain a constructor for a ModelElement subclass. |
Model |
getModel()
Get the Model to which this AbstractElementFactory is attached. |
protected java.lang.reflect.Constructor |
lookupConstructor(java.lang.Class meClass)
Look up a constructor for a ModelElement subclass by
the interfaces implemented by meClass . |
protected java.lang.reflect.Constructor |
lookupConstructor(java.lang.String stereotypeName)
Look up a constructor for a ModelElement subclass by
stereotype name. |
protected void |
setClass(java.lang.Class nsumlElementClass,
java.lang.Class modelElementClass)
Set a ModelElement subclass to be created for
a subclass of MModelElement . |
protected void |
setClass(StandardStereotypeDef stereotypeDef)
Set a ModelElement subclass to be created for
a particular stereotype. |
protected void |
setClass(StandardStereotypeDef stereotypeDef,
java.lang.Class modelElementClass)
Set a ModelElement subclass to be created for
a particular stereotype. |
protected void |
setClassesForStereotypes(java.lang.Class stereotypeConstantClass)
Set the ModelElement subclass to be created for
the StandardStereotypeDef constants in a given class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected AbstractElementFactory()
protected AbstractElementFactory(AbstractElementFactory prototype, Model model)
Model
.
prototype
- the factory to be copiedmodel
- the model which will use the new factoryMethod Detail |
public Model getModel()
AbstractElementFactory
is attached.
Model
public ModelElement createElement(ru.novosoft.uml.foundation.core.MModelElement me, ModelElement parent)
ModelElement
.
This implementation first calls createCustom(ru.novosoft.uml.foundation.core.MModelElement, com.ashridgetech.jamda.uml.ModelElement)
. If that
returns null, it calls getConstructor(ru.novosoft.uml.foundation.core.MModelElement)
and constructs
the new ModelElement
using it. If getConstructor(ru.novosoft.uml.foundation.core.MModelElement)
returns null, or if the constructor returned cannot be used to
create a ModelElement
,
an ModelElement.UnknownElementException
is thrown.
createElement
in interface Model.ElementFactory
me
- the model element being loadedparent
- the element which will contain the new ModelElement
ModelElement
, or null if this ElementFactory
cannot create one
for me
Model.ElementFactory.createElement(ru.novosoft.uml.foundation.core.MModelElement, com.ashridgetech.jamda.uml.ModelElement)
public abstract Model.ElementFactory createCopy(Model model)
ElementFactory
for
model
. Subclasses should implement this by creating a new instance
with a constructor that calls AbstractElementFactory(AbstractElementFactory,Model)
and then copies any data specific to the subclass.
createCopy
in interface Model.ElementFactory
model
- the model being loaded
ElementFactory
.Model.Model(ru.novosoft.uml.model_management.MModel, java.util.List, java.util.List)
,
Model.getDefaultElementFactoryList()
protected ModelElement createCustom(ru.novosoft.uml.foundation.core.MModelElement me, ModelElement parent)
ModelElement
,
for any or all MModelElement
s.
This implementation returns null.
me
- the MModelElement
for which a ModelElement
is requiredparent
- the ModelElement
which is to be the parent of the one created
MModelElement
lookupConstructor(java.lang.Class)
protected java.lang.reflect.Constructor getConstructor(ru.novosoft.uml.foundation.core.MModelElement me)
ModelElement
subclass.
This implementation first calls lookupConstructor(String)
for
the name of each stereotype attached to me
. If no constructor
is found, it then calls lookupConstructor(Class)
with the class
of me
. If no constructor is found, it returns null.
me
- the MModelElement
for which a constructor is required
me
lookupConstructor(java.lang.Class)
protected java.lang.reflect.Constructor lookupConstructor(java.lang.Class meClass)
ModelElement
subclass by
the interfaces implemented by meClass
. The constructor must
have been registered using setClass( Class, Class )
meClass
- the MModelElement
Class for which a constructor is required
meClass
getConstructor(ru.novosoft.uml.foundation.core.MModelElement)
protected java.lang.reflect.Constructor lookupConstructor(java.lang.String stereotypeName)
ModelElement
subclass by
stereotype name. The constructor must
have been registered using setClass( StandardStereotypeDef, Class )
stereotypeName
- the name of the stereotype for which a class is required
stereotypeName
getConstructor(ru.novosoft.uml.foundation.core.MModelElement)
protected void setClass(java.lang.Class nsumlElementClass, java.lang.Class modelElementClass)
ModelElement
subclass to be created for
a subclass of MModelElement
.
nsumlElementClass
- the MModelElement
interface
- this must be an interface, not a classmodelElementClass
- the ModelElement
class to construct,
for nsumlElementClass
This class must have a constructor with two parameters, the first
a subclass of MModelElement
and the second a subclass of ModelElement
Throws:
java.lang.IllegalArgumentException
- if nsumlElementClass
does
not have the correct constructorlookupConstructor(java.lang.Class)
protected void setClass(StandardStereotypeDef stereotypeDef, java.lang.Class modelElementClass)
ModelElement
subclass to be created for
a particular stereotype.
stereotypeDef
- the definition of the stereotype for which a class is being setmodelElementClass
- the ModelElement
class to construct,
for the Stereotype
defined by stereotypeDef
This class must have a constructor with two parameters, the first
a subclass of MModelElement
and the second a subclass of ModelElement
Throws:
java.lang.IllegalArgumentException
- if modelElementClass
does
not have the correct constructorsetClass(StandardStereotypeDef)
,
lookupConstructor(java.lang.Class)
protected void setClass(StandardStereotypeDef stereotypeDef)
ModelElement
subclass to be created for
a particular stereotype. If stereotypeDef
returns null from StandardStereotypeDef.getElementClass()
,
no class is set.
stereotypeDef
- the definition of the stereotype for which a class is being set
for stereotypeName
java.lang.IllegalArgumentException
- if the Class
returned by
StandardStereotypeDef.getElementClass()
does
not have the correct constructorprotected void setClassesForStereotypes(java.lang.Class stereotypeConstantClass)
ModelElement
subclass to be created for
the StandardStereotypeDef
constants in a given class.
stereotypeConstantClass
- the class containing the definitions of the stereotypes
for which a class is being set. The values of all the public static variables of this class
with a type of StandardStereotypeDef
will be used to call setClass(StandardStereotypeDef)
.
java.lang.IllegalArgumentException
- if any StandardStereotypeDef
's modelElementClass
does
not have the correct constructorsetClass(StandardStereotypeDef)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |