org.argouml.model.uml
Class ExtensionMechanismsHelperImpl

java.lang.Object
  extended byorg.argouml.model.uml.ExtensionMechanismsHelperImpl
All Implemented Interfaces:
org.argouml.model.ExtensionMechanismsHelper

class ExtensionMechanismsHelperImpl
extends Object
implements org.argouml.model.ExtensionMechanismsHelper

Helper class for UML Foundation::ExtensionMechanisms Package. Current implementation is a placeholder.

Since:
ARGO0.11.2

Field Summary
private  NSUMLModelImplementation nsmodel
          The model implementation.
 
Constructor Summary
(package private) ExtensionMechanismsHelperImpl(NSUMLModelImplementation implementation)
          Don't allow instantiation.
 
Method Summary
 void addExtendedElement(Object handle, Object extendedElement)
          Add an extended element to a stereotype.
 Collection getAllPossibleStereotypes(Collection models, Object modelElement)
          Returns all possible stereotypes for some modelelement.
protected  String getMetaModelName(Class clazz)
           
 String getMetaModelName(Object m)
           
 Object getStereotype(Collection models, Object stereo)
          Searches for a stereotype just like the given stereotype in all models in the current project.
 Object getStereotype(Object ns, Object stereo)
          Finds a stereotype in some namespace, but not in its subnamespaces.
 Collection getStereotypes(Collection models)
          Get all stereotypes from all Models in the list.
 Collection getStereotypes(Object ns)
          Returns all stereotypes in a namespace, but not those in a subnamespace.
 boolean isStereotype(Object object, String name, String base)
          Tests if a stereotype is a stereotype with some name and base class.
 boolean isStereotypeInh(Object object, String name, String base)
          Tests if a stereotype is or inherits from a stereotype with some name and base class.
private  boolean isValidStereoType(Class clazz, Object stereo)
          This function answers the question: Can we apply the given stereotype to the given class?
 boolean isValidStereoType(Object theModelElement, Object theStereotype)
          Returns true if the given stereotype has a baseclass that equals the baseclass of the given modelelement or one of the superclasses of the given modelelement.
 void setBaseClass(Object handle, Object baseClass)
          Set the baseclass of some stereotype.
 void setIcon(Object handle, Object icon)
          Set the icon for a stereotype.
 void setStereoType(Object modelElement, Object stereotype)
          Sets the stereotype of some modelelement.
 void setTag(Object handle, Object tag)
          Set the Tag of a TaggedValue.
 void setValueOfTag(Object handle, String value)
          Sets a value of some taggedValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nsmodel

private NSUMLModelImplementation nsmodel
The model implementation.

Constructor Detail

ExtensionMechanismsHelperImpl

ExtensionMechanismsHelperImpl(NSUMLModelImplementation implementation)
Don't allow instantiation.

Parameters:
implementation - To get other helpers and factories.
Method Detail

getStereotypes

public Collection getStereotypes(Object ns)
Returns all stereotypes in a namespace, but not those in a subnamespace.

Specified by:
getStereotypes in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
ns - is the namespace.
Returns:
a Collection with the stereotypes.

getStereotype

public Object getStereotype(Object ns,
                            Object stereo)
Finds a stereotype in some namespace, but not in its subnamespaces. Returns null if no such stereotype is found. TODO: What if stereo.getName() or stereo.getBaseClass() is null? Then you know immediately that none will be found, but is that the correct answer?

Specified by:
getStereotype in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
ns - is the namespace.
stereo - is the stereotype.
Returns:
the stereotype found or null.

getStereotype

public Object getStereotype(Collection models,
                            Object stereo)
Searches for a stereotype just like the given stereotype in all models in the current project. The given stereotype can not have its namespace set yet; otherwise it will be returned itself! TODO: Should it only search for stereotypes owned by the Model object?

Specified by:
getStereotype in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
models - a collection of models
stereo - is the given stereotype
Returns:
Stereotype

getMetaModelName

public String getMetaModelName(Object m)
Specified by:
getMetaModelName in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
m - the ModelElement
Returns:
the meta name of the ModelElement

getMetaModelName

protected String getMetaModelName(Class clazz)
Parameters:
clazz - the UML class
Returns:
the meta name of the UML class

getAllPossibleStereotypes

public Collection getAllPossibleStereotypes(Collection models,
                                            Object modelElement)
Returns all possible stereotypes for some modelelement. Possible stereotypes are those stereotypes that are owned by the same namespace the modelelement is owned by and that have a baseclass that is the same as the metamodelelement name of the modelelement.

Specified by:
getAllPossibleStereotypes in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
modelElement - is the model element
models - the models to search in
Returns:
Collection

isValidStereoType

private boolean isValidStereoType(Class clazz,
                                  Object stereo)
This function answers the question: Can we apply the given stereotype to the given class?

Parameters:
clazz - the class we want to apply the stereotype to
stereo - the given stereotype
Returns:
true if the stereotype may be applied

isValidStereoType

public boolean isValidStereoType(Object theModelElement,
                                 Object theStereotype)
Returns true if the given stereotype has a baseclass that equals the baseclass of the given modelelement or one of the superclasses of the given modelelement.

Specified by:
isValidStereoType in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
theModelElement - is the model element
theStereotype - is the stereotype
Returns:
boolean

getStereotypes

public Collection getStereotypes(Collection models)
Get all stereotypes from all Models in the list. Finds only stereotypes owned by the Model objects themselves.

Specified by:
getStereotypes in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
models - the models to search
Returns:
the collection of stereotypes in all models in the current project
Throws:
ClassCastException - if an member in the models is not a Model.

setStereoType

public void setStereoType(Object modelElement,
                          Object stereotype)
Sets the stereotype of some modelelement. The method also copies a stereotype that is not a part of the current model to the current model.

Specified by:
setStereoType in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
modelElement - is the model element
stereotype - is the stereotype

isStereotype

public boolean isStereotype(Object object,
                            String name,
                            String base)
Tests if a stereotype is a stereotype with some name and base class.

Specified by:
isStereotype in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
object - is the stereotype.
name - is the name of the stereotype.
base - is the base class of the stereotype.
Returns:
true if object is a stereotype with the desired characteristics.

isStereotypeInh

public boolean isStereotypeInh(Object object,
                               String name,
                               String base)
Tests if a stereotype is or inherits from a stereotype with some name and base class.

Specified by:
isStereotypeInh in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
object - is the stereotype.
name - is the name of the stereotype.
base - is the base class of the stereotype.
Returns:
true if object is a (descendant of a) stereotype with the desired characteristics.

addExtendedElement

public void addExtendedElement(Object handle,
                               Object extendedElement)
Add an extended element to a stereotype.

Specified by:
addExtendedElement in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
handle - Stereotype
extendedElement - ExtensionPoint

setBaseClass

public void setBaseClass(Object handle,
                         Object baseClass)
Set the baseclass of some stereotype.

Specified by:
setBaseClass in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
handle - the stereotype
baseClass - the baseclass

setIcon

public void setIcon(Object handle,
                    Object icon)
Set the icon for a stereotype.

Specified by:
setIcon in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
handle - Stereotype
icon - String

setTag

public void setTag(Object handle,
                   Object tag)
Set the Tag of a TaggedValue.

Specified by:
setTag in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
handle - TaggedValue
tag - String

setValueOfTag

public void setValueOfTag(Object handle,
                          String value)
Sets a value of some taggedValue.

Specified by:
setValueOfTag in interface org.argouml.model.ExtensionMechanismsHelper
Parameters:
handle - is the tagged value
value - is the value


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook