Author: tchemit Date: 2010-08-12 17:04:52 +0200 (Thu, 12 Aug 2010) New Revision: 953 Url: http://nuiton.org/repositories/revision/eugene/953 Log: add new methods to fill objectmodel from builder and transformerToJava Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelBuilder.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-08-12 15:00:46 UTC (rev 952) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2010-08-12 15:04:52 UTC (rev 953) @@ -329,6 +329,18 @@ builder.setDocumentation(element, documentation); } + public void setMinMultiplicity(ObjectModelAttribute attribute, int multiplicity) { + builder.setMinMultiplicity(attribute, multiplicity); + } + + public void setMaxMultiplicity(ObjectModelAttribute attribute, int multiplicity) { + builder.setMaxMultiplicity(attribute, multiplicity); + } + + public void addComment(ObjectModelElement element, String comment) { + builder.addComment(element, comment); + } + public void addAnnotation(ObjectModelClassifier classifier, ObjectModelElement element, String annotation) { @@ -340,6 +352,10 @@ return builder.addBlock(classifier, modifiers); } + public void addStereotype(ObjectModelElement element, String stereotype) { + builder.addStereotype(element, stereotype); + } + /** * Clone the {@code source} operation into the {@code destination} classifier. * Name, returnType, Parameters and Exceptions will be cloned. You can specify Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelBuilder.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelBuilder.java 2010-08-12 15:00:46 UTC (rev 952) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelBuilder.java 2010-08-12 15:04:52 UTC (rev 953) @@ -28,7 +28,20 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.object.xml.*; +import org.nuiton.eugene.models.object.xml.ObjectModeImplAssociationClassParticipant; +import org.nuiton.eugene.models.object.xml.ObjectModelAssociationClassImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelAttributeImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelClassifierImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelElementImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelEnumerationImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelImplRef; +import org.nuiton.eugene.models.object.xml.ObjectModelImplSuperClassRef; +import org.nuiton.eugene.models.object.xml.ObjectModelImplTagValue; +import org.nuiton.eugene.models.object.xml.ObjectModelInterfaceImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelOperationImpl; +import org.nuiton.eugene.models.object.xml.ObjectModelParameterImpl; /** * Builder to fill an empty ObjectModel. The object model name is important if @@ -139,7 +152,7 @@ throw new IllegalArgumentException( "Unsupported modifier type '" + modifier.name() + "'"); } - } + } } /** @@ -323,7 +336,7 @@ // Create reverse association ObjectModelAttributeImpl associationB = (ObjectModelAttributeImpl) addAssociation(classifierB, classifierA, roleName, - minMultiplicity, maxMultiplicity, modifiers); + minMultiplicity, maxMultiplicity, modifiers); associationB.setReverseAttributeName(associationA.getName()); associationB.setReverseMaxMultiplicity(associationA.getMaxMultiplicity()); @@ -469,9 +482,9 @@ /** * Add a superclass to an other class. The superclass may not exist in model. * - * @param clazz where the superclass will be added - * @param type type of inner classifier to create - * @param name superclass qualified name + * @param clazz where the superclass will be added + * @param type type of inner classifier to create + * @param name superclass qualified name * @param modifiers modifiers of the inner classifier * @return the new instanciated inner classifier * @throws IllegalArgumentException if given {@code type} is not a concrete classifier type @@ -491,7 +504,7 @@ break; case OBJECT_MODEL_CLASS: inner = new ObjectModelClassImpl(); - setClassModifiers((ObjectModelClassImpl)inner, modifiers); + setClassModifiers((ObjectModelClassImpl) inner, modifiers); break; case OBJECT_MODEL_INTERFACE: inner = new ObjectModelInterfaceImpl(); @@ -572,4 +585,39 @@ ref.setName(name); impl.addLiteral(ref); } + + /** + * Add a comment to an element. + * + * @param element where the comment will be added + * @param comment comment to add + * @since 2.1.2 + */ + public void addComment(ObjectModelElement element, String comment) { + ObjectModelElementImpl impl = (ObjectModelElementImpl) element; + impl.addComment(comment); + } + + /** + * Set the min multiplicity of an attribute in the model. + * + * @param attribute where the multiplicity will be setted + * @param multiplicity String description for the element + */ + public void setMinMultiplicity(ObjectModelAttribute attribute, int multiplicity) { + ObjectModelAttributeImpl impl = (ObjectModelAttributeImpl) attribute; + impl.setMinMultiplicity(multiplicity); + } + + /** + * Set the max multiplicity of an attribute in the model. + * + * @param attribute where the multiplicity will be setted + * @param multiplicity String description for the element + */ + public void setMaxMultiplicity(ObjectModelAttribute attribute, int multiplicity) { + ObjectModelAttributeImpl impl = (ObjectModelAttributeImpl) attribute; + impl.setMaxMultiplicity(multiplicity); + } + }
participants (1)
-
tchemit@users.nuiton.org