org.argouml.model.uml.foundation.core
Class CoreHelper

java.lang.Object
  |
  +--org.argouml.model.uml.foundation.core.CoreHelper

public class CoreHelper
extends java.lang.Object

Helper class for UML Foundation::Core 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 CoreHelper SINGLETON
          Singleton instance.
 
Constructor Summary
private CoreHelper()
          Don't allow instantiation.
 
Method Summary
 MDependency buildSupportDependency(MModelElement from, MModelElement to)
          Builds a dependency with stereotype support.
 boolean equalsAggregationKind(java.lang.Object associationEnd, java.lang.String kindType)
           
 java.util.Collection getAllAttributes(MClassifier clazz)
          Returns all attributes of some classifier and of its parents.
 java.util.Collection getAllBehavioralFeatures()
          Returns all behavioralfeatures found in the projectbrowser model
 java.util.Collection getAllBehavioralFeatures(MModelElement element)
          Returns all behavioralfeatures found in this element and its children.
 java.util.Collection getAllClasses()
          Returns all classes found in the projectbrowser model.
 java.util.Collection getAllClasses(MNamespace ns)
          Returns all classes found in this namespace and in its children.
 java.util.Collection getAllClassifiers()
          Returns all classifiers found in the projectbrowser model
 java.util.Collection getAllClassifiers(MNamespace ns)
          Returns all classifiers found in this namespace and in its children
 java.util.Collection getAllComponents()
          Returns all components found in the projectbrowser model
 java.util.Collection getAllComponents(MNamespace ns)
          Returns all components found in this namespace and in its children.
 java.util.Collection getAllContents(MClassifier clazz)
          Returns the contents (owned elements) of this classifier and all its parents as specified in section 2.5.3.8 of the UML 1.3 spec.
 java.util.Collection getAllDataTypes()
          Returns all datatypes found in the projectbrowser model.
 java.util.Collection getAllDataTypes(MNamespace ns)
          Returns all components found in this namespace and in its children.
 java.util.Collection getAllInterfaces()
          Returns all interfaces found in the projectbrowser model
 java.util.Collection getAllInterfaces(MNamespace ns)
          Returns all interfaces found in this namespace and in its children
 java.util.Collection getAllNodes()
          Returns all nodes found in the projectbrowser model
 java.util.Collection getAllNodes(MNamespace ns)
          Returns all components found in this namespace and in its children.
 java.util.Collection getAllPossibleNamespaces(java.lang.Object modelElement)
          Returns all possible namespaces that may be selected by some given modelelement.
 java.util.Collection getAllRealizedInterfaces(java.lang.Object o)
          Returns all interfaces that are realized by the given class or by its superclasses.
 java.util.Collection getAllSupertypes(java.lang.Object cls1)
          This method returns all Classifiers of which this class is a direct or indirect subtype.
 java.util.Collection getAssociatedClassifiers(java.lang.Object aclassifier)
          Gets all classifiers that are associated to the given classifier (have an association relationship with the classifier).
 java.util.Collection getAssociateEnds(MClassifier classifier)
          This method returns all opposite AssociationEnds of a given Classifier
 java.util.Collection getAssociateEndsInh(java.lang.Object classifier1)
          This method returns all opposite AssociationEnds of a given Classifier, including inherited
 MAssociationEnd getAssociationEnd(MClassifier type, MAssociation assoc)
          Returns the associationend between a classifier and an associaton.
 java.util.Collection getAssociations(java.lang.Object oclassifier)
          Returns all associations for some classifier.
 java.util.Collection getAssociations(java.lang.Object from, java.lang.Object to)
          Gets the associations between the classifiers from and to.
 java.util.Collection getAttributes(MClassifier classifier)
          This method returns all attributes of a given Classifier.
 java.util.Collection getAttributesInh(java.lang.Object classifier)
          This method returns all attributes of a given Classifier, including inherited
 java.util.Collection getBaseClasses(java.lang.Object o)
          Returns the base classes (that are the classes that do not have any generalizations) for some given namespace.
private  void getChildren(java.util.Collection currentChildren, MGeneralization gen)
          Adds all children recursively to the Collection in the first argument.
 java.util.Collection getChildren(java.lang.Object o)
          Returns all children from some given generalizableelement on all levels (the complete tree excluding the generalizable element itself).
