org.nuiton.eugene.models.object
Class ObjectModelBuilder

java.lang.Object
  extended by org.nuiton.eugene.models.object.ObjectModelBuilder
Direct Known Subclasses:
JavaBuilder

public class ObjectModelBuilder
extends Object

Builder to fill an empty ObjectModel. The object model name is important if you want to use the model in generators.

Created: 3 nov. 2009

Version:
$Id: ObjectModelBuilder.java 1079 2011-06-28 09:15:23Z tchemit $
Author:
fdesbois

Field Summary
protected  ObjectModelImpl model
           
 
Constructor Summary
ObjectModelBuilder(String name)
          Constructor.
 
Method Summary
 ObjectModelAttribute addAssociation(ObjectModelClassifier classifierA, ObjectModelClassifier classifierB, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
          Add an association A to B.
 ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type)
          Add an attribute to a classifier (interface, class, enum) without default value.
 ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type, String value, ObjectModelModifier... modifiers)
          Add an attribute to a classifier (interface, class, enum).
 void addComment(ObjectModelElement element, String comment)
          Add a comment to an element.
 void addException(ObjectModelOperation operation, String exception)
          Add an exception to an operation.
 ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name, ObjectModelModifier... modifiers)
          Add a superclass to an other class.
 void addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName)
          Add an interface to a classifier.
 void addLiteral(ObjectModelEnumeration enumz, String name)
           
 ObjectModelOperation addOperation(ObjectModelClassifier classifier, ObjectModelOperation operation)
          Add an operation to a classifier.
 ObjectModelOperation addOperation(ObjectModelClassifier classifier, String name, String returnType, ObjectModelModifier... modifiers)
          Add an operation to a classifier.
 ObjectModelParameter addParameter(ObjectModelOperation operation, String type, String name)
          Add a parameter to an operation.
 ObjectModelAttribute addReverseAssociation(ObjectModelAttribute attrAssociation, String roleName, int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
          Create reverse association from an other association.
 void addStereotype(ObjectModelElement element, String stereotype)
          Add a stereotype to an element.
 void addSuperclass(ObjectModelClass clazz, String superclassQualifiedName)
          Add a superclass to an other class.
 void addTagValue(ObjectModelElement element, String name, String value)
          Add a tagValue to an element
 void addTagValue(String name, String value)
          Add a tagValue to the model.
 ObjectModelAssociationClass createAssociationClass(String name, String packageName, ObjectModelAttribute attrAssociationA, ObjectModelAttribute attrAssociationB, ObjectModelModifier... modifiers)
          Create association class.
protected  ObjectModelClass createClass(ObjectModelClassImpl clazz, String name, String packageName, ObjectModelModifier... modifiers)
           
 ObjectModelClass createClass(String name, String packageName, ObjectModelModifier... modifiers)
          Create a new class in the model.
 ObjectModelEnumeration createEnumeration(String name, String packageName)
          Create a new interface in the model.
 ObjectModelInterface createInterface(String name, String packageName)
          Create a new interface in the model.
 ObjectModel getModel()
          Get the building model
protected  void setClassModifiers(ObjectModelClassImpl clazz, ObjectModelModifier... modifiers)
          Set modifiers to a class.
 void setDocumentation(ObjectModelElement element, String documentation)
          Set the documentation of an element in the model.
 void setMaxMultiplicity(ObjectModelAttribute attribute, int multiplicity)
          Set the max multiplicity of an attribute in the model.
 void setMinMultiplicity(ObjectModelAttribute attribute, int multiplicity)
          Set the min multiplicity of an attribute in the model.
 void setNavigable(ObjectModelAttribute attribute, boolean navigable)
          Set the navigable flag of an attribute in the model.
 void setOperationBody(ObjectModelOperation operation, String body)
          Set the body code for an Operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected ObjectModelImpl model
Constructor Detail

ObjectModelBuilder

public ObjectModelBuilder(String name)
Constructor. Must have a name for the new model created.

Parameters:
name - model name
Method Detail

getModel

public ObjectModel getModel()
Get the building model

Returns:
the ObjectModel which is currently built

addTagValue

public void addTagValue(String name,
                        String value)
Add a tagValue to the model.

Parameters:
name - tagValue name
value - tagValue value

addTagValue

public void addTagValue(ObjectModelElement element,
                        String name,
                        String value)
Add a tagValue to an element

Parameters:
element - where the tag value will be added
name - tagValue name
value - tagValue value

createClass

public ObjectModelClass createClass(String name,
                                    String packageName,
                                    ObjectModelModifier... modifiers)
Create a new class in the model. Modifiers allowed : ABSTRACT, STATIC.

Parameters:
name - class name
packageName - class package
modifiers - class modifiers
Returns:
the new ObjectModelClass added to the model

createClass

protected ObjectModelClass createClass(ObjectModelClassImpl clazz,
                                       String name,
                                       String packageName,
                                       ObjectModelModifier... modifiers)
                                throws IllegalArgumentException
Throws:
IllegalArgumentException

setClassModifiers

protected void setClassModifiers(ObjectModelClassImpl clazz,
                                 ObjectModelModifier... modifiers)
                          throws IllegalArgumentException
Set modifiers to a class. Only STATIC and ABSTRACT are actually supported.

Parameters:
clazz - ObjectModelClassImpl where modifiers will be set
modifiers - Array of ObjectModelModifier to set
Throws:
IllegalArgumentException - for unsupported modifier

createInterface

public ObjectModelInterface createInterface(String name,
                                            String packageName)
Create a new interface in the model.

Parameters:
name - interface name
packageName - interface package
Returns:
the new ObjectModelInterface added to the model

createEnumeration

public ObjectModelEnumeration createEnumeration(String name,
                                                String packageName)
Create a new interface in the model.

Parameters:
name - interface name
packageName - interface package
Returns:
the new ObjectModelInterface added to the model

addAttribute

public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
                                         String name,
                                         String type)
