org.argouml.model.uml
Class CollaborationsHelperImpl

java.lang.Object
  extended byorg.argouml.model.uml.CollaborationsHelperImpl
All Implemented Interfaces:
org.argouml.model.CollaborationsHelper

class CollaborationsHelperImpl
extends Object
implements org.argouml.model.CollaborationsHelper

Helper class for UML BehavioralElements::Collaborations Package. Current implementation is a placeholder.

Since:
ARGO0.11.2

Field Summary
private  NSUMLModelImplementation nsmodel
          The model implementation.
 
Constructor Summary
(package private) CollaborationsHelperImpl(NSUMLModelImplementation implementation)
          Don't allow instantiation.
 
Method Summary
 void addBase(Object arole, Object abase)
          Adds a base to the given classifierrole.
 void addConstrainingElement(Object handle, Object constraint)
          Add a constraining element.
 void addInstance(Object classifierRole, Object instance)
          Adds an instance to a classifier role.
 void addMessage(Object handle, Object elem)
          Add a message to an interaction or association role.
 void addMessage3(Object handle, Object mess)
          Add Message to a predecessor Message.
 void addPredecessor(Object handle, Object predecessor)
          Adds a predecessor to a message.
 Collection allAvailableContents(Object arole)
          Returns all available contents for a given classifierrole as defined in section 2.10.3.3 of the UML 1.3 spec.
 Collection allAvailableFeatures(Object arole)
          Returns all available features for a given classifierrole as defined in section 2.10.3.3 of the UML 1.3 spec.
 Collection getAllClassifierRoles(Object ns)
          Returns all classifierroles found in this namespace and in its children.
 Collection getAllPossibleActivators(Object ames)
          Returns all possible activators for some message mes.
 Collection getAllPossibleAssociationRoles(Object roleArg)
          Returns all associations the bases of the classifierrole has, thereby forming the set of associationroles the classifierrole can use.
private  Collection getAllPossibleBases(ru.novosoft.uml.behavior.collaborations.MAssociationRole role)
          Returns all possible bases for some AssociationRole taking into account the wellformednessrules as defined in section 2.10.3 of the UML 1.3 spec.
private  Collection getAllPossibleBases(ru.novosoft.uml.behavior.collaborations.MClassifierRole role)
          Returns all possible bases for some classifierrole taking into account the wellformednessrules as defined in section 2.10.3 of the UML 1.3 spec.
 Collection getAllPossibleBases(Object role)
           
 Collection getAllPossiblePredecessors(Object amessage)
          Returns all possible predecessors for some message, taking into account the wellformednessrules as defined in section 2.10 of the UML spec.
 Object getAssocationRole(Object afrom, Object ato)
          Returns the first found associationrole between two classifierroles.
 Collection getClassifierRoles(Object role)
          Returns all classifierroles associated via associationroles to some classifierrole role.
 boolean hasAsActivator(Object message, Object activator)
          Returns true if the given message has the message activator somewhere as it's activator.
 boolean isAddingCollaborationAllowed(Object context)
          Returns true if a collaboration may be added to the given context.
 void removeBase(Object handle, Object c)
          This method removes a classifier from a classifier role.
 void removeConstrainingElement(Object handle, Object constraint)
          Remove a constraining element.
 void removeMessage(Object handle, Object message)
          Removes a message from the interaction or association role.
 void removeMessage3(Object handle, Object mess)
          Removes a successor message.
 void removePredecessor(Object handle, Object message)
          Removes a predecessor message.
 void setAction(Object handle, Object action)
          Sets the action to a message.
 void setActivator(Object ames, Object anactivator)
          Sets the activator of some given message mes.
 void setBase(Object arole, Object abase)
           
 void setBases(Object role, Collection bases)
          Sets the bases of the given classifierrole to the given collection bases.
 void setContext(Object handle, Object col)
          Set the context of an interaction.
 void setMessages3(Object handle, Collection messages)
           
 void setPredecessors(Object handle, Collection predecessors)
          Set the collection of predecessing messages.
 void setRepresentedClassifier(Object handle, Object classifier)
          Sets the represented classifier of some collaboration.
 void setRepresentedOperation(Object handle, Object operation)
          Sets the represented operation of some collaboration.
 void setSender(Object handle, Object sender)
          Sets the sender of some model element.
 
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

CollaborationsHelperImpl

CollaborationsHelperImpl(NSUMLModelImplementation implementation)
Don't allow instantiation.

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

getAllClassifierRoles

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

Specified by:
getAllClassifierRoles in interface org.argouml.model.CollaborationsHelper
Parameters:
ns - the namespace
Returns:
Collection collection of all classifierroles

getAllPossibleAssociationRoles

public Collection getAllPossibleAssociationRoles(Object roleArg)
Returns all associations the bases of the classifierrole has, thereby forming the set of associationroles the classifierrole can use. UML Spec 1.3 section 2.10.3.3.