private  MNamespace getCurrentModel()
          Get the current model.
 java.util.Collection getDependencies(java.lang.Object supplierObj, java.lang.Object clientObj)
          Returns the dependencies between some supplier modelelement and some client modelelement.
 java.lang.Object getDestination(java.lang.Object relationship)
          Returns the destination of a relation.
 java.util.Collection getExtendedClassifiers(java.lang.Object clazz)
          Returns all classes some generalizable element extends.
 java.util.Collection getExtendingClassifiers(MClassifier clazz)
          Returns all classifiers that extend some classifier.
 java.util.Collection getExtendingElements(java.lang.Object clazz)
          Returns all elements that extend some class.
 java.lang.String getFeatureName(java.lang.Object o)
          This method returns the name of a feature.
 MNamespace getFirstSharedNamespace(MNamespace ns1, MNamespace ns2)
          Gets the first namespace two namespaces share.
 java.util.Collection getFlows(MModelElement source, MModelElement target)
          Returns all flows from some source modelelement to a target modelelement.
 MGeneralization getGeneralization(java.lang.Object achild, java.lang.Object aparent)
          Gets the generalization between two generalizable elements.
static CoreHelper getHelper()
          Singleton instance access method.
 java.util.Collection getOperations(java.lang.Object classifier)
          This method returns all operations of a given Classifier
 java.util.Collection getOperationsInh(MClassifier classifier)
          This method returns all operations of a given Classifier, including inherited
 java.util.Collection getRealizedInterfaces(MClassifier classifier)
          Return all interfaces the given class realizes.
 java.util.Collection getRelationships(MModelElement source, MModelElement dest)
          Returns all relationships between the source and dest modelelement and vica versa.
 MParameter getReturnParameter(java.lang.Object operation1)
          This method finds all paramters of the given operation which have the MParamterDirectionType RETURN.
 java.util.Collection getReturnParameters(java.lang.Object operation)
          Returns all return parameters for an operation.
 java.lang.Object getSource(java.lang.Object relationship)
          Returns the source of a relation.
 MOperation getSpecification(java.lang.Object object)
          Returns the operation that some method realized.
 java.util.Collection getSpecifications(java.lang.Object classifier)
          Returns all Interfaces of which this class is a realization.
 java.util.Collection getSubtypes(MClassifier cls)
          This method returns all Classifiers of which this class is a direct supertype.
 java.util.Collection getSupertypes(java.lang.Object ogeneralizableelement)
          This method returns all Classifiers of which this class is a direct subtype.
 boolean hasCompositeEnd(java.lang.Object association)
           
private  java.util.Collection internalGetAllRealizedInterfaces(java.lang.Object o, java.util.Collection col, java.util.Set visited)
          Helper method for getAllRealizedInterfaces.
 boolean isMethod(java.lang.Object o)
          This method returns if the object is a method.
 boolean isOperation(java.lang.Object o)
          This method returns if the object is an operation.
 boolean isValidNamespace(java.lang.Object mObj, java.lang.Object nsObj)
          Returns true if some modelelement may be owned by the given namespace.
 void removeFeature(java.lang.Object cls, java.lang.Object feature)
          This method removes a feature from a classifier.
 void setReturnParameter(java.lang.Object operation, java.lang.Object newReturnParameter)
          Build a returnparameter.
 
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 CoreHelper SINGLETON
Singleton instance.

Constructor Detail

CoreHelper

private CoreHelper()
Don't allow instantiation.

Method Detail

getHelper

public static CoreHelper getHelper()
Singleton instance access method.


getAllSupertypes

public java.util.Collection getAllSupertypes(java.lang.Object cls1)
This method returns all Classifiers of which this class is a direct or indirect subtype.

Parameters:
cls1 - the class you want to have the parents for
Returns:
a collection of the parents, each of which is a MGeneralizableElement

getSupertypes

public java.util.Collection getSupertypes(java.lang.Object ogeneralizableelement)
This method returns all Classifiers of which this class is a direct subtype.

Parameters:
ogeneralizableelement - the class you want to have the parents for
Returns:
a collection of the parents, each of which is a MGeneralizableElement

getAssociateEnds

public java.util.Collection getAssociateEnds(MClassifier classifier)
This method returns all opposite AssociationEnds of a given Classifier

