org.argouml.model.uml
Class ModelManagementHelperImpl

java.lang.Object
  extended byorg.argouml.model.uml.ModelManagementHelperImpl
All Implemented Interfaces:
org.argouml.model.ModelManagementHelper

class ModelManagementHelperImpl
extends Object
implements org.argouml.model.ModelManagementHelper

Helper class for UML ModelManagement Package.

Current implementation is a placeholder.

Since:
ARGO0.11.2

Field Summary
private static Logger LOG
          Logger.
private  NSUMLModelImplementation nsmodel
          The model implementation.
 
Constructor Summary
(package private) ModelManagementHelperImpl(NSUMLModelImplementation implementation)
          Don't allow instantiation.
 
Method Summary
 boolean corresponds(Object obj1, Object obj2)
          Tests if two objects are of the same type, have the same name and the same relative position in the model.
 Collection getAllBehavioralFeatures(Object ns)
           
 Collection getAllModelElementsOfKind(Object nsa, Object type)
          Returns all modelelements found in this namespace and its children that are of some class kind.
 Collection getAllModelElementsOfKind(Object nsa, String kind)
          Helper method for #getAllModelElementsOfKind(Object, Class).
 Collection getAllModelElementsOfKindWithModel(Object model, Object type)
          Returns all modelelements of the given kind.
 Collection getAllNamespaces(Object ns)
          Returns all namespaces found in this namespace and in its children This method is CPU intensive and therefore needs to be as efficient as possible.
 Collection getAllSubSystems(Object ns)
          Returns all subsystems found in this namespace and in its children.
 Collection getAllSurroundingNamespaces(Object ns)
          Returns all surrounding namespaces of some namespace ns.
 Object getCorrespondingElement(Object elem, Object model)
          Utility function for managing several overlayed models, eg a user model to which elements from some profile models is imported when needed.
 Object getCorrespondingElement(Object elem, Object model, boolean canCreate)
          Utility function for managing several overlayed models, eg a user model to which elements from some profile models is imported when needed.
 Object getElement(Vector path, Object theRootNamespace)
          Get the modelelement a given path below a given root-namespace.
private  List getOwnerShipPath(Object elem)
           
 Vector getPath(Object element)
          Finds the absolute path of a ModelElement.
 boolean isCyclicOwnership(Object parent, Object child)
          Checks if a child for some ownershiprelationship (as in a namespace A is owned by a namespace B) is allready in the ownerhship relation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Logger LOG
Logger.


nsmodel

private NSUMLModelImplementation nsmodel
The model implementation.

Constructor Detail

ModelManagementHelperImpl

ModelManagementHelperImpl(NSUMLModelImplementation implementation)
Don't allow instantiation.

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

getAllSubSystems

public Collection getAllSubSystems(Object ns)
Returns all subsystems found in this namespace and in its children.

Specified by:
getAllSubSystems in interface org.argouml.model.ModelManagementHelper
Parameters:
ns - is the namespace
Returns:
Collection

getAllNamespaces

public Collection getAllNamespaces(Object ns)
Returns all namespaces found in this namespace and in its children This method is CPU intensive and therefore needs to be as efficient as possible.

Specified by:
getAllNamespaces in interface org.argouml.model.ModelManagementHelper
Parameters:
ns - namespace to process
Returns:
Collection of all namespaces found

getAllModelElementsOfKindWithModel

public Collection getAllModelElementsOfKindWithModel(Object model,
                                                     Object type)
Returns all modelelements of the given kind.

Specified by:
getAllModelElementsOfKindWithModel in interface org.argouml.model.ModelManagementHelper
Parameters:
model - The model where we search.
type - is the class kind
Returns:
Collection

getAllModelElementsOfKind

public Collection getAllModelElementsOfKind(Object nsa,
                                            Object type)
Returns all modelelements found in this namespace and its children that are of some class kind.

This method is CPU intensive and therefore needs to be as efficient as possible.

Specified by:
getAllModelElementsOfKind in interface org.argouml.model.ModelManagementHelper
Parameters:
nsa - is the namespace
type - is the class kind
Returns:
Collection

getAllModelElementsOfKind

public Collection getAllModelElementsOfKind(Object nsa,
                                            String kind)