Specified by:
getAllPossibleAssociationRoles in interface org.argouml.model.CollaborationsHelper
Parameters:
roleArg - the classifierrole
Returns:
Collection the set of associationroles the classifierrole can use

getClassifierRoles

public Collection getClassifierRoles(Object role)
Returns all classifierroles associated via associationroles to some classifierrole role.

Specified by:
getClassifierRoles in interface org.argouml.model.CollaborationsHelper
Parameters:
role - the classifierrole
Returns:
Collection all classifierroles associated via associationroles to the given classifierrole role

getAssocationRole

public Object getAssocationRole(Object afrom,
                                Object ato)
Returns the first found associationrole between two classifierroles.

Specified by:
getAssocationRole in interface org.argouml.model.CollaborationsHelper
Parameters:
afrom - the first classifierrole
ato - the second classifierrole
Returns:
MAssociationRole the association between them, or null if none

getAllPossibleActivators

public Collection getAllPossibleActivators(Object ames)
Returns all possible activators for some message mes. The possible activators are all messages in the same interaction as the given message that are not part of the predecessors of the message and that are not equal to the given message.

Specified by:
getAllPossibleActivators in interface org.argouml.model.CollaborationsHelper
Parameters:
ames - the message
Returns:
Collection all possible activators for the given message

hasAsActivator

public boolean hasAsActivator(Object message,
                              Object activator)
Returns true if the given message has the message activator somewhere as it's activator. This is defined as that the message activator can be the activator itself of the given message OR that the given activator can be the activator of the activator of the given message (recursive) OR that the given activator is part of the predecessors of the activator of the given message (recursive too).

Specified by:
hasAsActivator in interface org.argouml.model.CollaborationsHelper
Parameters:
message - the given message
activator - the given activator
Returns:
boolean true if the given message has the message activator somewhere as it's activator

setActivator

public void setActivator(Object ames,
                         Object anactivator)
Sets the activator of some given message mes. Checks the wellformednessrules as defined in the UML 1.3 spec in section 2.10.3.6, will throw an illegalargumentexception if the wellformednessrules are not met. Not only sets the activator for the given message mes but also for the predecessors of mes. This is done since it can not be the case that a list of messages (defined by the predecessor) has a different activator.

Specified by:
setActivator in interface org.argouml.model.CollaborationsHelper
Parameters:
ames - the given message
anactivator - the given activator

getAllPossiblePredecessors

public Collection getAllPossiblePredecessors(Object amessage)
Returns all possible predecessors for some message, taking into account the wellformednessrules as defined in section 2.10 of the UML spec.

Specified by:
getAllPossiblePredecessors in interface org.argouml.model.CollaborationsHelper
Parameters:
amessage - the given message
Returns:
Collection all possible predecessors

addBase

public void addBase(Object arole,
                    Object abase)
Adds a base to the given classifierrole. If the classifierrole does not have a name yet and there is only one base, the name of the classifierrole is set to the name of the given base according to the wellformednessrules of section 2.10.3 of the UML 1.3 spec.

Specified by:
addBase in interface org.argouml.model.CollaborationsHelper
Parameters:
arole - the given classifierrole
abase - the base to be added

setBases

public void setBases(Object role,
                     Collection bases)
Sets the bases of the given classifierrole to the given collection bases.

Specified by:
setBases in interface org.argouml.model.CollaborationsHelper
Parameters:
role - the given classifierrole
bases - the given collection of bases

allAvailableFeatures

public Collection allAvailableFeatures(Object arole)
Returns all available features for a given classifierrole as defined in section 2.10.3.3 of the UML 1.3 spec. Does not use the standard getAvailableFeatures method on ClassifierRole since this is derived information.

Specified by:
allAvailableFeatures in interface org.argouml.model.CollaborationsHelper
Parameters:
arole - the given classifierrole
Returns:
Collection all available features

allAvailableContents

public Collection allAvailableContents(Object arole)
Returns all available contents for a given classifierrole as defined in section 2.10.3.3 of the UML 1.3 spec. Does not use the standard getAvailableContents method on ClassifierRole since this is derived information.

Specified by:
allAvailableContents in interface org.argouml.model.CollaborationsHelper
Parameters:
arole - the given classifierrole
Returns:
Collection all available contents

getAllPossibleBases

public Collection getAllPossibleBases(Object role)
Specified by:
getAllPossibleBases in interface org.argouml.model.CollaborationsHelper
Parameters:
role - the given classifierrole or associationrole
Returns:
all available bases

getAllPossibleBases

private Collection getAllPossibleBases(ru.novosoft.uml.behavior.collaborations.MAssociationRole role)
Returns all possible bases for some AssociationRole taking into account the wellformednessrules as defined in section 2.10.3 of the UML 1.3 spec.