Parameters:
classifier - the classifier you want to have the opposite association ends for
Returns:
a collection of the opposite associationends

getAssociateEndsInh

public java.util.Collection getAssociateEndsInh(java.lang.Object classifier1)
This method returns all opposite AssociationEnds of a given Classifier, including inherited

Parameters:
classifier1 - the classifier you want to have the opposite association ends for
Returns:
a collection of the opposite associationends

removeFeature

public void removeFeature(java.lang.Object cls,
                          java.lang.Object feature)
This method removes a feature from a classifier.

Parameters:
cls -
feature -

getFeatureName

public java.lang.String getFeatureName(java.lang.Object o)
This method returns the name of a feature.

Parameters:
o - is the feature
Returns:
name

isMethod

public boolean isMethod(java.lang.Object o)
This method returns if the object is a method.

Parameters:
o - object
Returns:
true if it's a method, false if not

isOperation

public boolean isOperation(java.lang.Object o)
This method returns if the object is an operation.

Parameters:
o - object
Returns:
true if it's an operation, false if not

getOperations

public java.util.Collection getOperations(java.lang.Object classifier)
This method returns all operations of a given Classifier

Parameters:
classifier - the classifier you want to have the operations for
Returns:
a collection of the operations

getAttributes

public java.util.Collection getAttributes(MClassifier classifier)
This method returns all attributes of a given Classifier.

Parameters:
classifier - the classifier you want to have the attributes for
Returns:
a collection of the attributes

getAttributesInh

public java.util.Collection getAttributesInh(java.lang.Object classifier)
This method returns all attributes of a given Classifier, including inherited

Parameters:
classifier - the classifier you want to have the attributes for
Returns:
a collection of the attributes

getOperationsInh

public java.util.Collection getOperationsInh(MClassifier classifier)
This method returns all operations of a given Classifier, including inherited

Parameters:
classifier - the classifier you want to have the operations for
Returns:
a collection of the operations

getReturnParameter

public MParameter getReturnParameter(java.lang.Object operation1)
This method finds all paramters of the given operation which have the MParamterDirectionType RETURN. If it is only one, it is returned. In case there are no return parameters, null is returned. If there is more than one return paramter, first of them is returned, but a message is logged.

Parameters:
operation1 - the operation you want to find the return parameter for.
Returns:
If this operation has only one paramter with Kind: RETURN, this is it, otherwise null

getReturnParameters

public java.util.Collection getReturnParameters(java.lang.Object operation)
Returns all return parameters for an operation.

Parameters:
operation - is the operation.
Returns:
Collection

getSpecification

public MOperation getSpecification(java.lang.Object object)
Returns the operation that some method realized. Returns null if object isn't a method or, possibly, if the method isn't properly defined.

Parameters:
object - the method you want the realized operation of.
Returns:
an operation, or null.

getSpecifications

public java.util.Collection getSpecifications(java.lang.Object classifier)
Returns all Interfaces of which this class is a realization.

Parameters:
classifier - the class you want to have the interfaces for
Returns:
a collection of the Interfaces

getSubtypes

public java.util.Collection getSubtypes(MClassifier cls)
This method returns all Classifiers of which this class is a direct supertype.

Parameters:
cls - the class you want to have the children for
Returns:
a collection of the children, each of which is a MGeneralizableElement

setReturnParameter

public void setReturnParameter(java.lang.Object operation,
                               java.lang.Object newReturnParameter)
Build a returnparameter. Removes all current return parameters from the operation and adds the supplied parameter. The directionkind of the parameter will be return. The name will be equal to the name of the last found return parameter or the default value "return" if no return parameter was present in the operation.

Parameters:
operation - is the operation
newReturnParameter - is the return parameter.

buildSupportDependency

public MDependency buildSupportDependency(MModelElement from,
                                          MModelElement to)
Builds a dependency with stereotype support.

Parameters:
from - is the model element where the dependency begins
to - is the model element where dependency ends
Returns:
a newly created dependency.

getAllBehavioralFeatures

public java.util.Collection getAllBehavioralFeatures(MModelElement element)
Returns all behavioralfeatures found in this element and its children.

Parameters:
element - is the element
Returns:
Collection

getAllBehavioralFeatures

public java.util.Collection getAllBehavioralFeatures()
Returns all behavioralfeatures found in the projectbrowser model

Returns:
Collection