Helper method for #getAllModelElementsOfKind(Object, Class).

Specified by:
getAllModelElementsOfKind in interface org.argouml.model.ModelManagementHelper
Parameters:
nsa - namespace.
kind - name of class to find, this implementation will add the "M" for NSUML.
Returns:
a Collection.

getAllSurroundingNamespaces

public Collection getAllSurroundingNamespaces(Object ns)
Returns all surrounding namespaces of some namespace ns. See section 2.5.3.24 of the UML 1.3 spec for a definition.

Specified by:
getAllSurroundingNamespaces in interface org.argouml.model.ModelManagementHelper
Parameters:
ns - to process
Returns:
Collection of surrounding namespaces.

getAllBehavioralFeatures

public Collection getAllBehavioralFeatures(Object ns)
Specified by:
getAllBehavioralFeatures in interface org.argouml.model.ModelManagementHelper
Parameters:
ns - the given namespace
Returns:
a collection of all behavioralfeatures in the given namespace

getElement

public Object getElement(Vector path,
                         Object theRootNamespace)
Get the modelelement a given path below a given root-namespace.

Specified by:
getElement in interface org.argouml.model.ModelManagementHelper
Parameters:
path - the given path
theRootNamespace - the given namespace to start from
Returns:
the modelelement looked for, or null if not found

getPath

public Vector getPath(Object element)
Finds the absolute path of a ModelElement. Ie the name of each namespace starting at the root (the Model) and ending with the name of the element.

The returned Vector implicitly starts at the root (the model) and follows element's chain of owning namespaces back down to element. The first element will thus be the name of the top level namespace below the model, and the last element will be the name of element itself. Note thus that for the model the path will be empty.

Specified by:
getPath in interface org.argouml.model.ModelManagementHelper
Parameters:
element - is the object to resolve the path for.
Returns:
A Vector as described above.
Throws:
IllegalArgumentException - if element isn't a ModelElement properly owned by namespaces and a model.

getCorrespondingElement

public Object getCorrespondingElement(Object elem,
                                      Object model)
Utility function for managing several overlayed models, eg a user model to which elements from some profile models is imported when needed. This version of the function assumes it is permissible to create missing elements. This function may fail and return null eg if some required object doesn't exist in the target model and cannot be copied.

Specified by:
getCorrespondingElement in interface org.argouml.model.ModelManagementHelper
Parameters:
elem - is some element.
model - is the model the returned object shall belong to.
Returns:
An element of the same type and at the same position in the model as elem, or if that would turn out impossible then null.

getCorrespondingElement

public Object getCorrespondingElement(Object elem,
                                      Object model,
                                      boolean canCreate)
Utility function for managing several overlayed models, eg a user model to which elements from some profile models is imported when needed. This version of the function will only copy objects if canCreate is true, but may then also copy other missing elements. This function may fail and return null eg if the required object doesn't exist in the target model and canCreate is false or some required object doesn't exist in the target model and cannot be copied.

Specified by:
getCorrespondingElement in interface org.argouml.model.ModelManagementHelper
Parameters:
elem - is some element.
model - is the model the returned object shall belong to.
canCreate - determines if objects can be copied into model.
Returns:
An element of the same type and at the same position in the model as elem, or if that would turn out impossible then null.

corresponds

public boolean corresponds(Object obj1,
                           Object obj2)
Tests if two objects are of the same type, have the same name and the same relative position in the model. Same relative position implies either: * their owners correspond to eachother. * they are both owned by model objects.

Specified by:
corresponds in interface org.argouml.model.ModelManagementHelper
Parameters:
obj1 - is an object.
obj2 - is another object.
Returns:
true if obj1 corresponds to obj2, false otherwise.

isCyclicOwnership

public boolean isCyclicOwnership(Object parent,
                                 Object child)
Checks if a child for some ownershiprelationship (as in a namespace A is owned by a namespace B) is allready in the ownerhship relation.

Specified by:
isCyclicOwnership in interface org.argouml.model.ModelManagementHelper
Parameters:
parent - The current leaf for the ownership relation
child - The child that should be owned by the parent
Returns:
true if the child is allready in the ownership relationship

getOwnerShipPath

private List getOwnerShipPath(Object elem)


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