org.argouml.model.uml.modelmanagement
Class ModelManagementHelper

java.lang.Object
  |
  +--org.argouml.model.uml.modelmanagement.ModelManagementHelper

public class ModelManagementHelper
extends java.lang.Object

Helper class for UML ModelManagement Package.

Current implementation is a placeholder.

Since:
ARGO0.11.2

Field Summary
protected static Logger cat
          Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.
private static ModelManagementHelper SINGLETON
          Singleton instance.
 
Constructor Summary
private ModelManagementHelper()
          Don't allow instantiation.
 
Method Summary
 boolean corresponds(MModelElement obj1, MModelElement obj2)
          Tests if two objects are of the same type, have the same name and the same relative position in the model.
 java.util.Collection getAllModelElementsOfKind(java.lang.Class kind)
          Returns all modelelements found in this namespace and its children that are of some class kind the projectbrowser model
 java.util.Collection getAllModelElementsOfKind(java.lang.Object nsa, java.lang.Class kind)
          Returns all modelelements found in this namespace and its children that are of some class kind.
 java.util.Collection getAllModelElementsOfKind(java.lang.Object nsa, java.lang.String kind)
          helper method for getAllModelElementsOfKind(Object, Class)
 java.util.Collection getAllNamespaces()
          Returns all namespaces found in the projectbrowser model
 java.util.Collection getAllNamespaces(java.lang.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.
 java.util.Collection getAllSubSystems()
          Returns all subsystems found in the projectbrowser model
 java.util.Collection getAllSubSystems(MNamespace ns)
          Returns all subsystems found in this namespace and in its children
 java.util.Collection getAllSurroundingNamespaces(MNamespace ns)
          Returns all surrounding namespaces of some namespace ns.
 java.lang.Object getCorrespondingElement(java.lang.Object elem, java.lang.Object model)
          Utility function for managing several overlayed models, eg a user model to which elements from some profile models is imported when needed.
 java.lang.Object getCorrespondingElement(java.lang.Object elem, java.lang.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.
 MModelElement getElement(java.util.Vector path, java.lang.Object rt)
           
static ModelManagementHelper getHelper()
          Singleton instance access method.
private  java.util.List getOwnerShipPath(java.lang.Object elem)
           
 java.util.Vector getPath(java.lang.Object element)
          Finds the absolute path of a ModelElement.
 boolean isCyclicOwnership(java.lang.Object parent, java.lang.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

cat

protected static Logger cat
Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.


SINGLETON

private static ModelManagementHelper SINGLETON
Singleton instance.

Constructor Detail

ModelManagementHelper

private ModelManagementHelper()
Don't allow instantiation.

Method Detail

getHelper

public static ModelManagementHelper getHelper()
Singleton instance access method.


getAllSubSystems

public java.util.Collection getAllSubSystems()
Returns all subsystems found in the projectbrowser model

Returns:
Collection

getAllSubSystems

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

Parameters:
ns - is the namespace
Returns:
Collection

getAllNamespaces

public java.util.Collection getAllNamespaces()
Returns all namespaces found in the projectbrowser model

Returns:
Collection

getAllNamespaces

public java.util.Collection getAllNamespaces(java.lang.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.

Parameters:
ns - namespace to process
Returns:
Collection of all namespaces found

getAllModelElementsOfKind

public java.util.Collection getAllModelElementsOfKind(java.lang.Class kind)
Returns all modelelements found in this namespace and its children that are of some class kind the projectbrowser model

Parameters:
kind - is the class kind
Returns:
Collection

getAllModelElementsOfKind

public java.util.Collection getAllModelElementsOfKind(java.lang.Object nsa,
                                                      java.lang.Class kind)
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.

Parameters:
nsa - is the namespace
kind - is the class kind
Returns:
Collection

getAllModelElementsOfKind

public java.util.Collection getAllModelElementsOfKind(java.lang.Object nsa,
                                                      java.lang.String kind)
helper method for getAllModelElementsOfKind(Object, Class)

Parameters:
nsa - namespace.
kind - name of class to find, this implementation will add the "M" for NSUML.
Returns:
a Collection.

getAllSurroundingNamespaces

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

Parameters:
ns - to process
Returns:
Collection of surrounding namespaces.

getElement

public MModelElement getElement(java.util.Vector path,
                                java.lang.Object rt)

getPath

public java.util.Vector getPath(java.lang.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.

Parameters:
element - is the object to resolve the path for.
Returns:
A Vector as described above.
Throws:
java.lang.IllegalArgumentException - if element isn't a ModelElement properly owned by namespaces and a model.

getCorrespondingElement

public java.lang.Object getCorrespondingElement(java.lang.Object elem,
                                                java.lang.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.

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 java.lang.Object getCorrespondingElement(java.lang.Object elem,
                                                java.lang.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.

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(MModelElement obj1,
                           MModelElement 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.

Parameters:
obj1 - is an object.
obj2 - is another object.
Returns:
true if obj1 corresponds to obj2, false otherwise.

isCyclicOwnership

public boolean isCyclicOwnership(java.lang.Object parent,
                                 java.lang.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.

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 java.util.List getOwnerShipPath(java.lang.Object elem)


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