getAllInterfaces

public java.util.Collection getAllInterfaces()
Returns all interfaces found in the projectbrowser model

Returns:
Collection

getAllInterfaces

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

Returns:
Collection

getAllClasses

public java.util.Collection getAllClasses()
Returns all classes found in the projectbrowser model.

Returns:
Collection

getAllClasses

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

Parameters:
ns - is the namespace.
Returns:
Collection

getRealizedInterfaces

public java.util.Collection getRealizedInterfaces(MClassifier classifier)
Return all interfaces the given class realizes.

Parameters:
classifier - is the class
Returns:
Collection

getExtendedClassifiers

public java.util.Collection getExtendedClassifiers(java.lang.Object clazz)
Returns all classes some generalizable element extends.

Parameters:
clazz - is the generalizable element
Returns:
Collection

getGeneralization

public MGeneralization getGeneralization(java.lang.Object achild,
                                         java.lang.Object aparent)
Gets the generalization between two generalizable elements. Returns null if there is none.

Parameters:
achild - is the child generalizable element.
aparent - is the parent generalizable element.
Returns:
MGeneralization

getFlows

public java.util.Collection getFlows(MModelElement source,
                                     MModelElement target)
Returns all flows from some source modelelement to a target modelelement.

Parameters:
source - is the source model element.
target - is the target model element.
Returns:
Collection

getExtendingElements

public java.util.Collection getExtendingElements(java.lang.Object clazz)
Returns all elements that extend some class.

Parameters:
clazz - is the class (a generalizable element)
Returns:
Collection

getExtendingClassifiers

public java.util.Collection getExtendingClassifiers(MClassifier clazz)
Returns all classifiers that extend some classifier.

Parameters:
clazz - is the classifier.
Returns:
Collection

getAllComponents

public java.util.Collection getAllComponents()
Returns all components found in the projectbrowser model

Returns:
Collection

getAllComponents

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

Parameters:
ns - is the namespace.
Returns:
Collection

getAllDataTypes

public java.util.Collection getAllDataTypes()
Returns all datatypes found in the projectbrowser model.

Returns:
Collection

getAllDataTypes

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

Parameters:
ns - is the namespace
Returns:
Collection

getAllNodes

public java.util.Collection getAllNodes()
Returns all nodes found in the projectbrowser model

Returns:
Collection

getAllNodes

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

Parameters:
ns - is the namespace
Returns:
Collection

getAssociatedClassifiers

public java.util.Collection getAssociatedClassifiers(java.lang.Object aclassifier)
Gets all classifiers that are associated to the given classifier (have an association relationship with the classifier).

Parameters:
aclassifier - an MClassifier
Returns:
Collection

getAssociations

public java.util.Collection getAssociations(java.lang.Object from,
                                            java.lang.Object to)
Gets the associations between the classifiers from and to. Returns null if from or to is null or if there is no association between them.

Parameters:
from - a classifier
to - a classifier
Returns:
MAssociation

getAllClassifiers

public java.util.Collection getAllClassifiers()
Returns all classifiers found in the projectbrowser model

Returns:
Collection

getAllClassifiers

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

Returns:
Collection

getAssociations

public java.util.Collection getAssociations(java.lang.Object oclassifier)
Returns all associations for some classifier.

Parameters:
oclassifier -
Returns:
Collection

getAssociationEnd

public MAssociationEnd getAssociationEnd(MClassifier type,
                                         MAssociation assoc)
Returns the associationend between a classifier and an associaton.

Parameters:
type - is the classifier
assoc - is the association
Returns:
MAssociationEnd

getAllContents

public java.util.Collection getAllContents(MClassifier clazz)
Returns the contents (owned elements) of this classifier and all its parents as specified in section 2.5.3.8 of the UML 1.3 spec.

Parameters:
clazz - is the classifier
Returns:
Collection

getAllAttributes

public java.util.Collection getAllAttributes(MClassifier clazz)
Returns all attributes of some classifier and of its parents.

Parameters:
clazz - is the classifier
Returns:
Collection

getSource

public java.lang.Object getSource(java.lang.Object relationship)
Returns the source of a relation. The source of a relation is defined as the modelelement that propagates this relation. If there are more then 1 sources, only the first is returned. If there is no source, null is returned. Examples of sources include classifiers that are types to associationends, usecases that are bases to extend and include relations and so on. A source is allways the start from the arrow in the fig, the destination the end.