Add an attribute to a classifier (interface, class, enum) without default value. Default visibility is set to PUBLIC.

Parameters:
classifier - where the attribute will be added
name - attribute name
type - attribute type (full qualified name)
Returns:
the new ObjectModelAttribute added

addAttribute

public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier,
                                         String name,
                                         String type,
                                         String value,
                                         ObjectModelModifier... modifiers)
                                  throws IllegalArgumentException
Add an attribute to a classifier (interface, class, enum). Modifiers allowed : STATIC, FINAL, PUBLIC, PRIVATE, PROTECTED, PACKAGE, ORDERED, UNIQUE. The last visibility set will be keeped.

Parameters:
classifier - where the attribute will be added
name - attribute name
type - attribute type (full qualified name)
value - default value for the attribute
modifiers - attribute modifiers
Returns:
the new ObjectModelAttribute added
Throws:
IllegalArgumentException - illegal Modifier
See Also:
ObjectModelModifier.isVisibility()

addAssociation

public ObjectModelAttribute addAssociation(ObjectModelClassifier classifierA,
                                           ObjectModelClassifier classifierB,
                                           String roleName,
                                           int minMultiplicity,
                                           int maxMultiplicity,
                                           ObjectModelModifier... modifiers)
                                    throws IllegalArgumentException
Add an association A to B. Create only attribute association for classifierA. MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE STATIC, NAVIGABLE. You have to use method addReverseAssociation(ObjectModelAttribute, String, int, int, ObjectModelModifier...) to create attribute association for classifierB.

Parameters:
classifierA - classifier from
classifierB - classifier to
roleName - role of A in association
minMultiplicity - minimum multiplicity of A in association
maxMultiplicity - maximum multiplicity of A in association
modifiers - for the association
Returns:
the attribute corresponding to the association for classifierA
Throws:
IllegalArgumentException - illegal modifier

addReverseAssociation

public ObjectModelAttribute addReverseAssociation(ObjectModelAttribute attrAssociation,
                                                  String roleName,
                                                  int minMultiplicity,
                                                  int maxMultiplicity,
                                                  ObjectModelModifier... modifiers)
Create reverse association from an other association. MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE STATIC, NAVIGABLE.

Parameters:
attrAssociation - other association A to B
roleName - role of B in association
minMultiplicity - minimum multiplicity of B in association
maxMultiplicity - maximum multiplicity of B in association
modifiers - for the association
Returns:
the attribute corresponding to the association for classifierB
See Also:
addAssociation(ObjectModelClassifier, ObjectModelClassifier, String, int, int, ObjectModelModifier...)

createAssociationClass

public ObjectModelAssociationClass createAssociationClass(String name,
                                                          String packageName,
                                                          ObjectModelAttribute attrAssociationA,
                                                          ObjectModelAttribute attrAssociationB,
                                                          ObjectModelModifier... modifiers)
Create association class. The two extremities of the association must be existing before creating the association class. Modifiers allowed : ABSTRACT, STATIC.

