|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.ashridgetech.jamda.uml.ModelElement
Base class with common functionality for all Jamda UML elements which can be
contained within a Model, and Model itself.
XXX TO Do: check has stereotype if adding stereotype-dependent tags
| Nested Class Summary | |
static class |
ModelElement.DuplicateElementException
Thrown by loadElement(ru.novosoft.uml.foundation.core.MModelElement) to indicate a duplicate element. |
protected static class |
ModelElement.ElementListStore
|
protected static class |
ModelElement.ElementNameListStore
|
protected static class |
ModelElement.ElementNameStore
|
protected static class |
ModelElement.ElementStore
|
class |
ModelElement.TaggedValue
Utility class to hold an Object which is stored in a Tagged Value. |
static class |
ModelElement.UnknownElementException
Thrown by loadElement(ru.novosoft.uml.foundation.core.MModelElement) to indicate an unknown element. |
| Field Summary | |
protected static ModelElement.ElementStore |
DUMMY_STORE
Returned from getSubElementStore(java.lang.Class) to indicate an element will not be stored. |
| Constructor Summary | |
protected |
ModelElement(ru.novosoft.uml.foundation.core.MModelElement me,
ModelElement parent)
Creates new ModelElement during loading. |
| Method Summary | |
protected void |
add(ModelElement me)
Add a child element to this ModelElement. |
void |
addStereotype(Stereotype stereotype)
Adds a Stereotype to this object. |
void |
addTaggedValue(TagDefinition tagDef,
ModelElement newValue)
Add a tagged value to those stored in this element under a certain TagDefinition. |
void |
addTaggedValue(TagDefinition tagDef,
java.lang.String newValue)
Add a Stringtagged value to those stored in this element under a certain TagDefinition. |
void |
addTaggedValues(TagDefinition tagDef,
java.util.Collection newValues)
Add some tagged value(s) to those stored in this element under a certain TagDefinition. |
protected void |
addTaggedValuesInternal(TagDefinition tagDef,
java.util.Collection newValues,
boolean multiple,
boolean replace)
Add a new set of values to a tagged value collection, ensuring that they have the correct type. |
protected void |
checkInitialised()
|
protected void |
checkState(boolean condition,
java.lang.String message)
|
void |
checkValid()
Check whether this object is valid. |
protected java.util.Collection |
findTaggedValueCollection(TagDefinition tagDef,
boolean create)
Get the tagged value collection stored in this element under a certain TagDefinition. |
boolean |
getBooleanTaggedValue(TagDefinition tagDef)
Get the boolean tagged value stored in this element under a certain TagDefinition. |
java.util.List |
getChildElements()
Get all the ModelElements which this one contains. |
java.lang.String |
getComment()
Get the comment for this element, which is all the comments in the model for this element concatenated. |
java.lang.String |
getDescription()
Get a description of this element for logging |
ModelElement |
getDirectSource()
Get the ModelElement which was the immediate source for generating this one, if any. |
protected ModelElement |
getElement(ru.novosoft.uml.foundation.core.MModelElement me)
Get the ModelElement which is the wrapper for a NSUML MModelElement. |
java.lang.String |
getElementType()
Get the name of the type of element. |
java.lang.String |
getFullName()
Get the fully qualified name of this element, including the names of the containing elements up to but excluding the Model or 'Data types' ModelPackage. |
java.lang.String |
getId()
Get the XMI id of this element |
Model |
getModel()
Get the Model to which this package belongs, either directly or indirectly. |
java.lang.String |
getName()
Get the name of this element, excluding the names of the containing elements. |
(package private) ru.novosoft.uml.foundation.core.MModelElement |
getNsElement()
Get the NSUML MModelElement which this object wraps,
as set in the constructor. |
ModelElement |
getOriginalSource()
Get the ModelElement which was the original source for generating this one, if any. |
ModelElement |
getParentElement()
Get the ModelElement which contains this one, if any. |
static java.util.List |
getProperties(java.util.Collection elements)
Get the Propertys for a Collection of PropertyElements. |
java.util.Collection |
getStereotypes()
Get the Stereotypes which apply to this element. |
java.lang.String |
getStringTaggedValue(TagDefinition tagDef)
Get the String tagged value stored in this element under a certain TagDefinition. |
protected ModelElement.ElementStore |
getSubElementStore(java.lang.Class meClass)
Must be overridden by subclasses to return the sub-element ModelElement.ElementStore
into which an object of the class meClass should be stored,
if they wish to store objects of this class. |
java.lang.Object |
getTaggedValue(TagDefinition tagDef)
Get the single tagged value(s) stored in this element under a certain TagDefinition. |
java.util.Collection |
getTaggedValues(TagDefinition tagDef)
Get the tagged value(s) stored in this element under a certain TagDefinition. |
org.apache.commons.jxpath.JXPathContext |
getXpathContext()
Get the XPath context for this ModelElement. |
boolean |
hasStereotype(Stereotype stereotype)
Tests whether this element has a certain Stereotype. |
boolean |
hasTaggedValue(TagDefinition tagDef)
Show whether this element has a tagged value for a certain TagDefinition. |
protected void |
init(java.lang.Class c)
Initialises this object when creating a new object, not loading from a file. |
protected void |
initLoad(java.lang.Class c,
boolean loading)
MUST be called by subclass constructors. |
boolean |
isInitialised()
Show whether this element is fully initialised yet. |
protected void |
load()
|
protected void |
load(java.util.Collection c,
java.lang.String description)
Load all the MModelElements of a given collection. |
protected void |
load(java.util.Collection c,
java.lang.String description,
java.lang.Class elementClass)
Load the MModelElements of a given collection, choosing
those which are instances of a certain class. |
protected ModelElement |
loadElement(ru.novosoft.uml.foundation.core.MModelElement element)
Return the appropriate ModelElement
for the NSUML element being loaded. |
protected void |
logChange(java.lang.String message)
Log a message reporting a change to an element |
protected org.apache.log4j.Logger |
logger()
|
protected static org.apache.log4j.Logger |
logger(java.lang.Class c)
|
protected void |
logLoad(java.lang.String message)
Log a message reporting progress of loading a model. |
protected void |
logLoadWarning(java.lang.String message)
Log a warning message about loading a model. |
protected void |
logNew(java.lang.String message)
Log a message reporting a new element added to a model. |
protected void |
logWarning(java.lang.String message)
Log a general warning message. |
protected void |
removeTaggedValue(TagDefinition tagDef)
Remove the tagged value stored in this element under a certain TagDefinition, if it exists. |
static java.util.List |
select(java.util.Collection c,
Stereotype stereotype)
Select from a collection of ModelElements those
with a given Stereotype. |
void |
setComment(java.lang.String comment)
Set the comment for this element. |
void |
setDirectSource(ModelElement source)
Set the ModelElement which was the immediate source for generating this one, if any. |
void |
setTaggedValue(TagDefinition tagDef,
boolean newValue)
Set the ooleantagged value stored in this element under a certain TagDefinition. |
void |
setTaggedValue(TagDefinition tagDef,
ModelElement newValue)
Set a single tagged value stored in this element under a certain TagDefinition. |
void |
setTaggedValue(TagDefinition tagDef,
java.lang.String newValue)
Set the Stringtagged value stored in this element under a certain TagDefinition. |
void |
setTaggedValues(TagDefinition tagDef,
java.util.Collection newValues)
Set the tagged value(s) stored in this element under a certain TagDefinition. |
Stereotype |
stereotype(StandardStereotypeDef stereotypeDef)
Get a Stereotype from the model using a standard definition. |
TagDefinition |
tag(StandardTagDef tagDef)
Get a tag definition from the model using a standard definition. |
protected java.lang.String |
tagError(java.lang.String description,
TagDefinition tagDef,
java.util.Collection tagColl)
Utility method to get an error message for a tag-related error. |
java.lang.String |
toString()
|
ClassType |
type(StandardClassDef typeDef)
Get a ClassType from the model using a standard definition. |
DataType |
type(StandardDataTypeDef typeDef)
Get a DataType from the model using a standard definition. |
InterfaceType |
type(StandardInterfaceDef typeDef)
Get a InterfaceType from the model using a standard definition. |
java.lang.Object |
xpath(java.lang.String expr)
Evaluate an XPath expression for a single object in the context returned by getXpathContext(). |
java.util.List |
xpathList(java.lang.String expr)
Evaluate an XPath expression for a list of objects in the context returned by getXpathContext(). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static final ModelElement.ElementStore DUMMY_STORE
getSubElementStore(java.lang.Class) to indicate an element will not be stored.
| Constructor Detail |
protected ModelElement(ru.novosoft.uml.foundation.core.MModelElement me,
ModelElement parent)
me - the NSUML element from which this object is being loadedparent - the element which contains this one ( must be null for a Model| Method Detail |
public static java.util.List select(java.util.Collection c,
Stereotype stereotype)
ModelElements those
with a given Stereotype.
c - the Collection from which to select.
Every element must be an object of a subclass of ModelElement.stereotype - the Stereotype by which to select elements
ModelElements in an unmodifiable listpublic static java.util.List getProperties(java.util.Collection elements)
Propertys for a Collection of PropertyElements.
elements - the Collection of elements - all must implement PropertyElement
List of Propertys. The list is modifiable and under the
control of the caller.
protected void initLoad(java.lang.Class c,
boolean loading)
init(java.lang.Class),
which sets loading to false.
c - the STATIC class of the object making the call, from XYZ.class, not getClass()loading - true if this object is being created from an existing NSUML object,
false if it is a completely new objectprotected void init(java.lang.Class c)
c - the STATIC class of the object making the call, from XYZ.class, not getClass()protected void logLoad(java.lang.String message)
protected void logNew(java.lang.String message)
protected void logChange(java.lang.String message)
protected void logLoadWarning(java.lang.String message)
protected void logWarning(java.lang.String message)
public Model getModel()
Model to which this package belongs, either directly or indirectly.
Must be overridden by subclasses which do not have a parent.
public java.lang.String getName()
public java.lang.String getId()
public java.lang.String getFullName()
Model or 'Data types' ModelPackage.
public java.lang.String getComment()
public void setComment(java.lang.String comment)
comment - the new commentpublic java.lang.String getDescription()
public java.util.Collection getStereotypes()
Stereotypes which apply to this element.
Note: this method may not be called until the Model
to which this element belongs is fully initialised.
Stereotype objects
IllegalStateException - if the Model is not initialised#getModelpublic boolean hasStereotype(Stereotype stereotype)
Stereotype.
Note: this method uses getStereotypes() and has
the same restrictions.
stereotype - the Stereotype to test for
StereotypegetStereotypes()public void addStereotype(Stereotype stereotype)
Stereotype to this object.
stereotype - the Stereotype to add
IllegalStateException - if this object already has stereotype#hasStereotypepublic java.util.Collection getTaggedValues(TagDefinition tagDef)
TagDefinition.
tagDef - the TagDefinition whose values are required
Objects. If this element does
not have a tag corresponding to tagDef, returns an empty collection.
If tagDef's TagDefinition.isReferenceType() method returns true,
the collection contains the ModelElements referred to by the tagged values,
otherwise the actual String or Boolean values.hasTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
getTaggedValue(com.ashridgetech.jamda.uml.TagDefinition)public java.lang.Object getTaggedValue(TagDefinition tagDef)
TagDefinition.
tagDef - the TagDefinition whose value is required. Must have
an upper multiplicity of 1.
hasTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
getTaggedValues(com.ashridgetech.jamda.uml.TagDefinition)public boolean getBooleanTaggedValue(TagDefinition tagDef)
TagDefinition.
tagDef - the TagDefinition whose value is required. Must have
an upper multiplicity of 1.
hasTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
getTaggedValue(com.ashridgetech.jamda.uml.TagDefinition)public java.lang.String getStringTaggedValue(TagDefinition tagDef)
String tagged value stored in this element under a certain TagDefinition.
tagDef - the TagDefinition whose value is required. Must have
an upper multiplicity of 1.
hasTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
getTaggedValue(com.ashridgetech.jamda.uml.TagDefinition)public boolean hasTaggedValue(TagDefinition tagDef)
TagDefinition.
tagDef - the TagDefinition whose presence is to be tested
tagDef
public void addTaggedValue(TagDefinition tagDef,
ModelElement newValue)
TagDefinition.
tagDef - the TagDefinition whose values are to be set - must
support multiple values, as defined by its TagDefinition.isMultiple() methodnewValue - the additional value for this tag - must be a permitted value
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValues(com.ashridgetech.jamda.uml.TagDefinition),
addTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection),
addTaggedValue(TagDefinition,String),
setTaggedValue(TagDefinition,ModelElement)
public void addTaggedValue(TagDefinition tagDef,
java.lang.String newValue)
Stringtagged value to those stored in this element under a certain TagDefinition.
tagDef - the TagDefinition whose values are to be set - must
support multiple values, as defined by its TagDefinition.isMultiple() methodnewValue - the additional value for this tag - must be a permitted value
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValues(com.ashridgetech.jamda.uml.TagDefinition),
addTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection),
addTaggedValue(TagDefinition,ModelElement)
public void addTaggedValues(TagDefinition tagDef,
java.util.Collection newValues)
TagDefinition.
tagDef - the TagDefinition whose values are to be setnewValues - the new values for this tag - must be permitted values
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValues(com.ashridgetech.jamda.uml.TagDefinition),
setTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection)
public void setTaggedValue(TagDefinition tagDef,
ModelElement newValue)
TagDefinition.
tagDef - the TagDefinition whose values are to be set - must
support only single values, as defined by its TagDefinition.isMultiple() methodnewValue - the additional value for this tag - must be a permitted value
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
setTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection),
addTaggedValue(TagDefinition,ModelElement),
setTaggedValue(TagDefinition,String),
setTaggedValue(TagDefinition,boolean)
public void setTaggedValue(TagDefinition tagDef,
java.lang.String newValue)
Stringtagged value stored in this element under a certain TagDefinition.
tagDef - the TagDefinition whose values are to be set - must
support only single values, as defined by its TagDefinition.isMultiple() methodnewValue - the additional value for this tag - must be a permitted value
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
setTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection),
addTaggedValue(TagDefinition,String),
setTaggedValue(TagDefinition,ModelElement),
setTaggedValue(TagDefinition,boolean)
public void setTaggedValue(TagDefinition tagDef,
boolean newValue)
ooleantagged value stored in this element under a certain TagDefinition.
tagDef - the TagDefinition whose values are to be set - must
support only single values, as defined by its TagDefinition.isMultiple() methodnewValue - the additional value for this tag - must be a permitted value
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValue(com.ashridgetech.jamda.uml.TagDefinition),
setTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection),
setTaggedValue(TagDefinition,ModelElement),
setTaggedValue(TagDefinition,String)
public void setTaggedValues(TagDefinition tagDef,
java.util.Collection newValues)
TagDefinition.
Clears the collection, then calls addTaggedValuesInternal(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection, boolean, boolean).
tagDef - the TagDefinition whose values are to be setnewValues - the new values for this tag - must be permitted values
for the tagDef, as defined by its TagDefinition.isPermittedValue(java.lang.Object) methodgetTaggedValues(com.ashridgetech.jamda.uml.TagDefinition),
addTaggedValues(com.ashridgetech.jamda.uml.TagDefinition, java.util.Collection)public ModelElement getParentElement()
ModelElement which contains this one, if any.
ModelElement, or null if there is no containing ModelElementpublic java.util.List getChildElements()
ModelElements which this one contains.
List of ModelElementsgetParentElement()public org.apache.commons.jxpath.JXPathContext getXpathContext()
ModelElement.
xpath(java.lang.String)public java.lang.Object xpath(java.lang.String expr)
getXpathContext().
expr - the expression to evaluate
public java.util.List xpathList(java.lang.String expr)
getXpathContext().
expr - the expression to evaluate
public ModelElement getDirectSource()
ModelElement which was the immediate source for generating this one, if any.
ModelElement, or null if there is no source ModelElementpublic ModelElement getOriginalSource()
ModelElement which was the original source for generating this one, if any.
This is found by following the chain of source elements until an element with no source is found.
ModelElement, or this element if there is no source ModelElementpublic void setDirectSource(ModelElement source)
ModelElement which was the immediate source for generating this one, if any.
This method may only be called once on each instance of this class.
source - the source ModelElement - may not be null
IllegalStateException - if this method has already been calledpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getElementType()
public boolean isInitialised()
public void checkValid()
throws java.lang.IllegalStateException
IllegalStateException - if a problem is foundpublic TagDefinition tag(StandardTagDef tagDef)
tagDef - the StandardTagDef
for the required TagDefinitionpublic DataType type(StandardDataTypeDef typeDef)
DataType from the model using a standard definition.
typeDef - the StandardDataTypeDef
for the required DataTypepublic ClassType type(StandardClassDef typeDef)
ClassType from the model using a standard definition.
typeDef - the StandardClassDef
for the required ClassTypepublic InterfaceType type(StandardInterfaceDef typeDef)
InterfaceType from the model using a standard definition.
typeDef - the StandardInterfaceDef
for the required InterfaceTypepublic Stereotype stereotype(StandardStereotypeDef stereotypeDef)
Stereotype from the model using a standard definition.
stereotypeDef - the StandardStereotypeDef
for the required Stereotype
protected void checkState(boolean condition,
java.lang.String message)
protected void checkInitialised()
protected ModelElement getElement(ru.novosoft.uml.foundation.core.MModelElement me)
ModelElement which is the wrapper for a NSUML MModelElement.
Looks it up in the Model using its XMI id and checks it exists.
me - the NSUML MModelElement which backs the desired element
me
IllegalStateException - if there is no wrapper element for meModel.getElementById(java.lang.String)ru.novosoft.uml.foundation.core.MModelElement getNsElement()
MModelElement which this object wraps,
as set in the constructor. Package scope only.
protected java.util.Collection findTaggedValueCollection(TagDefinition tagDef,
boolean create)
TagDefinition.
tagDef - the TagDefinition whose values are requiredcreate - if true, a new tagged value collection is created if one does not
already exist
MTaggedValue,
as appropriate to the MTagDefinition.
If this element does not have a tag correpsonding to tagDef, return null.
IllegalStateException - if the collections are not as expectedprotected void removeTaggedValue(TagDefinition tagDef)
TagDefinition, if it exists.
tagDef - the TagDefinition whose values are to be removed
If this element does not have a tag correpsonding to tagDef, there is no action.
protected void addTaggedValuesInternal(TagDefinition tagDef,
java.util.Collection newValues,
boolean multiple,
boolean replace)
tagDef - the TagDefinition whose values are to be setnewValues - the new values for this tag - may be empty, must not be nullmultiple - if true, tagDef must allow multiple valuesreplace - if true, the new values replace the old onesprotected void add(ModelElement me)
ModelElement.
me - The ModelElement to be added to the map
Must not be null and its name property must not be null
AssertionException - if mp does not belong to this ModelElementprotected ModelElement.ElementStore getSubElementStore(java.lang.Class meClass)
ModelElement.ElementStore
into which an object of the class meClass should be stored,
if they wish to store objects of this class.
This implementation returns null, to indicate the object is not known.
DUMMY_STORE if the object is deliberately not stored,
or null if the object is not known.
protected ModelElement loadElement(ru.novosoft.uml.foundation.core.MModelElement element)
throws ModelElement.UnknownElementException
ModelElement
for the NSUML element being loaded. This implementation
uses Model.createElement(ru.novosoft.uml.foundation.core.MModelElement, com.ashridgetech.jamda.uml.ModelElement).
element - the NSUML element
ModelElement
ModelElement.UnknownElementException - if no ModelElement can be created for element,
unless the element is a tagged value
ModelElement.UnknownElementExceptionprotected void load()
protected void load(java.util.Collection c,
java.lang.String description)
MModelElements of a given collection.
Calls loadElement(ru.novosoft.uml.foundation.core.MModelElement) for each one.
c - the MModelElements to loaddescription - description of the MModelElements to load
protected void load(java.util.Collection c,
java.lang.String description,
java.lang.Class elementClass)
MModelElements of a given collection, choosing
those which are instances of a certain class.
Calls loadElement(ru.novosoft.uml.foundation.core.MModelElement) for each one.
c - the MModelElements to loaddescription - description of the MModelElements to loadelementClass - the class of the MModelElements to load,
or null to load all elements in the collectionprotected org.apache.log4j.Logger logger()
protected static org.apache.log4j.Logger logger(java.lang.Class c)
protected java.lang.String tagError(java.lang.String description,
TagDefinition tagDef,
java.util.Collection tagColl)
description - description of the problemtagDef - the TagDefinition concernedtagColl - the collection of tagged values
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||