This method also works to get the source of a Link.

Parameters:
relationship - is the relation
Returns:
Object

getDestination

public java.lang.Object getDestination(java.lang.Object relationship)
Returns the destination of a relation. The destination of a relation is defined as the modelelement that receives this relation. If there are more then 1 destinations, only the first is returned. If there is no destination, null is returned. Examples of sources include classifiers that are types to associationends, usecases that are bases to extend and include relations and so on. In the case of an association, the destination is defined as the type of the second element in the connections list.

This method also works for links.

Parameters:
relationship - is the relation
Returns:
object

getDependencies

public java.util.Collection getDependencies(java.lang.Object supplierObj,
                                            java.lang.Object clientObj)
Returns the dependencies between some supplier modelelement and some client modelelement. Does not return the vica versa relationship (dependency 'from client to supplier').

Parameters:
supplierObj - a MModelElement
clientObj - a MModelElement
Returns:
Collection

getRelationships

public java.util.Collection getRelationships(MModelElement source,
                                             MModelElement dest)
Returns all relationships between the source and dest modelelement and vica versa.

Parameters:
source - is the source model element
dest - is the destination model element
Returns:
Collection

isValidNamespace

public boolean isValidNamespace(java.lang.Object mObj,
                                java.lang.Object nsObj)
Returns true if some modelelement may be owned by the given namespace.

Parameters:
mObj - a MModelElement
nsObj - a MNamespace
Returns:
boolean

getFirstSharedNamespace

public MNamespace getFirstSharedNamespace(MNamespace ns1,
                                          MNamespace ns2)
Gets the first namespace two namespaces share. That is: it returns the first namespace that owns the given namespaces itself or some owner of the given namespaces.

Parameters:
ns1 - is the first name space
ns2 - is the second name space
Returns:
MNamespace

getAllPossibleNamespaces

public java.util.Collection getAllPossibleNamespaces(java.lang.Object modelElement)
Returns all possible namespaces that may be selected by some given modelelement. Which namespaces are allowed, is decided in the method isValidNamespace.

Parameters:
modelElement - is the model element
Returns:
Collection

getBaseClasses

public java.util.Collection getBaseClasses(java.lang.Object o)
Returns the base classes (that are the classes that do not have any generalizations) for some given namespace. Personally, this seems a pointless operation to me but in GoModelToBaseElements this is done like this for some reason. TODO: find out if someone uses this.

Parameters:
o - is the given namespace.
Returns:
Collection

getChildren

public java.util.Collection getChildren(java.lang.Object o)
Returns all children from some given generalizableelement on all levels (the complete tree excluding the generalizable element itself).

Parameters:
o - is the generalizable element
Returns:
Collection
Throws:
java.lang.IllegalStateException - if there is a circular reference.

getChildren

private void getChildren(java.util.Collection currentChildren,
                         MGeneralization gen)
                  throws java.lang.IllegalStateException
Adds all children recursively to the Collection in the first argument.

Parameters:
currentChildren - collection to collect them in.
gen - element whose children are added.
Throws:
java.lang.IllegalStateException - if there is a circular reference.

getAllRealizedInterfaces

public java.util.Collection getAllRealizedInterfaces(java.lang.Object o)
Returns all interfaces that are realized by the given class or by its superclasses. It's possible that interfaces occur twice in the collection returned. In that case there is a double reference to that interface.

Parameters:
o - is the given class
Returns:
Collection

internalGetAllRealizedInterfaces

private java.util.Collection internalGetAllRealizedInterfaces(java.lang.Object o,
                                                              java.util.Collection col,
                                                              java.util.Set visited)
Helper method for getAllRealizedInterfaces.

Parameters:
o -
col -
visited -
Returns:
Collection

hasCompositeEnd

public final boolean hasCompositeEnd(java.lang.Object association)

equalsAggregationKind

public final boolean equalsAggregationKind(java.lang.Object associationEnd,
                                           java.lang.String kindType)
Parameters:
associationEnd - is the association end
kindType - the MAggregationKind as a string in lower case letter, eg: composite.
Returns:
true if the aggregation kinds are the same.

getCurrentModel

private MNamespace getCurrentModel()
Get the current model.

Returns:
the current model.


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