org.argouml.model.uml
Class UmlFactoryImpl

java.lang.Object
  extended byorg.argouml.model.uml.AbstractUmlModelFactory
      extended byorg.argouml.model.uml.UmlFactoryImpl
All Implemented Interfaces:
org.argouml.model.UmlFactory

class UmlFactoryImpl
extends AbstractUmlModelFactory
implements org.argouml.model.UmlFactory

Root factory for UML model element instance creation.

Since:
ARGO0.11.2

Nested Class Summary
(package private)  class UmlFactoryImpl.ObjectCreateInfo
           
 
Field Summary
private  NSUMLModelImplementation nsmodel
          The model implementation.
private static Object[][] VALID_CONNECTIONS
          An array of valid connections, the combination of connecting class and node classes must exist as a row in this list to be considered valid.
private  Map validConnectionMap
          A map of valid connections keyed by the connection type.
 
Constructor Summary
(package private) UmlFactoryImpl(NSUMLModelImplementation implementation)
          Don't allow external instantiation.
 
Method Summary
 Object buildConnection(Object elementType, Object fromElement, Object fromStyle, Object toElement, Object toStyle, Object unidirectional, Object namespace)
          Creates a UML model element of the given type and uses this to connect two other existing UML model elements.
 Object buildNode(Object elementType)
          Creates a UML model element of the given type.
private  void buildValidConnectionMap()
           
 Object createActionExpression()
          Create an empty but initialized instance of a UML ActionExpression.
 void delete(Object elem)
          Deletes a modelelement.
private  void deleteAction(Object elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  void deleteFeature(ru.novosoft.uml.foundation.core.MFeature elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  void deleteInstance(ru.novosoft.uml.behavior.common_behavior.MInstance elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  void deleteNamespace(ru.novosoft.uml.foundation.core.MNamespace elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  void deleteRelationship(ru.novosoft.uml.foundation.core.MRelationship elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  void deleteStateVertex(ru.novosoft.uml.behavior.state_machines.MStateVertex elem)
          Factored this method out of delete to simplify the design of the delete operation.
private  ActivityGraphsFactoryImpl getActivityGraphs()
          Returns the package factory for the UML package BehavioralElements::ActivityGraphs.
 CollaborationsFactoryImpl getCollaborations()
          Returns the package factory for the UML package BehavioralElements::Collaborations.
 CommonBehaviorFactoryImpl getCommonBehavior()
          Returns the package factory for the UML package BehavioralElements::CommonBehavior.
 CoreFactoryImpl getCore()
          Returns the package factory for the UML package Foundation::Core.
private  ExtensionMechanismsFactoryImpl getExtensionMechanisms()
          Returns the package factory for the UML package Foundation::ExtensionMechanisms.
 ModelManagementFactoryImpl getModelManagement()
          Returns the package factory for the UML package ModelManagement.
 StateMachinesFactoryImpl getStateMachines()
          Returns the package factory for the UML package BehavioralElements::StateMachines.
 UseCasesFactoryImpl getUseCases()
          Returns the package factory for the UML package BehavioralElements::UseCases.
 boolean isConnectionValid(Object connectionType, Object fromElement, Object toElement)
          Checks if some type of UML model element is valid to connect two other existing UML model elements.
 boolean isRemoved(Object o)
          The Project may check if a certain MBase has been removed.
 
Methods inherited from class org.argouml.model.uml.AbstractUmlModelFactory
addListenersToModelElement, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.argouml.model.UmlFactory
addListenersToModelElement
 

Field Detail

nsmodel

private NSUMLModelImplementation nsmodel
The model implementation.


validConnectionMap

private Map validConnectionMap
A map of valid connections keyed by the connection type. The constructor builds this from the data in the VALID_CONNECTIONS array


VALID_CONNECTIONS

private static final Object[][] VALID_CONNECTIONS
An array of valid connections, the combination of connecting class and node classes must exist as a row in this list to be considered valid.

Constructor Detail

UmlFactoryImpl

UmlFactoryImpl(NSUMLModelImplementation implementation)
Don't allow external instantiation.

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

buildValidConnectionMap

private void buildValidConnectionMap()

buildConnection

public Object buildConnection(Object elementType,
                              Object fromElement,
                              Object fromStyle,
                              Object toElement,
                              Object toStyle,
                              Object unidirectional,
                              Object namespace)
                       throws org.argouml.model.IllegalModelElementConnectionException
Creates a UML model element of the given type and uses this to connect two other existing UML model elements. This only works for UML elements. If a diagram contains elements of another type then it is the responsibility of the diagram manage those items and not call this method. It also only works for UML model elements that are represented in diagrams by an edge, hence the requirement to state the connecting ends.

Specified by:
buildConnection in interface org.argouml.model.UmlFactory
Parameters:
elementType - the UML object type of the connection
fromElement - the UML object for the "from" element
fromStyle - the aggregationkind for the connection in case of an association
toElement - the UML object for the "to" element
toStyle - the aggregationkind for the connection in case of an association
unidirectional - for association and associationrole
namespace - the namespace to use if it can't be determined
Returns:
the newly build connection (UML object)
Throws:
org.argouml.model.IllegalModelElementConnectionException - if the connection is not a valid thing to do

buildNode

public Object buildNode(Object elementType)
Creates a UML model element of the given type. This only works for UML elements. If a diagram contains elements of another type then it is the responsibility of the diagram manage those items and not call this method. It also only works for UML model elements that are represented in diagrams by a node.

The parameter "elementType" stands for the type of model element to build.

Specified by:
buildNode in interface org.argouml.model.UmlFactory
See Also:
UmlFactory.buildNode(java.lang.Object)

isConnectionValid

public boolean isConnectionValid(Object connectionType,
                                 Object fromElement,
                                 Object toElement)
Checks if some type of UML model element is valid to connect two other existing UML model elements. This only works for UML elements. If a diagram contains elements of another type then it is the responsibility of the diagram to filter those out before calling this method.

Specified by:
isConnectionValid in interface org.argouml.model.UmlFactory
Parameters:
connectionType - the UML object type of the connection
fromElement - the UML object type of the "from"
toElement - the UML object type of the "to"
Returns:
true if valid

getExtensionMechanisms

private ExtensionMechanismsFactoryImpl getExtensionMechanisms()
Returns the package factory for the UML package Foundation::ExtensionMechanisms.

Returns:
the ExtensionMechanisms factory instance.

getCore

public CoreFactoryImpl getCore()
Returns the package factory for the UML package Foundation::Core.

Returns:
the Core factory instance.

getCommonBehavior

public CommonBehaviorFactoryImpl getCommonBehavior()
Returns the package factory for the UML package BehavioralElements::CommonBehavior.

Returns:
the CommonBehavior factory instance.

getUseCases

public UseCasesFactoryImpl getUseCases()
Returns the package factory for the UML package BehavioralElements::UseCases.

Returns:
the UseCases factory instance.

getStateMachines

public StateMachinesFactoryImpl getStateMachines()
Returns the package factory for the UML package BehavioralElements::StateMachines.

Returns:
the StateMachines factory instance.

getCollaborations

public CollaborationsFactoryImpl getCollaborations()
Returns the package factory for the UML package BehavioralElements::Collaborations.

Returns:
the Collaborations factory instance.

getActivityGraphs

private ActivityGraphsFactoryImpl getActivityGraphs()
Returns the package factory for the UML package BehavioralElements::ActivityGraphs.

Returns:
the ActivityGraphs factory instance.

getModelManagement

public ModelManagementFactoryImpl getModelManagement()
Returns the package factory for the UML package ModelManagement.

Returns:
the ModelManagement factory instance.

delete

public void delete(Object elem)
Deletes a modelelement. It calls the remove method of the modelelement but also does 'cascading deletes' that are not provided for in the remove method of the modelelement itself. For example: this delete method also removes the binary associations that a class has if the class is deleted. In this way, it is not longer possible that illegal states exist in the nsmodel.

The actual deletion is delegated to delete methods in the rest of the factories. For example: a method deleteClass exists on CoreHelper. Delete methods as deleteClass should only do those extra actions that are necessary for the deletion of the modelelement itself. I.e. deleteClass should only take care of things specific to MClass.

The delete methods in the UML Factories should not be called directly throughout the code! Calls should allways refer to this method and never call the deleteXXX method on XXXFactory directly. The reason that it is possible to call the deleteXXX methods directly is a pure implementation detail.

The implementation of this method uses a quite complicate if then else tree. This is done to provide optimal performance and full compliance to the UML 1.3 nsmodel. The last remark refers to the fact that the UML 1.3 model knows multiple inheritance in several places. This has to be taken into account.

Extensions and its children are not taken into account here. They do not require extra cleanup actions. Not in the form of a call to the remove method as is normal for all children of MBase and not in the form of other behaviour we want to implement via this operation.

Specified by:
delete in interface org.argouml.model.UmlFactory
Parameters:
elem - The element to be deleted

isRemoved

public boolean isRemoved(Object o)
The Project may check if a certain MBase has been removed.

Specified by:
isRemoved in interface org.argouml.model.UmlFactory
Parameters:
o - the object to be checked
Returns:
true if removed

deleteFeature

private void deleteFeature(ru.novosoft.uml.foundation.core.MFeature elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

deleteNamespace

private void deleteNamespace(ru.novosoft.uml.foundation.core.MNamespace elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

deleteRelationship

private void deleteRelationship(ru.novosoft.uml.foundation.core.MRelationship elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

deleteAction

private void deleteAction(Object elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

deleteInstance

private void deleteInstance(ru.novosoft.uml.behavior.common_behavior.MInstance elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

deleteStateVertex

private void deleteStateVertex(ru.novosoft.uml.behavior.state_machines.MStateVertex elem)
Factored this method out of delete to simplify the design of the delete operation.

Parameters:
elem -

createActionExpression

public Object createActionExpression()
Create an empty but initialized instance of a UML ActionExpression. NSUML does not have a factory method for this.

Specified by:
createActionExpression in interface org.argouml.model.UmlFactory
Returns:
an initialized UML ActionExpression instance.


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