Parameters:
name - association class name
packageName - association package name
attrAssociationA - attribute association for classifierA involved in association class
attrAssociationB - attribute association for classifierB involved in association class
modifiers - for the association class
Returns:
the new association class created with participants A and B

addOperation

public ObjectModelOperation addOperation(ObjectModelClassifier classifier,
                                         String name,
                                         String returnType,
                                         ObjectModelModifier... modifiers)
                                  throws IllegalArgumentException
Add an operation to a classifier. Modifiers allowed : STATIC, ABSTRACT, PUBLIC, PRIVATE, PROTECTED, PACKAGE. The last visibility set will be keeped.

Parameters:
classifier - where the operation will be added
name - operation name
returnType - operation type (full qualified name)
modifiers - operation modifiers
Returns:
the new ObjectModelOperation added
Throws:
IllegalArgumentException - illegal Modifier

addOperation

public ObjectModelOperation addOperation(ObjectModelClassifier classifier,
                                         ObjectModelOperation operation)
Add an operation to a classifier. Modifiers allowed : STATIC, ABSTRACT, PUBLIC, PRIVATE, PROTECTED, PACKAGE. The last visibility set will be keeped.

Parameters:
classifier - where the operation will be added
operation - operation to add
Returns:
the added operation (says the given parameter)
Since:
2.1.2

setOperationBody

public void setOperationBody(ObjectModelOperation operation,
                             String body)
Set the body code for an Operation.

Parameters:
operation - where the code will be added
body - code to add to the operation

addInterface

public void addInterface(ObjectModelClassifier classifier,
                         String interfaceQualifiedName)
Add an interface to a classifier. The interface may not exist in model.

Parameters:
classifier - where the interface will be added
interfaceQualifiedName - interface qualified name

addSuperclass

public void addSuperclass(ObjectModelClass clazz,
                          String superclassQualifiedName)
Add a superclass to an other class. The superclass may not exist in model.

Parameters:
clazz - where the superclass will be added
superclassQualifiedName - superclass qualified name

addInnerClassifier

public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz,
                                                ObjectModelType type,
                                                String name,
                                                ObjectModelModifier... modifiers)
                                         throws IllegalArgumentException
Add a superclass to an other class. The superclass may not exist in model.

Parameters:
clazz - where the superclass will be added
type - type of inner classifier to create
name - superclass qualified name
modifiers - modifiers of the inner classifier
Returns:
the new instanciated inner classifier
Throws:
IllegalArgumentException - if given type is not a concrete classifier type

addParameter

public ObjectModelParameter addParameter(ObjectModelOperation operation,
                                         String type,
                                         String name)
Add a parameter to an operation.

Parameters:
operation - where the parameter will be added
type - paremeter type (full qualified name)
name - parameter name
Returns:
the new ObjectModelParameter added

addException

public void addException(ObjectModelOperation operation,
                         String exception)
Add an exception to an operation.

Parameters:
operation - where the exception will be added
exception - name of the exception (full qualified name)

setDocumentation

public void setDocumentation(ObjectModelElement element,
                             String documentation)
Set the documentation of an element in the model.

Parameters:
element - where the documentation will be setted
documentation - String documentation for the element

addStereotype

public void addStereotype(ObjectModelElement element,
                          String stereotype)
Add a stereotype to an element.

Parameters:
element - where the stereotype will be added
stereotype - name

addLiteral

public void addLiteral(ObjectModelEnumeration enumz,
                       String name)

addComment

public void addComment(ObjectModelElement element,
                       String comment)
Add a comment to an element.

Parameters:
element - where the comment will be added
comment - comment to add
Since:
2.1.2

setMinMultiplicity

public void setMinMultiplicity(ObjectModelAttribute attribute,
                               int multiplicity)
Set the min multiplicity of an attribute in the model.

Parameters:
attribute - where the multiplicity will be setted
multiplicity - String description for the element

setMaxMultiplicity

public void setMaxMultiplicity(ObjectModelAttribute attribute,
                               int multiplicity)
Set the max multiplicity of an attribute in the model.

Parameters:
attribute - where the multiplicity will be setted
multiplicity - String description for the element

setNavigable

public void setNavigable(ObjectModelAttribute attribute,
                         boolean navigable)
Set the navigable flag of an attribute in the model.

Parameters:
attribute - where the navigable flag will be setted
navigable - navigable flag value to set
Since:
2.3


Copyright © 2004-2012 CodeLutin. All Rights Reserved.