Parameters:
role - the given associationrole
Returns:
Collection all possible bases

getAllPossibleBases

private Collection getAllPossibleBases(ru.novosoft.uml.behavior.collaborations.MClassifierRole role)
Returns all possible bases for some classifierrole taking into account the wellformednessrules as defined in section 2.10.3 of the UML 1.3 spec.

Parameters:
role - the given classifierrole
Returns:
Collection all possible bases

setBase

public void setBase(Object arole,
                    Object abase)
Specified by:
setBase in interface org.argouml.model.CollaborationsHelper
See Also:
CollaborationsHelper.setBase( java.lang.Object, java.lang.Object)

isAddingCollaborationAllowed

public boolean isAddingCollaborationAllowed(Object context)
Returns true if a collaboration may be added to the given context. To decouple ArgoUML as much as possible from the NSUML model, the parameter of the method is of type Object.

TODO: MVW: Removed the MCollaboration and MModel. Why were they included in the test below?

- MCollaboration: this allows a 2nd diagram for the same collaboration. According to my interpretation of the UML spec, this is not alowed; a collaboration diagram maps on a collaboration.

- MModel: this allowed a collaboration diagram without a represented classifier/operation. But there is no way to correct this later...

Specified by:
isAddingCollaborationAllowed in interface org.argouml.model.CollaborationsHelper
Parameters:
context - the given context
Returns:
boolean true if a collaboration may be added

removeBase

public void removeBase(Object handle,
                       Object c)
This method removes a classifier from a classifier role.

Specified by:
removeBase in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - is the classifier role
c - is the classifier

removeConstrainingElement

public void removeConstrainingElement(Object handle,
                                      Object constraint)
Remove a constraining element.

Specified by:
removeConstrainingElement in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - The collaboration to remove a constraint to.
constraint - The constraint to remove.

removeMessage

public void removeMessage(Object handle,
                          Object message)
Removes a message from the interaction or association role.

Specified by:
removeMessage in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - The interaction or association role to remove the message from.
message - The message to remove.

removeMessage3

public void removeMessage3(Object handle,
                           Object mess)
Removes a successor message.

Specified by:
removeMessage3 in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - the Message that needs to loose a successor
mess - the Message that is removed

removePredecessor

public void removePredecessor(Object handle,
                              Object message)
Removes a predecessor message.

Specified by:
removePredecessor in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - the Message that needs to loose a predecessor
message - the Message that is removed

addConstrainingElement

public void addConstrainingElement(Object handle,
                                   Object constraint)
Add a constraining element.

Specified by:
addConstrainingElement in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - The collaboration to add a constraint to.
constraint - The constraint to add.

addInstance

public void addInstance(Object classifierRole,
                        Object instance)
Adds an instance to a classifier role.

Specified by:
addInstance in interface org.argouml.model.CollaborationsHelper
Parameters:
classifierRole - is the classifier role
instance - is the instance to add

addMessage

public void addMessage(Object handle,
                       Object elem)
Add a message to an interaction or association role.

Specified by:
addMessage in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - The interaction or association role.
elem - The message.

addMessage3

public void addMessage3(Object handle,
                        Object mess)
Add Message to a predecessor Message.

Specified by:
addMessage3 in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - predecessor Message
mess - Message to be added

addPredecessor

public void addPredecessor(Object handle,
                           Object predecessor)
Adds a predecessor to a message.

Specified by:
addPredecessor in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - the message
predecessor - is the predecessor

setAction

public void setAction(Object handle,
                      Object action)
Sets the action to a message.

Specified by:
setAction in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - is the message
action - is the action

setContext

public void setContext(Object handle,
                       Object col)
Set the context of an interaction.

Specified by:
setContext in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - The element.
col - The context to set.

setMessages3

public void setMessages3(Object handle,
                         Collection messages)
Specified by:
setMessages3 in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - Message
messages - Collection of predecessor messages

setPredecessors

public void setPredecessors(Object handle,
                            Collection predecessors)
Set the collection of predecessing messages.

Specified by:
setPredecessors in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - Message
predecessors - Collection of Messages

setRepresentedClassifier

public void setRepresentedClassifier(Object handle,
                                     Object classifier)
Sets the represented classifier of some collaboration.

Specified by:
setRepresentedClassifier in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - the collaboration
classifier - is the classifier or null

setRepresentedOperation

public void setRepresentedOperation(Object handle,
                                    Object operation)
Sets the represented operation of some collaboration.

Specified by:
setRepresentedOperation in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - the collaboration
operation - is the operation or null

setSender

public void setSender(Object handle,
                      Object sender)
Sets the sender of some model element.

Specified by:
setSender in interface org.argouml.model.CollaborationsHelper
Parameters:
handle - model element
sender - the sender


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