Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelOperationImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelOperationImpl.java:1.11 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelOperationImpl.java:1.12 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelOperationImpl.java:1.11 Fri Mar 3 10:28:34 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelOperationImpl.java Fri May 25 16:14:19 2007 @@ -1,142 +1,151 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*##%*/ + * Copyright (C) 2002, 2003, 2004 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ -/* * -* ObjectModelOperationImpl.java -* -* Created: 14 janv. 2004 -* -* @author Cédric Pineau -* Copyright Code Lutin -* @version $Revision: 1.11 $ -* -* Last update : $Date: 2006/03/03 10:28:34 $ -* by : $Author: thimel $ -*/ package org.codelutin.generator.models.object.xml; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; -import org.codelutin.generator.models.object.ObjectModelElement; import org.codelutin.generator.models.object.ObjectModelOperation; import org.codelutin.generator.models.object.ObjectModelParameter; -public class ObjectModelOperationImpl extends ObjectModelElementImpl implements ObjectModelOperation { - - protected ObjectModelParameter returnParameter = null; - protected String visibility = "public"; - protected String transactionLevel = "supports"; - protected boolean abstractz = false; - protected ArrayList parameters = new ArrayList(); - protected Set exceptions = new HashSet(); - - public String toString(){ - return getName()+ "(" + parameters + ")" + "<<" + getStereotypes() + ">> throws " + exceptions + " tagvalue: " + getTagValues(); - } - - /** - * 2 operations are equal if the have same name and same argument type. - */ - public boolean equals(Object o){ - if(o instanceof ObjectModelOperation){ - ObjectModelOperation op = (ObjectModelOperation)o; - if(getName().equals(op.getName()) && getParameters().size() == op.getParameters().size()){ - for(Iterator i=getParameters().iterator(), opi=op.getParameters().iterator(); i.hasNext() && opi.hasNext();){ - ObjectModelParameter p = (ObjectModelParameter)i.next(); - ObjectModelParameter pop = (ObjectModelParameter)opi.next(); - if(!p.getType().equals(pop.getType())){ - return false; - } - } - return true; - } - } - return false; - } - - public ObjectModelOperationImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); - } - - public void postInit() { - super.postInit(); - } - - public ObjectModelParameterImpl parsetParameter(ObjectModelParameterImpl parameter) { - if (parameter == null) - return new ObjectModelParameterImpl(objectModelImpl, this); - parameter.postInit(); - parameters.add(parameter); - return parameter; - } - - public void parsetVisibility(String visibility) { - this.visibility = visibility; - } - - public void parsetAbstract(boolean abstractz) { - this.abstractz = abstractz; - } - - public ObjectModelParameterImpl parsetReturnParameter(ObjectModelParameterImpl returnParameter) { - if (returnParameter == null) - return new ObjectModelParameterImpl(objectModelImpl, this); - returnParameter.postInit(); - this.returnParameter = returnParameter; - return returnParameter; - } - - public String getReturnType() { - return returnParameter.getType(); - } - - public String getVisibility() { - return visibility; - } - - /** - * Returns whether this operation is abstract or not. - * - * @return a boolean indicating whether this operation is abstract or not. - */ - public boolean isAbstract() { - return abstractz; - } - - public Collection getParameters() { - return parameters; - } - - public ObjectModelParameterImpl parsetExceptionParameter(ObjectModelParameterImpl raisedParameter) { - if (raisedParameter == null) { - return new ObjectModelParameterImpl(objectModelImpl, this); - } - raisedParameter.postInit(); - this.exceptions.add(raisedParameter.getType()); - return raisedParameter; - } - - public Set getExceptions() { - return exceptions; - } - +/* * + * ObjectModelOperationImpl.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau Copyright Code Lutin + * + * @version $Revision: 1.12 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ by : $Author: chatellier $ + */ +public class ObjectModelOperationImpl extends ObjectModelElementImpl implements + ObjectModelOperation { + + protected ObjectModelParameter returnParameter = null; + + protected String visibility = "public"; + + protected String transactionLevel = "supports"; + + protected boolean abstractz = false; + + protected List parameters = new ArrayList(); + + protected Set exceptions = new HashSet(); + + public ObjectModelOperationImpl() { + super(); + } + + public String toString() { + return getName() + "(" + parameters + ")" + "<<" + getStereotypes() + + ">> throws " + exceptions + " tagvalue: " + getTagValues(); + } + + /** + * 2 operations are equal if the have same name and same argument type. + */ + public boolean equals(Object o) { + if (o instanceof ObjectModelOperation) { + ObjectModelOperation op = (ObjectModelOperation) o; + if (getName().equals(op.getName()) + && getParameters().size() == op.getParameters().size()) { + for (Iterator i = getParameters().iterator(), opi = op + .getParameters().iterator(); i.hasNext() + && opi.hasNext();) { + ObjectModelParameter p = (ObjectModelParameter) i.next(); + ObjectModelParameter pop = (ObjectModelParameter) opi + .next(); + if (!p.getType().equals(pop.getType())) { + return false; + } + } + return true; + } + } + return false; + } + + public void addParameter(ObjectModelParameterImpl parameter) { + // if (parameter == null) + // return new ObjectModelParameterImpl(objectModelImpl, this); + parameter.postInit(); + parameter.setDeclaringElement(this); + parameters.add(parameter); + // return parameter; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + public void setAbstract(boolean abstractz) { + this.abstractz = abstractz; + } + + public void setReturnParameter(ObjectModelParameterImpl returnParameter) { + // /if (returnParameter == null) + // return new ObjectModelParameterImpl(objectModelImpl, this); + returnParameter.postInit(); + returnParameter.setDeclaringElement(this); + this.returnParameter = returnParameter; + // return returnParameter; + } + + public String getReturnType() { + return returnParameter.getType(); + } + + public String getVisibility() { + return visibility; + } + + /** + * Returns whether this operation is abstract or not. + * + * @return a boolean indicating whether this operation is abstract or not. + */ + public boolean isAbstract() { + return abstractz; + } + + public Collection getParameters() { + return parameters; + } + + public void addExceptionParameter(ObjectModelParameterImpl raisedParameter) { + // if (raisedParameter == null) { + // return new ObjectModelParameterImpl(objectModelImpl, this); + // } + raisedParameter.postInit(); + raisedParameter.setDeclaringElement(this); + + this.exceptions.add(raisedParameter.getType()); + // return raisedParameter; + } + + public Set getExceptions() { + return exceptions; + } } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplRef.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplRef.java:1.6 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplRef.java:1.7 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplRef.java:1.6 Thu May 19 09:18:23 2005 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplRef.java Fri May 25 16:14:19 2007 @@ -23,10 +23,10 @@ * * @author Cédric Pineau * Copyright Code Lutin -* @version $Revision: 1.6 $ +* @version $Revision: 1.7 $ * -* Last update : $Date: 2005/05/19 09:18:23 $ -* by : $Author: thimel $ +* Last update : $Date: 2007/05/25 16:14:19 $ +* by : $Author: chatellier $ */ package org.codelutin.generator.models.object.xml; @@ -36,7 +36,7 @@ public void postInit() {} - public void parsetName(String name) { + public void setName(String name) { this.name = name; } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplSuperClassRef.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplSuperClassRef.java:1.1 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplSuperClassRef.java:1.2 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplSuperClassRef.java:1.1 Thu Jul 8 14:03:46 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplSuperClassRef.java Fri May 25 16:14:19 2007 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *##%*/ +package org.codelutin.generator.models.object.xml; + /* * * ObjectModelImplRef.java * @@ -23,22 +25,16 @@ * * @author Cédric Pineau * Copyright Code Lutin -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * -* Last update : $Date: 2004/07/08 14:03:46 $ -* by : $Author: pineau $ +* Last update : $Date: 2007/05/25 16:14:19 $ +* by : $Author: chatellier $ */ -package org.codelutin.generator.models.object.xml; - public class ObjectModelImplSuperClassRef extends ObjectModelImplRef { protected String discrimininator = null; - - public void postInit() { - super.postInit(); - } - public void parsetDiscriminator (String discrimininator) { + public void setDiscriminator (String discrimininator) { this.discrimininator = discrimininator; } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassifierImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassifierImpl.java:1.5 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassifierImpl.java:1.6 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassifierImpl.java:1.5 Wed Jan 4 13:29:11 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassifierImpl.java Fri May 25 16:14:19 2007 @@ -1,27 +1,43 @@ -/* - * Created on May 13, 2004 +/* *##% + * Copyright (C) 2004-2007 Code Lutin * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ package org.codelutin.generator.models.object.xml; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelElement; +import org.codelutin.generator.models.object.ObjectModelInterface; import org.codelutin.generator.models.object.ObjectModelOperation; -import java.util.LinkedList; -import java.util.HashSet; - /** + * + * ObjectModelClassifierImpl.java + * + * @author chatellier * @author cedric + * @version $Revision: 1.6 $ * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * Last update : $Date: 2007/05/25 16:14:19 $ + * By : $Author: chatellier $ */ public abstract class ObjectModelClassifierImpl extends ObjectModelElementImpl implements ObjectModelClassifier { @@ -29,17 +45,17 @@ protected String qualifiedName = null; protected String packageName = null; - protected ArrayList interfaces = null; - protected ArrayList interfacesRefs = new ArrayList(); - protected ArrayList operations = new ArrayList(); + protected List interfaces = null; + protected List interfacesRefs = new ArrayList(); + protected List operations = new ArrayList(); protected String type = null; public String toString(){ return "" + getQualifiedName() + " implements " + getInterfaces(); } - public ObjectModelClassifierImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); + public ObjectModelClassifierImpl() { + super(); } public void postInit() { @@ -47,30 +63,31 @@ qualifiedName = packageName + "." + name; } - public void parsetExtern(boolean extern) { + public void setExtern(boolean extern) { this.extern = extern; } - public void parsetPackage(String packageName) { + public void setPackage(String packageName) { this.packageName = packageName; } - public ObjectModelImplRef parsetInterface(ObjectModelImplRef ref) { - if (ref == null) - return new ObjectModelImplRef(); + public void addInterface(ObjectModelImplRef ref) { + //if (ref == null) + // return new ObjectModelImplRef(); interfacesRefs.add(ref); - return ref; + //return ref; } - public ObjectModelOperationImpl parsetOperation(ObjectModelOperationImpl operation) { - if (operation == null) - return new ObjectModelOperationImpl(objectModelImpl, this); + public void addOperation(ObjectModelOperationImpl operation) { + //if (operation == null) + // return new ObjectModelOperationImpl(objectModelImpl, this); operation.postInit(); + operation.setDeclaringElement(this); operations.add(operation); - return operation; + //return operation; } - public void parsetType(String type) { + public void setType(String type) { this.type = type; } @@ -86,9 +103,9 @@ return qualifiedName; } - public Collection getInterfaces() { + public Collection getInterfaces() { if (interfaces == null) { - interfaces = new ArrayList(); + interfaces = new ArrayList(); Iterator i = interfacesRefs.iterator(); while (i.hasNext()) { ObjectModelImplRef ref = (ObjectModelImplRef) i.next(); @@ -98,10 +115,10 @@ return interfaces; } - public Collection getOperations(String name) { - ArrayList result = new ArrayList(); - for(Iterator i=getOperations().iterator(); i.hasNext();){ - ObjectModelOperation op = (ObjectModelOperation)i.next(); + public Collection getOperations(String name) { + List result = new ArrayList(); + for(Iterator i=getOperations().iterator(); i.hasNext();){ + ObjectModelOperation op = i.next(); if(name.equals(op.getName())){ result.add(op); } @@ -109,26 +126,26 @@ return result; } - public Collection getOperations() { + public Collection getOperations() { return operations; } - public Collection getAllOtherOperations(boolean distinct){ + public Collection getAllOtherOperations(boolean distinct){ return getAllInterfaceOperations(distinct); } - public Collection getAllInterfaceOperations(boolean distinct){ - Collection result = null; + public Collection getAllInterfaceOperations(boolean distinct){ + Collection result = null; if(distinct){ - result = new HashSet(); + result = new HashSet(); }else{ - result = new LinkedList(); + result = new LinkedList(); } getAllInterfaceOperations(result); return result; } - protected Collection getAllInterfaceOperations(Collection result){ + protected Collection getAllInterfaceOperations(Collection result){ for(Iterator i=getInterfaces().iterator(); i.hasNext();){ ObjectModelClassifierImpl interfacez = (ObjectModelClassifierImpl)i.next(); Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImpl.java:1.21 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImpl.java:1.22 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImpl.java:1.21 Tue Jan 24 18:20:00 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImpl.java Fri May 25 16:14:19 2007 @@ -1,33 +1,33 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*##%*/ + * Copyright (C) 2002, 2003, 2004 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ /* * -* ObjectModelImpl.java -* -* Created: 14 janv. 2004 -* -* @author C�dric Pineau -* Copyright Code Lutin -* @version $Revision: 1.21 $ -* -* Last update : $Date: 2006/01/24 18:20:00 $ -* by : $Author: bpoussin $ -*/ + * ObjectModelImpl.java + * + * Created: 14 janv. 2004 + * + * @author C�dric Pineau + * Copyright Code Lutin + * @version $Revision: 1.22 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ + * by : $Author: chatellier $ + */ package org.codelutin.generator.models.object.xml; import java.util.ArrayList; @@ -38,330 +38,411 @@ import java.util.Map; import org.codelutin.generator.models.object.ObjectModel; +import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; import org.codelutin.generator.models.object.ObjectModelInterface; /** -* Implementation class for the root node abstraction of object model trees. -* This an entry point for browsing a model tree. This object offers as well several facilities for a direct access to some of the object model elements. -* In this concrete class, the tree is build by parsing an object model xml description using lutinxml XMLObjectParser. -*/ + * Implementation class for the root node abstraction of object model trees. + * This an entry point for browsing a model tree. This object offers as well + * several facilities for a direct access to some of the object model elements. + * In this concrete class, the tree is build by parsing an object model xml + * description using lutinxml XMLObjectParser. + */ public class ObjectModelImpl implements ObjectModel { - protected String name = null; - protected HashMap classes = new HashMap(); - protected HashMap interfaces = new HashMap(); - protected HashMap classifiers = new HashMap(); - protected List comments = new ArrayList(); - private HashMap tagValues = new HashMap(); - - public void parsetName(String name) { - this.name = name; - } - - public ObjectModelClassImpl parsetClass(ObjectModelClassImpl clazz) { - if (clazz == null) - return new ObjectModelClassImpl(this, null); - clazz.postInit(); - if (! clazz.isExtern()) { - ObjectModelElementImpl initialElement = (ObjectModelElementImpl)classes.get(clazz.getQualifiedName()); - if (initialElement == null) { - classes.put(clazz.getQualifiedName(), clazz); - classifiers.put(clazz.getQualifiedName(), clazz); - } else { - if (!(initialElement instanceof ObjectModelClassImpl)) - throw new IllegalArgumentException("\"" + clazz + "\" is incompatible with already defined element \"" + initialElement + "\""); - ObjectModelClassImpl initialClazz = (ObjectModelClassImpl)initialElement; - - //La classe existe déjà. On va prendre tout ce que contient la - //nouvelle classe et l'ajouter à la précédente si nécessaire. - - mergeClasses(initialClazz, clazz); - clazz = initialClazz; - } - } - return clazz; - } - - public ObjectModelClassImpl parsetAssociationClass(ObjectModelAssociationClassImpl clazz) { - if (clazz == null) - return new ObjectModelAssociationClassImpl(this, null); - clazz.postInit(); - if (! clazz.isExtern()) { - ObjectModelElementImpl initialElement = (ObjectModelElementImpl)classes.get(clazz.getQualifiedName()); - if (initialElement == null) { - classes.put(clazz.getQualifiedName(), clazz); - classifiers.put(clazz.getQualifiedName(), clazz); - } else { - if (!(initialElement instanceof ObjectModelAssociationClassImpl)) - throw new IllegalArgumentException("\"" + clazz + "\" is incompatible with already defined element \"" + initialElement + "\""); - ObjectModelAssociationClassImpl initialClazz = (ObjectModelAssociationClassImpl)initialElement; - - mergeAssociationClasses(initialClazz, clazz); - clazz = initialClazz; - } - } - return clazz; - } - - public void parsetComment(String comment) { - this.comments.add(comment); - } - - /** - * Returns the name of this model. - * - * @return the name of this model. - */ - public String getName() { - return name; - } - - /** - * Returns all classifiers defined in this model. - * @see ObjectModelClassifier - * - * @return a Collection containing all ObjectModelClassifier for this model. - */ - public Collection getClassifiers() { - return classifiers.values(); - } - - /** - * Returns the classifier corresponding to the given qualified name, or null if the model contains no classifier for this qualified name. - * @param qualifiedClassifierName - the qualified name of the classifier to retrieve. - * - * @return the ObjectModelClassifier of the found classifier, or null if the model contains no classifier for this qualified name. - */ - public ObjectModelClassifier getClassifier(String qualifiedClassifierName) { - return (qualifiedClassifierName == null?null:(ObjectModelClassifier) classifiers.get(qualifiedClassifierName)); - } - - /** - * Returns all classes defined in this model. - * @see ObjectModelClass. - * - * @return a Collection containing all ObjectModelClass for this model. - */ - public Collection getClasses() { - return classes.values(); - } - - /** - * Returns the class corresponding to the given qualified name, or null if the model contains no class for this qualified name. - * @param qualifiedClassName - the qualified name of the class to retrieve. - * - * @return the ObjectModelClass of the found class, or null if the model contains no class for this qualified name. - */ - public ObjectModelClass getClass(String qualifiedClassName) { - if (qualifiedClassName == null) return null; - if (!hasClass(qualifiedClassName)) { - System.out.println("WARNING : Class "+ qualifiedClassName +" not found in model"); - System.out.println("You may forgot to declare for good an external class ?"); - } - return (ObjectModelClass) classes.get(qualifiedClassName); - } - - /* (non-Javadoc) - * @see org.codelutin.generator.models.object.ObjectModel#hasClass(java.lang.String) - */ - public boolean hasClass(String qualifiedClassName){ - return classes.containsKey(qualifiedClassName); - } - - public ObjectModelInterfaceImpl parsetInterface(ObjectModelInterfaceImpl interfacez) { - if (interfacez == null) - return new ObjectModelInterfaceImpl(this, null); - interfacez.postInit(); - if (! interfacez.isExtern()) { - ObjectModelElementImpl initialElement = (ObjectModelElementImpl)interfaces.get(interfacez.getQualifiedName()); - if (initialElement == null) { - interfaces.put(interfacez.getQualifiedName(), interfacez); - classifiers.put(interfacez.getQualifiedName(), interfacez); - } else { - if (!(initialElement instanceof ObjectModelInterfaceImpl)) - throw new IllegalArgumentException("\"" + interfacez + "\" is incompatible with already defined element \"" + initialElement + "\""); - ObjectModelInterfaceImpl initialInterfacez = (ObjectModelInterfaceImpl)initialElement; - - mergeClassifiers(initialInterfacez, interfacez); - interfacez = initialInterfacez; - } - } - return interfacez; - } - - /** - * Returns the interface corresponding to the given qualified name, or null if the model contains no interface for this qualified name. - * @param qualifiedInterfaceName - the qualified name of the interface to retrieve. - * - * @return the ObjectModelInterface of the found interface, or null if the model contains no interface for this qualified name. - */ - public ObjectModelInterface getInterface(String qualifiedInterfaceName) { - ObjectModelInterface result = null; - result = (ObjectModelInterface)interfaces.get(qualifiedInterfaceName); - if(result == null){ - System.out.println("WARNING : Class "+ qualifiedInterfaceName +" not found in model"); - } - return result; - } - - /** - * Returns all interfaces defined in this model. - * @see ObjectModelInterface. - * - * @return a Collection containing all ObjectModelInterface for this model. - */ - public Collection getInterfaces() { - return interfaces.values(); - } - - /** - * Returns all comments not lied to a particular model element - * - * @return a List containing all comments for this model as Strings. - */ - public List getComments() { - return comments; - } - - private void mergeClassifiers(ObjectModelClassifierImpl initialClazzifier, ObjectModelClassifierImpl additionalClazzifier) { - Iterator it; - - //On n'utilise pas les parsetXXX puisque les post-init sont censés être déjà faits... - - //System.out.println("Doc initial : " + initialClazzifier.documentation); - //System.out.println("Doc additional : " + additionalClazzifier.documentation); - String description = ""; - String sourceDoc = ""; - if (initialClazzifier.documentation != null) { - description += initialClazzifier.getDescription(); - if (initialClazzifier.documentation.contains("--")) - sourceDoc += initialClazzifier.getSourceDocumentation(); - } - if (additionalClazzifier.documentation != null) { - if (!description.equals("")) - description += " - "; - description += additionalClazzifier.getDescription(); - if (additionalClazzifier.documentation.contains("--")) { - if (!sourceDoc.equals("")) - sourceDoc += " - "; - sourceDoc += additionalClazzifier.getSourceDocumentation(); - } - } - if (!description.equals("") || !sourceDoc.equals("")) - initialClazzifier.documentation = description + "--" + sourceDoc; - - //System.out.println("Doc after : " + initialClazzifier.documentation); - - for (it = additionalClazzifier.interfacesRefs.iterator(); it.hasNext(); ) { - ObjectModelImplRef interfaceRef = (ObjectModelImplRef)it.next(); - if (!contains(initialClazzifier.interfacesRefs, interfaceRef)) - initialClazzifier.interfacesRefs.add(interfaceRef); - initialClazzifier.interfaces = null; //On force ainsi à regénérer l'objet - } - for (it = additionalClazzifier.getOperations().iterator(); it.hasNext(); ) { - ObjectModelOperationImpl operation = (ObjectModelOperationImpl)it.next(); - if (!contains(initialClazzifier.getOperations(),operation)) - initialClazzifier.operations.add(operation); - } - for (it = additionalClazzifier.getComments().iterator(); it.hasNext(); ) { - String comment = (String)it.next(); - if (!initialClazzifier.comments.contains(comment)) - initialClazzifier.comments.add(comment); - } - for (it = additionalClazzifier.getStereotypes().iterator(); it.hasNext(); ) { - String stereotype = (String)it.next(); - if (!initialClazzifier.getStereotypes().contains(stereotype)) - initialClazzifier.stereotypes.add(stereotype); - } - - for (it = additionalClazzifier.getTagValues().keySet().iterator(); it.hasNext(); ) { - String tagName = (String)it.next(); - if (!initialClazzifier.getTagValues().containsKey(tagName)) - initialClazzifier.tagValues.put(tagName, additionalClazzifier.getTagValue(tagName)); - } - } - - - /** - * This method takes two ObjectModelClassImpl and merges both of them in the first one - * @param initialClazz the instance of ObjectModelClassImpl to be modified - * @param additionalClazz the instance of ObjectModelClassImpl tu be used for merging - */ - private void mergeClasses(ObjectModelClassImpl initialClazz, ObjectModelClassImpl additionalClazz) { - Iterator it; - mergeClassifiers(initialClazz, additionalClazz); - - for (it = additionalClazz.getAttributes().iterator(); it.hasNext();) { - ObjectModelAttributeImpl attribute = (ObjectModelAttributeImpl)it.next(); - if (!contains(initialClazz.getAttributes(), attribute)) { - initialClazz.attributes.put(attribute.getName(), attribute); - initialClazz.orderedAttributes.add(attribute); - } - } - for (it = additionalClazz.superclassesRefs.iterator(); it.hasNext(); ) { - ObjectModelImplRef superclassRef = (ObjectModelImplRef)it.next(); - if (!contains(initialClazz.superclassesRefs, superclassRef)) - initialClazz.superclassesRefs.add(superclassRef); - initialClazz.superclasses = null; //On force ainsi à regénérer l'objet - } - } - - private void mergeAssociationClasses(ObjectModelAssociationClassImpl initialAssocClazz, ObjectModelAssociationClassImpl additionalAssocClazz) { - mergeClasses(initialAssocClazz, additionalAssocClazz); - Iterator it; - for (it = additionalAssocClazz.participantsRefs.iterator(); it.hasNext(); ) { - ObjectModeImplAssociationClassParticipant participant = - (ObjectModeImplAssociationClassParticipant)it.next(); - if (!contains(initialAssocClazz.participantsRefs, participant)) - initialAssocClazz.participantsRefs.add(participant); - initialAssocClazz.participantsAttributes = null; //On force ainsi à regénérer l'objet - initialAssocClazz.participantsClassifiers = null; //On force ainsi à regénérer l'objet - } - } - - private boolean contains(Collection coll, ObjectModelAttributeImpl toFind) { - for (Iterator it = coll.iterator(); it.hasNext(); ) { - ObjectModelAttributeImpl attribute = (ObjectModelAttributeImpl)it.next(); - if (attribute.getName().equals(toFind.getName())) //Seul le nom de l'attribut compte - return true; - } - return false; - } - - private boolean contains(Collection coll, ObjectModelOperationImpl toFind) { - return coll.contains(toFind); //Le equals(...) de ObjectModelOperationImpl convient - } - - private boolean contains(Collection coll, ObjectModelImplRef toFind) { - return coll.contains(toFind); //Le equals(...) de ObjectModelImplRef convient - } - - public ObjectModelImplTagValue parsetTagValue(ObjectModelImplTagValue tagValue) { - if (tagValue == null) - return new ObjectModelImplTagValue(); - tagValues .put(tagValue.getName(), tagValue.getValue()); - return tagValue; - } - - /** - * Returns the tagValues associated with this element. - * For each entry, the key is the name of the tagValue, the value is the value of the tagValue :-) - * - * @return a Map containing all tagValues associated with this element - */ - public Map getTagValues() { - return tagValues; - } - - /** - * Returns the tagValue corresponding to the given name, or null if the element has no associated tagValue for this name. - * - * @return the value of the found tagValue, or null if the element has no associated tagValue for this name. - */ - public String getTagValue(String tagValue) { - return (tagValue == null?null:(String) tagValues.get(tagValue)); - } - + protected String name = null; + protected Map classes = new HashMap(); + protected Map interfaces = new HashMap(); + protected Map classifiers = new HashMap(); + protected List comments = new ArrayList(); + private Map tagValues = new HashMap(); + + public void setName(String name) { + this.name = name; + } + + public void addClass(ObjectModelClassImpl clazz) { + //if (clazz == null) + // return new ObjectModelClassImpl(this, null); + clazz.postInit(); + clazz.setObjectModelImpl(this); + + if (!clazz.isExtern()) { + ObjectModelElementImpl initialElement = (ObjectModelElementImpl) classes + .get(clazz.getQualifiedName()); + if (initialElement == null) { + classes.put(clazz.getQualifiedName(), clazz); + classifiers.put(clazz.getQualifiedName(), clazz); + } else { + if (!(initialElement instanceof ObjectModelClassImpl)) + throw new IllegalArgumentException( + "\"" + + clazz + + "\" is incompatible with already defined element \"" + + initialElement + "\""); + ObjectModelClassImpl initialClazz = (ObjectModelClassImpl) initialElement; + + // La classe existe déjà. On va prendre tout ce que contient la + // nouvelle classe et l'ajouter à la précédente si nécessaire. + + mergeClasses(initialClazz, clazz); + clazz = initialClazz; + } + } + //return clazz; + } + + public void addAssociationClass( + ObjectModelAssociationClassImpl clazz) { + //if (clazz == null) + // return new ObjectModelAssociationClassImpl(this, null); + clazz.postInit(); + clazz.setObjectModelImpl(this); + + if (!clazz.isExtern()) { + ObjectModelElementImpl initialElement = (ObjectModelElementImpl) classes + .get(clazz.getQualifiedName()); + if (initialElement == null) { + classes.put(clazz.getQualifiedName(), clazz); + classifiers.put(clazz.getQualifiedName(), clazz); + } else { + if (!(initialElement instanceof ObjectModelAssociationClassImpl)) + throw new IllegalArgumentException( + "\"" + + clazz + + "\" is incompatible with already defined element \"" + + initialElement + "\""); + ObjectModelAssociationClassImpl initialClazz = (ObjectModelAssociationClassImpl) initialElement; + + mergeAssociationClasses(initialClazz, clazz); + clazz = initialClazz; + } + } + //return clazz; + } + + public void addComment(String comment) { + this.comments.add(comment); + } + + /** + * Returns the name of this model. + * + * @return the name of this model. + */ + public String getName() { + return name; + } + + /** + * Returns all classifiers defined in this model. + * + * @see ObjectModelClassifier + * + * @return a Collection containing all ObjectModelClassifier for this model. + */ + public Collection getClassifiers() { + return classifiers.values(); + } + + /** + * Returns the classifier corresponding to the given qualified name, or null + * if the model contains no classifier for this qualified name. + * + * @param qualifiedClassifierName - + * the qualified name of the classifier to retrieve. + * + * @return the ObjectModelClassifier of the found classifier, or null if the + * model contains no classifier for this qualified name. + */ + public ObjectModelClassifier getClassifier(String qualifiedClassifierName) { + return (qualifiedClassifierName == null ? null + : (ObjectModelClassifier) classifiers + .get(qualifiedClassifierName)); + } + + /** + * Returns all classes defined in this model. + * + * @see ObjectModelClass. + * + * @return a Collection containing all ObjectModelClass for this model. + */ + public Collection getClasses() { + return classes.values(); + } + + /** + * Returns the class corresponding to the given qualified name, or null if + * the model contains no class for this qualified name. + * + * @param qualifiedClassName - + * the qualified name of the class to retrieve. + * + * @return the ObjectModelClass of the found class, or null if the model + * contains no class for this qualified name. + */ + public ObjectModelClass getClass(String qualifiedClassName) { + if (qualifiedClassName == null) + return null; + if (!hasClass(qualifiedClassName)) { + System.out.println("WARNING : Class " + qualifiedClassName + + " not found in model"); + System.out + .println("You may forgot to declare for good an external class ?"); + } + return (ObjectModelClass) classes.get(qualifiedClassName); + } + + /* + * (non-Javadoc) + * + * @see org.codelutin.generator.models.object.ObjectModel#hasClass(java.lang.String) + */ + public boolean hasClass(String qualifiedClassName) { + return classes.containsKey(qualifiedClassName); + } + + public void addInterface(ObjectModelInterfaceImpl interfacez) { + //if (interfacez == null) + // return new ObjectModelInterfaceImpl(this, null); + interfacez.postInit(); + interfacez.setObjectModelImpl(this); + + if (!interfacez.isExtern()) { + ObjectModelElementImpl initialElement = (ObjectModelElementImpl) interfaces + .get(interfacez.getQualifiedName()); + if (initialElement == null) { + interfaces.put(interfacez.getQualifiedName(), interfacez); + classifiers.put(interfacez.getQualifiedName(), interfacez); + } else { + if (!(initialElement instanceof ObjectModelInterfaceImpl)) + throw new IllegalArgumentException( + "\"" + + interfacez + + "\" is incompatible with already defined element \"" + + initialElement + "\""); + ObjectModelInterfaceImpl initialInterfacez = (ObjectModelInterfaceImpl) initialElement; + + mergeClassifiers(initialInterfacez, interfacez); + interfacez = initialInterfacez; + } + } + //return interfacez; + } + + /** + * Returns the interface corresponding to the given qualified name, or null + * if the model contains no interface for this qualified name. + * + * @param qualifiedInterfaceName - + * the qualified name of the interface to retrieve. + * + * @return the ObjectModelInterface of the found interface, or null if the + * model contains no interface for this qualified name. + */ + public ObjectModelInterface getInterface(String qualifiedInterfaceName) { + ObjectModelInterface result = null; + result = (ObjectModelInterface) interfaces.get(qualifiedInterfaceName); + if (result == null) { + System.out.println("WARNING : Class " + qualifiedInterfaceName + + " not found in model"); + } + return result; + } + + /** + * Returns all interfaces defined in this model. + * + * @see ObjectModelInterface. + * + * @return a Collection containing all ObjectModelInterface for this model. + */ + public Collection getInterfaces() { + return interfaces.values(); + } + + /** + * Returns all comments not lied to a particular model element + * + * @return a List containing all comments for this model as Strings. + */ + public List getComments() { + return comments; + } + + private void mergeClassifiers(ObjectModelClassifierImpl initialClazzifier, + ObjectModelClassifierImpl additionalClazzifier) { + Iterator it; + + // On n'utilise pas les parsetXXX puisque les post-init sont censés être + // déjà faits... + + // System.out.println("Doc initial : " + + // initialClazzifier.documentation); + // System.out.println("Doc additional : " + + // additionalClazzifier.documentation); + String description = ""; + String sourceDoc = ""; + if (initialClazzifier.documentation != null) { + description += initialClazzifier.getDescription(); + if (initialClazzifier.documentation.contains("--")) + sourceDoc += initialClazzifier.getSourceDocumentation(); + } + if (additionalClazzifier.documentation != null) { + if (!description.equals("")) + description += " - "; + description += additionalClazzifier.getDescription(); + if (additionalClazzifier.documentation.contains("--")) { + if (!sourceDoc.equals("")) + sourceDoc += " - "; + sourceDoc += additionalClazzifier.getSourceDocumentation(); + } + } + if (!description.equals("") || !sourceDoc.equals("")) + initialClazzifier.documentation = description + "--" + sourceDoc; + + // System.out.println("Doc after : " + initialClazzifier.documentation); + + for (it = additionalClazzifier.interfacesRefs.iterator(); it.hasNext();) { + ObjectModelImplRef interfaceRef = (ObjectModelImplRef) it.next(); + if (!contains(initialClazzifier.interfacesRefs, interfaceRef)) + initialClazzifier.interfacesRefs.add(interfaceRef); + initialClazzifier.interfaces = null; // On force ainsi à + // regénérer l'objet + } + for (it = additionalClazzifier.getOperations().iterator(); it.hasNext();) { + ObjectModelOperationImpl operation = (ObjectModelOperationImpl) it + .next(); + if (!contains(initialClazzifier.getOperations(), operation)) + initialClazzifier.operations.add(operation); + } + for (it = additionalClazzifier.getComments().iterator(); it.hasNext();) { + String comment = (String) it.next(); + if (!initialClazzifier.comments.contains(comment)) + initialClazzifier.comments.add(comment); + } + for (it = additionalClazzifier.getStereotypes().iterator(); it + .hasNext();) { + String stereotype = (String) it.next(); + if (!initialClazzifier.getStereotypes().contains(stereotype)) + initialClazzifier.stereotypes.add(stereotype); + } + + for (it = additionalClazzifier.getTagValues().keySet().iterator(); it + .hasNext();) { + String tagName = (String) it.next(); + if (!initialClazzifier.getTagValues().containsKey(tagName)) + initialClazzifier.tagValues.put(tagName, additionalClazzifier + .getTagValue(tagName)); + } + } + + /** + * This method takes two ObjectModelClassImpl and merges both of them in the + * first one + * + * @param initialClazz + * the instance of ObjectModelClassImpl to be modified + * @param additionalClazz + * the instance of ObjectModelClassImpl tu be used for merging + */ + private void mergeClasses(ObjectModelClassImpl initialClazz, + ObjectModelClassImpl additionalClazz) { + Iterator it; + mergeClassifiers(initialClazz, additionalClazz); + + for (it = additionalClazz.getAttributes().iterator(); it.hasNext();) { + ObjectModelAttributeImpl attribute = (ObjectModelAttributeImpl) it + .next(); + if (!contains(initialClazz.getAttributes(), attribute)) { + initialClazz.attributes.put(attribute.getName(), attribute); + initialClazz.orderedAttributes.add(attribute); + } + } + for (it = additionalClazz.superclassesRefs.iterator(); it.hasNext();) { + ObjectModelImplRef superclassRef = (ObjectModelImplRef) it.next(); + if (!contains(initialClazz.superclassesRefs, superclassRef)) + initialClazz.superclassesRefs.add(superclassRef); + initialClazz.superclasses = null; // On force ainsi à regénérer + // l'objet + } + } + + private void mergeAssociationClasses( + ObjectModelAssociationClassImpl initialAssocClazz, + ObjectModelAssociationClassImpl additionalAssocClazz) { + mergeClasses(initialAssocClazz, additionalAssocClazz); + Iterator it; + for (it = additionalAssocClazz.participantsRefs.iterator(); it + .hasNext();) { + ObjectModeImplAssociationClassParticipant participant = (ObjectModeImplAssociationClassParticipant) it + .next(); + if (!contains(initialAssocClazz.participantsRefs, participant)) + initialAssocClazz.participantsRefs.add(participant); + initialAssocClazz.participantsAttributes = null; // On force + // ainsi à + // regénérer + // l'objet + initialAssocClazz.participantsClassifiers = null; // On force + // ainsi à + // regénérer + // l'objet + } + } + + private boolean contains(Collection coll, + ObjectModelAttributeImpl toFind) { + for (Iterator it = coll.iterator(); it + .hasNext();) { + ObjectModelAttribute attribute = it.next(); + if (attribute.getName().equals(toFind.getName())) // Seul le nom + // de l'attribut + // compte + return true; + } + return false; + } + + private boolean contains(Collection coll, ObjectModelOperationImpl toFind) { + return coll.contains(toFind); // Le equals(...) de + // ObjectModelOperationImpl convient + } + + private boolean contains(Collection coll, ObjectModelImplRef toFind) { + return coll.contains(toFind); // Le equals(...) de ObjectModelImplRef + // convient + } + + public ObjectModelImplTagValue addTagValue( + ObjectModelImplTagValue tagValue) { + if (tagValue == null) + return new ObjectModelImplTagValue(); + tagValues.put(tagValue.getName(), tagValue.getValue()); + return tagValue; + } + + /** + * Returns the tagValues associated with this element. For each entry, the + * key is the name of the tagValue, the value is the value of the tagValue + * :-) + * + * @return a Map containing all tagValues associated with this element + */ + public Map getTagValues() { + return tagValues; + } + + /** + * Returns the tagValue corresponding to the given name, or null if the + * element has no associated tagValue for this name. + * + * @return the value of the found tagValue, or null if the element has no + * associated tagValue for this name. + */ + public String getTagValue(String tagValue) { + return (tagValue == null ? null : (String) tagValues.get(tagValue)); + } } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplTagValue.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplTagValue.java:1.1 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplTagValue.java:1.2 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplTagValue.java:1.1 Thu May 13 09:18:36 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelImplTagValue.java Fri May 25 16:14:19 2007 @@ -1,27 +1,40 @@ -/* - * Created on May 13, 2004 +/* *##% + * Copyright (C) 2004-2007 Code Lutin * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ package org.codelutin.generator.models.object.xml; /** + * ObjectModelImplTagValue.java + * * @author cedric - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * @author chatellier + * @version $Revision: 1.2 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ By : $Author: chatellier $ */ public class ObjectModelImplTagValue extends ObjectModelImplRef { protected String value = null; - public void parsetValue(String value) { + public void setValue(String value) { this.value = value; } public String getValue() { return value; } - } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java:1.5 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java:1.6 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java:1.5 Wed Jun 30 13:27:25 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java Fri May 25 16:14:19 2007 @@ -1,9 +1,21 @@ -/* - * Created on May 11, 2004 +/* *##% + * Copyright (C) 2006 Code Lutin * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + package org.codelutin.generator.models.object.xml; import java.util.Iterator; @@ -11,10 +23,14 @@ import org.codelutin.generator.Util; /** - * @author cedric + * + * ObjectModeImplAssociationClassParticipant.java * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * @author cedric,chatellier + * @version $Revision: 1.6 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ + * By : $Author: chatellier $ */ public class ObjectModeImplAssociationClassParticipant extends ObjectModelImplRef { @@ -22,15 +38,18 @@ protected String attributeName = null; - public ObjectModeImplAssociationClassParticipant(ObjectModelAssociationClassImpl associationClass) { - this.associationClass = associationClass; + public ObjectModeImplAssociationClassParticipant() { + super(); } - - public void postInit() { - super.postInit(); + + /** + * @param associationClass the associationClass to set + */ + public void setAssociationClass(ObjectModelAssociationClassImpl associationClass) { + this.associationClass = associationClass; } - public void parsetAttribute(String attributeName) { + public void setAttribute(String attributeName) { this.attributeName = attributeName; } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java:1.22 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java:1.23 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java:1.22 Wed Mar 8 19:11:37 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java Fri May 25 16:14:19 2007 @@ -23,9 +23,9 @@ * * @author C�dric Pineau Copyright Code Lutin * - * @version $Revision: 1.22 $ + * @version $Revision: 1.23 $ * - * Last update : $Date: 2006/03/08 19:11:37 $ by : $Author: bpoussin $ + * Last update : $Date: 2007/05/25 16:14:19 $ by : $Author: chatellier $ */ package org.codelutin.generator.models.object.xml; @@ -34,38 +34,25 @@ import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelElement; public class ObjectModelAttributeImpl extends ObjectModelParameterImpl implements ObjectModelAttribute { protected String reverseAttributeName = null; - protected int reverseMaxMultiplicity = -1; - protected String associationType = null; - protected String visibility = "protected"; - protected int minMultiplicity = 1; - protected int maxMultiplicity = 1; - protected ObjectModelClassifier reference = null; - protected String associationClassName = null; - protected boolean isStatic = false; - protected boolean isFinal = false; - protected boolean isNavigable = true; - protected String ordering = "unspecified"; - public ObjectModelAttributeImpl(ObjectModelImpl objectModelImpl, - ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); + public ObjectModelAttributeImpl() { + super(); } public void postInit() { @@ -75,54 +62,47 @@ super.postInit(); } - public void parsetAssociationType(String associationType) { - this.associationType = associationType; + public void setReverseAttributeName(String reverseAttributeName) { + System.out.println("\n\n\nreverseAttribute\n\n\n"); + this.reverseAttributeName = reverseAttributeName; } - - public void parsetType(String type) { - this.type = type; - } - - public void parsetReverseAttribute(String reverseAttributeName) { - this.reverseAttributeName = reverseAttributeName; + + public void setAssociationType(String associationType) { + this.associationType = associationType; } - public void parsetReverseMaxMultiplicity(int reverseMaxMultiplicity) { + public void setReverseMaxMultiplicity(int reverseMaxMultiplicity) { this.reverseMaxMultiplicity = reverseMaxMultiplicity; } - public void parsetVisibility(String visibility) { + public void setVisibility(String visibility) { this.visibility = visibility; } - public void parsetFinal(boolean isFinal) { + public void setFinal(boolean isFinal) { this.isFinal = isFinal; } - public void parsetStatic(boolean isStatic) { + public void setStatic(boolean isStatic) { this.isStatic = isStatic; } - public void parsetMinMultiplicity(int minMultiplicity) { + public void setMinMultiplicity(int minMultiplicity) { this.minMultiplicity = minMultiplicity; } - public void parsetMaxMultiplicity(int maxMultiplicity) { + public void setMaxMultiplicity(int maxMultiplicity) { this.maxMultiplicity = maxMultiplicity; } - public void parsetNavigable(boolean isNavigable) { + public void setNavigable(boolean isNavigable) { this.isNavigable = isNavigable; } - public void parsetOrdering(String ordering) { + public void setOrdering(String ordering) { this.ordering = ordering; } - public String getType() { - return type; - } - /** * Returns whether this attribute is an aggregate or not. * @@ -155,7 +135,7 @@ return maxMultiplicity; } - public void parsetAssociationClass(String associationClassName) { + public void setAssociationClass(String associationClassName) { this.associationClassName = associationClassName; } @@ -177,7 +157,7 @@ * if it does not reference a model classifier. */ public ObjectModelClassifier getClassifier() { - return objectModelImpl.getClassifier(type); + return getModel().getClassifier(type); } /** @@ -204,7 +184,7 @@ public String getReverseAttributeName() { if ((reverseAttributeName == null) || ("".equals(reverseAttributeName))) { - reverseAttributeName = Util + reverseAttributeName = Util .toLowerCaseFirstLetter(getDeclaringElement().getName()); } return reverseAttributeName; @@ -234,7 +214,7 @@ * associated with this association, or null if there is none. */ public ObjectModelClass getAssociationClass() { - return objectModelImpl.getClass(associationClassName); + return getModel().getClass(associationClassName); } /** Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java:1.3 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java:1.4 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java:1.3 Mon Dec 6 18:40:04 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java Fri May 25 16:14:19 2007 @@ -15,10 +15,14 @@ import org.codelutin.generator.models.object.ObjectModelElement; /** + * ObjectModelElementImpl.java + * + * @author chatellier * @author cedric + * @version $Revision: 1.4 $ * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * Last update : $Date: 2007/05/25 16:14:19 $ + * By : $Author: chatellier $ */ public class ObjectModelElementImpl implements ObjectModelElement { @@ -27,40 +31,68 @@ protected String name = null; protected String documentation = null; - protected ArrayList stereotypes = new ArrayList(); - protected HashMap tagValues = new HashMap(); - protected List comments = new ArrayList(); - - public ObjectModelElementImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { + protected List stereotypes = new ArrayList(); + protected Map tagValues = new HashMap(); + protected List comments = new ArrayList(); + + public ObjectModelElementImpl() { + super(); + } + + /** + * @return the objectModelImpl + */ + public void setObjectModelImpl(ObjectModelImpl objectModelImpl) { this.objectModelImpl = objectModelImpl; + } + + /** + * @param declaringElement the declaringElement to set + */ + public void setDeclaringElement(ObjectModelElement declaringElement) { this.declaringElement = declaringElement; } + + /** + * TODO a tester + * @return + */ + protected ObjectModelImpl getModel() { + if(objectModelImpl != null) { + return objectModelImpl; + } + else if (declaringElement != null) { + return ((ObjectModelElementImpl)declaringElement).getModel(); + } + return null; + } + public void postInit() {} - public void parsetName(String name) { + public void setName(String name) { this.name = name; } - public void parsetDocumentation(String documentation) { + public void setDocumentation(String documentation) { this.documentation = documentation; } - public ObjectModelImplRef parsetStereotype(ObjectModelImplRef stereotype) { + public ObjectModelImplRef addStereotype(ObjectModelImplRef stereotype) { if (stereotype == null) return new ObjectModelImplRef(); stereotypes.add(stereotype.getName()); return stereotype; } - public ObjectModelImplTagValue parsetTagValue(ObjectModelImplTagValue tagValue) { + public ObjectModelImplTagValue addTagValue(ObjectModelImplTagValue tagValue) { if (tagValue == null) return new ObjectModelImplTagValue(); tagValues.put(tagValue.getName(), tagValue.getValue()); return tagValue; } - public void parsetComment(String comment) { + public void setComment(String comment) { this.comments.add(comment); } @@ -110,7 +142,7 @@ * * @return a Collection containing all stereotypes names associated with this element as String. */ - public Collection getStereotypes() { + public Collection getStereotypes() { return stereotypes; } @@ -129,7 +161,7 @@ * * @return a Map containing all tagValues associated with this element */ - public Map getTagValues() { + public Map getTagValues() { return tagValues; } @@ -147,7 +179,7 @@ * * @return a List containing all comments for this element as Strings. */ - public List getComments() { + public List getComments() { return comments; } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelInterfaceImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelInterfaceImpl.java:1.9 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelInterfaceImpl.java:1.10 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelInterfaceImpl.java:1.9 Thu Jul 15 16:35:25 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelInterfaceImpl.java Fri May 25 16:14:19 2007 @@ -1,85 +1,81 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*##%*/ + * Copyright (C) 2002, 2003, 2004 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ -/* * -* ObjectModelInterfaceImpl.java -* -* Created: 14 janv. 2004 -* -* @author Cédric Pineau -* Copyright Code Lutin -* @version $Revision: 1.9 $ -* -* Last update : $Date: 2004/07/15 16:35:25 $ -* by : $Author: pineau $ -*/ package org.codelutin.generator.models.object.xml; -import org.codelutin.generator.models.object.ObjectModelClass; -import org.codelutin.generator.models.object.ObjectModelElement; -import org.codelutin.generator.models.object.ObjectModelInterface; -import org.codelutin.generator.models.object.ObjectModelClassifier; import java.util.Iterator; -public class ObjectModelInterfaceImpl - extends ObjectModelClassifierImpl - implements ObjectModelInterface { - - public ObjectModelInterfaceImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); - } - - public void postInit() { - super.postInit(); - } - - public String toString(){ - StringBuffer result = new StringBuffer(); - result.append("interface " + getQualifiedName() + " "); - result.append("extends "); - for(Iterator i=getInterfaces().iterator(); i.hasNext();){ - result.append(((ObjectModelClassifier)i.next()).getName()); - if(i.hasNext()){ - result.append(", "); - } - } - return result.toString(); - } - - /** - * Returns whether this classifier is a class or not - * @see ObjectModelClass - * - * @return a boolean indicating whether this classifier is a class or not. - */ - public boolean isClass() { - return false; - } - - /** - * Returns whether this classifier is an interface or not - * @see ObjectModelInterface - * - * @return a boolean indicating whether this classifier is an interface or not. - */ - public boolean isInterface() { - return true; - } - +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +/* * + * ObjectModelInterfaceImpl.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * Copyright Code Lutin + * @version $Revision: 1.10 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ + * by : $Author: chatellier $ + */ +public class ObjectModelInterfaceImpl extends ObjectModelClassifierImpl + implements ObjectModelInterface { + + public ObjectModelInterfaceImpl() { + super(); + } + + public String toString() { + StringBuffer result = new StringBuffer(); + result.append("interface " + getQualifiedName() + " "); + result.append("extends "); + for (Iterator i = getInterfaces().iterator(); i.hasNext();) { + result.append(((ObjectModelClassifier) i.next()).getName()); + if (i.hasNext()) { + result.append(", "); + } + } + return result.toString(); + } + + /** + * Returns whether this classifier is a class or not + * + * @see ObjectModelClass + * + * @return a boolean indicating whether this classifier is a class or not. + */ + public boolean isClass() { + return false; + } + + /** + * Returns whether this classifier is an interface or not + * + * @see ObjectModelInterface + * + * @return a boolean indicating whether this classifier is an interface or + * not. + */ + public boolean isInterface() { + return true; + } } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAssociationClassImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAssociationClassImpl.java:1.11 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAssociationClassImpl.java:1.12 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAssociationClassImpl.java:1.11 Wed Jan 4 13:29:11 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAssociationClassImpl.java Fri May 25 16:14:19 2007 @@ -11,40 +11,44 @@ import java.util.Iterator; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.codelutin.generator.models.object.ObjectModelAssociationClass; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelElement; /** + * ObjectModelAssociationClassImpl.java + * + * @author chatellier * @author cedric + * @version $Revision: 1.12 $ * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * Last update : $Date: 2007/05/25 16:14:19 $ + * By : $Author: chatellier $ */ public class ObjectModelAssociationClassImpl extends ObjectModelClassImpl implements ObjectModelAssociationClass { - protected ArrayList participantsAttributes = null; - protected ArrayList participantsClassifiers = null; - protected ArrayList participantsRefs = new ArrayList(); - - public ObjectModelAssociationClassImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); - } - - public void postInit() { - super.postInit(); + private static final Log log = LogFactory.getLog(ObjectModelAssociationClassImpl.class); + + protected List participantsAttributes = null; + protected List participantsClassifiers = null; + protected List participantsRefs = new ArrayList(); + + public ObjectModelAssociationClassImpl() { + super(); } - public ObjectModeImplAssociationClassParticipant parsetParticipant(ObjectModeImplAssociationClassParticipant participant) { - if (participant == null) - return new ObjectModeImplAssociationClassParticipant(this); + public void addParticipant(ObjectModeImplAssociationClassParticipant participant) { + //if (participant == null) + // return new ObjectModeImplAssociationClassParticipant(this); participant.postInit(); + participant.setAssociationClass(this); participantsRefs.add(participant); - return participant; + //return participant; } /** @@ -53,7 +57,7 @@ * * @return a List containing all participants attributes for this association class. */ - public List getParticipantsAttributes() { + public List getParticipantsAttributes() { if (participantsAttributes == null) { parseParticipantsRefs(); } @@ -66,7 +70,7 @@ * * @return a List containing all participants classifiers for this association class. */ - public List getParticipantsClassifiers() { + public List getParticipantsClassifiers() { if (participantsClassifiers == null) { parseParticipantsRefs(); } @@ -74,8 +78,8 @@ } protected void parseParticipantsRefs() { - participantsClassifiers = new ArrayList(); - participantsAttributes = new ArrayList(); + participantsClassifiers = new ArrayList(); + participantsAttributes = new ArrayList(); for (Iterator i = participantsRefs.iterator(); i.hasNext();) { ObjectModeImplAssociationClassParticipant ref = (ObjectModeImplAssociationClassParticipant) i.next(); @@ -85,8 +89,8 @@ if (classifier.isClass()) { attribute = ((ObjectModelClass) classifier).getAttribute(ref.getAttributeName()); if (attribute == null) { - System.out.println("WARNING : Attribute "+ ref.getAttributeName() +" not found on "+classifier.getQualifiedName()); - System.out.println("WARNING : Assuming there is no navigability in this direction for the "+ getQualifiedName()+" association class"); + log.warn("WARNING : Attribute "+ ref.getAttributeName() +" not found on "+classifier.getQualifiedName()); + log.warn("WARNING : Assuming there is no navigability in this direction for the "+ getQualifiedName()+" association class"); } } participantsAttributes.add(attribute); Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelParameterImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelParameterImpl.java:1.7 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelParameterImpl.java:1.8 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelParameterImpl.java:1.7 Wed Jan 4 13:29:11 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelParameterImpl.java Fri May 25 16:14:19 2007 @@ -1,66 +1,55 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*##%*/ + * Copyright (C) 2002, 2003, 2004 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ -/* * -* ObjectModelParameterImpl.java -* -* Created: 14 janv. 2004 -* -* @author Cédric Pineau -* Copyright Code Lutin -* @version $Revision: 1.7 $ -* -* Last update : $Date: 2006/01/04 13:29:11 $ -* by : $Author: bpoussin $ -*/ package org.codelutin.generator.models.object.xml; -import org.codelutin.generator.models.object.ObjectModelElement; import org.codelutin.generator.models.object.ObjectModelParameter; -public class ObjectModelParameterImpl extends ObjectModelElementImpl implements ObjectModelParameter { - - protected String type = null; - - public ObjectModelParameterImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); - } - - public ObjectModelParameterImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement, String name, String type) { - super(objectModelImpl, declaringElement); - this.name = name; - this.type = type; - } - - public void postInit() { - super.postInit(); - } - - public void parsetType(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public String toString(){ - return getType() + " " + getName() + "<<" + getStereotypes() + ">> tagvalue: " + getTagValues(); - } - +/* * + * ObjectModelParameterImpl.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau Copyright Code Lutin + * + * @version $Revision: 1.8 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ by : $Author: chatellier $ + */ +public class ObjectModelParameterImpl extends ObjectModelElementImpl implements + ObjectModelParameter { + + protected String type = null; + + public ObjectModelParameterImpl() { + super(); + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public String toString() { + return getType() + " " + getName() + "<<" + getStereotypes() + + ">> tagvalue: " + getTagValues(); + } } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassImpl.java diff -u lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassImpl.java:1.16 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassImpl.java:1.17 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassImpl.java:1.16 Wed Jan 4 13:29:11 2006 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelClassImpl.java Fri May 25 16:14:19 2007 @@ -1,33 +1,33 @@ /* *##% -* Copyright (C) 2002, 2003, 2004 Code Lutin -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*##%*/ + * Copyright (C) 2002, 2003, 2004 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ /* * -* ObjectModelClassImpl.java -* -* Created: 14 janv. 2004 -* -* @author Cédric Pineau -* Copyright Code Lutin -* @version $Revision: 1.16 $ -* -* Last update : $Date: 2006/01/04 13:29:11 $ -* by : $Author: bpoussin $ -*/ + * ObjectModelClassImpl.java + * + * Created: 14 janv. 2004 + * + * @author Cédric Pineau + * Copyright Code Lutin + * @version $Revision: 1.17 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ + * by : $Author: chatellier $ + */ package org.codelutin.generator.models.object.xml; import java.util.ArrayList; @@ -36,216 +36,229 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; +import java.util.Map; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; -import org.codelutin.generator.models.object.ObjectModelElement; import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; -public class ObjectModelClassImpl - extends ObjectModelClassifierImpl - implements ObjectModelClass { - - protected ArrayList superclasses = null; - protected HashMap superclassesDiscriminators = new HashMap(); - protected ArrayList superclassesRefs = new ArrayList(); - protected ArrayList specialisations = null; - protected HashMap attributes = new HashMap(); - protected ArrayList orderedAttributes = new ArrayList(); - protected boolean abstractz = false; - - public ObjectModelClassImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { - super(objectModelImpl, declaringElement); - } - - public void postInit() { - super.postInit(); - } - - public ObjectModelImplRef parsetSuperclass(ObjectModelImplRef ref) { - if (ref == null) - return new ObjectModelImplSuperClassRef(); - superclassesRefs.add(ref); - return ref; - } - - public ObjectModelAttributeImpl parsetAttribute(ObjectModelAttributeImpl attribute) { - if (attribute == null) - return new ObjectModelAttributeImpl(objectModelImpl, this); - attribute.postInit(); - attributes.put(attribute.getName(), attribute); - orderedAttributes.add(attribute); - return attribute; - } - - public void parsetAbstract(boolean abstractz) { - this.abstractz = abstractz; - } - - public Collection getSuperclasses() { - if (superclasses == null) { - superclasses = new ArrayList(); - Iterator i = superclassesRefs.iterator(); - while (i.hasNext()) { - ObjectModelImplSuperClassRef ref = (ObjectModelImplSuperClassRef) i.next(); - ObjectModelClass superclass = objectModelImpl.getClass(ref.getName()); - superclasses.add(superclass); - superclassesDiscriminators.put(superclass, ref.getDiscriminator()); - } - } - return superclasses; - } - - /** - * Returns the discriminator for the given superclass. - * - * @return the discriminator for the given superclass as a String if it exists, null otherwise. - */ - public String getDiscriminator(ObjectModelClass superclass) { - return (String) superclassesDiscriminators.get(superclass); - } - - /** - * Returns all known direct specialized classes for this class. - * @see ObjectModelClass - * - * @return a Collection containing all known direct specialized ObjectModelClass for this class. - */ - public Collection getSpecialisations() { - if (specialisations == null) { - specialisations = new ArrayList(); - for (Iterator i = objectModelImpl.getClasses().iterator(); i.hasNext();) { - ObjectModelClass candidateClass = (ObjectModelClass) i.next(); - if (candidateClass.getSuperclasses().contains(this)) { - specialisations.add(candidateClass); - } - } - } - return specialisations; - } - - /** - * Returns all known specialized classes for this class for the specified discriminator. - * @see ObjectModelClass - * - * @return a Collection containing all known specialized ObjectModelClass for this class for the specified discriminator. - */ - public Collection getSpecialisations(String discriminator) { - ArrayList discriminatedSpecialisations = new ArrayList(); - for (Iterator i = getSpecialisations().iterator(); i.hasNext();) { - ObjectModelClass candidateClass = (ObjectModelClass) i.next(); - if (discriminator.equals(candidateClass.getDiscriminator(this))) { - discriminatedSpecialisations.add(candidateClass); - } - } - return discriminatedSpecialisations; - } - - public Collection getAttributes() { - return orderedAttributes; - } - - /** - * Returns the attribute corresponding to the given name, or null if the class contains no attribute for this name. - * - * @return the ObjectModelAttribute of the found attribute, or null if the class contains no attribute for this name. - */ - public ObjectModelAttribute getAttribute(String attributeName) { - return (attributeName == null?null:(ObjectModelAttribute) attributes.get(attributeName)); - } - - /** - * Returns whether this class is abstract or not. - * - * @return a boolean indicating whether this class is abstract or not. - */ - public boolean isAbstract() { - return abstractz; - } - - public Collection getAllOtherOperations(boolean distinct){ - Collection result = getAllInterfaceOperations(distinct); - getAllSuperclassOperations(result); - return result; - } - - public Collection getAllSuperclassOperations(boolean distinct){ - Collection result = null; - if(distinct){ - result = new HashSet(); - }else{ - result = new LinkedList(); - } - getAllSuperclassOperations(result); - return result; - } - - protected Collection getAllSuperclassOperations(Collection result){ - for(Iterator i=getSuperclasses().iterator(); i.hasNext();){ - ObjectModelClassImpl clazz = - (ObjectModelClassImpl)i.next(); - result.addAll(clazz.getOperations()); - clazz.getAllSuperclassOperations(result); - clazz.getAllInterfaceOperations(result); - } - return result; - } - - public Collection getAllOtherAttributes(){ - Collection result = new LinkedList(); - getAllOtherAttributes(result); - return result; - } - - protected Collection getAllOtherAttributes(Collection result){ - for(Iterator i=getSuperclasses().iterator(); i.hasNext();){ - ObjectModelClassImpl clazz = - (ObjectModelClassImpl)i.next(); - result.addAll(clazz.getAttributes()); - clazz.getAllOtherAttributes(result); - } - return result; - } - - public String toString(){ - StringBuffer result = new StringBuffer(); - result.append("class " + getQualifiedName() + "<<" + getStereotypes() + ">> tagvalue: " + getTagValues() + " "); - result.append("extends "); - for(Iterator i=getSuperclasses().iterator(); i.hasNext();){ - result.append(((ObjectModelClassifier)i.next()).getName()); - if(i.hasNext()){ - result.append(", "); - } - } - result.append("implements "); - for(Iterator i=getInterfaces().iterator(); i.hasNext();){ - result.append(((ObjectModelClassifier)i.next()).getName()); - if(i.hasNext()){ - result.append(", "); - } - } - return result.toString(); - } - - /** - * Returns whether this classifier is a class or not - * @see ObjectModelClass - * - * @return a boolean indicating whether this classifier is a class or not. - */ - public boolean isClass() { - return true; - } - - /** - * Returns whether this classifier is an interface or not - * @see ObjectModelInterface - * - * @return a boolean indicating whether this classifier is an interface or not. - */ - public boolean isInterface() { - return false; - } +public class ObjectModelClassImpl extends ObjectModelClassifierImpl implements + ObjectModelClass { + protected List superclasses = null; + protected Map superclassesDiscriminators = new HashMap(); + protected List superclassesRefs = new ArrayList(); + protected List specialisations = null; + protected Map attributes = new HashMap(); + protected List orderedAttributes = new ArrayList(); + protected boolean abstractz = false; + + public ObjectModelClassImpl() { + super(); + } + + public void addSuperclass(ObjectModelImplRef ref) { + //if (ref == null) + // return new ObjectModelImplSuperClassRef(); + superclassesRefs.add(ref); + //return ref; + } + + public void addAttribute( + ObjectModelAttributeImpl attribute) { + //if (attribute == null) + // return new ObjectModelAttributeImpl(objectModelImpl, this); + attribute.postInit(); + attribute.setDeclaringElement(this); + attributes.put(attribute.getName(), attribute); + orderedAttributes.add(attribute); + //return attribute; + } + + public void setAbstract(boolean abstractz) { + this.abstractz = abstractz; + } + + public Collection getSuperclasses() { + if (superclasses == null) { + superclasses = new ArrayList(); + Iterator i = superclassesRefs.iterator(); + while (i.hasNext()) { + ObjectModelImplSuperClassRef ref = (ObjectModelImplSuperClassRef) i + .next(); + ObjectModelClass superclass = objectModelImpl.getClass(ref + .getName()); + superclasses.add(superclass); + superclassesDiscriminators.put(superclass, ref + .getDiscriminator()); + } + } + return superclasses; + } + + /** + * Returns the discriminator for the given superclass. + * + * @return the discriminator for the given superclass as a String if it + * exists, null otherwise. + */ + public String getDiscriminator(ObjectModelClass superclass) { + return superclassesDiscriminators.get(superclass); + } + + /** + * Returns all known direct specialized classes for this class. + * + * @see ObjectModelClass + * + * @return a Collection containing all known direct specialized + * ObjectModelClass for this class. + */ + public Collection getSpecialisations() { + if (specialisations == null) { + specialisations = new ArrayList(); + for (Iterator i = objectModelImpl.getClasses().iterator(); i + .hasNext();) { + ObjectModelClass candidateClass = (ObjectModelClass) i.next(); + if (candidateClass.getSuperclasses().contains(this)) { + specialisations.add(candidateClass); + } + } + } + return specialisations; + } + + /** + * Returns all known specialized classes for this class for the specified + * discriminator. + * + * @see ObjectModelClass + * + * @return a Collection containing all known specialized ObjectModelClass + * for this class for the specified discriminator. + */ + public Collection getSpecialisations(String discriminator) { + List discriminatedSpecialisations = new ArrayList(); + for (Iterator i = getSpecialisations().iterator(); i.hasNext();) { + ObjectModelClass candidateClass = i.next(); + if (discriminator.equals(candidateClass.getDiscriminator(this))) { + discriminatedSpecialisations.add(candidateClass); + } + } + return discriminatedSpecialisations; + } + + public Collection getAttributes() { + return orderedAttributes; + } + + /** + * Returns the attribute corresponding to the given name, or null if the + * class contains no attribute for this name. + * + * @return the ObjectModelAttribute of the found attribute, or null if the + * class contains no attribute for this name. + */ + public ObjectModelAttribute getAttribute(String attributeName) { + return (attributeName == null ? null + : (ObjectModelAttribute) attributes.get(attributeName)); + } + + /** + * Returns whether this class is abstract or not. + * + * @return a boolean indicating whether this class is abstract or not. + */ + public boolean isAbstract() { + return abstractz; + } + + public Collection getAllOtherOperations(boolean distinct) { + Collection result = getAllInterfaceOperations(distinct); + getAllSuperclassOperations(result); + return result; + } + + public Collection getAllSuperclassOperations(boolean distinct) { + Collection result = null; + if (distinct) { + result = new HashSet(); + } else { + result = new LinkedList(); + } + getAllSuperclassOperations(result); + return result; + } + + protected Collection getAllSuperclassOperations(Collection result) { + for (Iterator i = getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClassImpl clazz = (ObjectModelClassImpl) i.next(); + result.addAll(clazz.getOperations()); + clazz.getAllSuperclassOperations(result); + clazz.getAllInterfaceOperations(result); + } + return result; + } + + public Collection getAllOtherAttributes() { + Collection result = new LinkedList(); + getAllOtherAttributes(result); + return result; + } + + protected Collection getAllOtherAttributes(Collection result) { + for (Iterator i = getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClassImpl clazz = (ObjectModelClassImpl) i.next(); + result.addAll(clazz.getAttributes()); + clazz.getAllOtherAttributes(result); + } + return result; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + result.append("class " + getQualifiedName() + "<<" + getStereotypes() + + ">> tagvalue: " + getTagValues() + " "); + result.append("extends "); + for (Iterator i = getSuperclasses().iterator(); i.hasNext();) { + result.append(((ObjectModelClassifier) i.next()).getName()); + if (i.hasNext()) { + result.append(", "); + } + } + result.append("implements "); + for (Iterator i = getInterfaces().iterator(); i.hasNext();) { + result.append(((ObjectModelClassifier) i.next()).getName()); + if (i.hasNext()) { + result.append(", "); + } + } + return result.toString(); + } + + /** + * Returns whether this classifier is a class or not + * + * @see ObjectModelClass + * + * @return a boolean indicating whether this classifier is a class or not. + */ + public boolean isClass() { + return true; + } + + /** + * Returns whether this classifier is an interface or not + * + * @see ObjectModelInterface + * + * @return a boolean indicating whether this classifier is an interface or + * not. + */ + public boolean isInterface() { + return false; + } } Index: lutingenerator/src/java/org/codelutin/generator/models/object/xml/DigesterObjectModelRuleSet.java diff -u /dev/null lutingenerator/src/java/org/codelutin/generator/models/object/xml/DigesterObjectModelRuleSet.java:1.1 --- /dev/null Fri May 25 16:14:28 2007 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/DigesterObjectModelRuleSet.java Fri May 25 16:14:19 2007 @@ -0,0 +1,118 @@ +/* *##% + * Copyright (C) 2007 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.generator.models.object.xml; + +import org.apache.commons.digester.Digester; +import org.apache.commons.digester.RuleSetBase; + +/** + * DigesterObjectModelRuleSet + * + * Definit principalement : + * - la classe d'implementation a utiliser pour chaque noeud + * - la methode a appeler apres chaque noeud + * + * Ce jeu de regle ne cree pas l'element racine. + * Il doit etre cree et ajoute a la pile digester avant l'appel a + * Digester.parse(File). + * + * Exemple: + * + * ObjectModel monModel = new ObjectModelImpl() + * Digester d = new Digester(); + * d.push(monModel); + * d.parse(file); + * + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/05/25 16:14:19 $ + * By : $Author: chatellier $ + */ +public class DigesterObjectModelRuleSet extends RuleSetBase { + + protected String prefix = null; + + public DigesterObjectModelRuleSet() { + this(""); + } + + public DigesterObjectModelRuleSet(String prefix) { + super(); + this.prefix = prefix; + this.namespaceURI = "http://www.codelutin.org/lutingenerator/objectModel"; + } + + /* (non-Javadoc) + * @see org.apache.commons.digester.RuleSetBase#addRuleInstances(org.apache.commons.digester.Digester) + */ + @Override + public void addRuleInstances(Digester d) { + + //d.addFactoryCreate("objectModel", DigesterObjectModelFactory.class); + // root element must be present on stask + d.addSetProperties("objectModel"); + + d.addObjectCreate("objectModel/class", ObjectModelClassImpl.class); + d.addSetProperties("objectModel/class"); + d.addSetNext("objectModel/class", "addClass"); + + d.addObjectCreate("objectModel/interface", ObjectModelInterfaceImpl.class); + d.addSetProperties("objectModel/interface"); + d.addSetNext("objectModel/interface", "addInterface"); + + d.addObjectCreate("objectModel/associationClass", ObjectModelAssociationClassImpl.class); + d.addSetProperties("objectModel/associationClass"); + d.addSetNext("objectModel/associationClass", "addAssociationClass"); + + d.addObjectCreate("*/stereotype", ObjectModelImplRef.class); + d.addSetProperties("*/stereotype"); + d.addSetNext("*/stereotype", "addStereotype"); + + d.addObjectCreate("*/class/attribute", ObjectModelAttributeImpl.class); + d.addSetProperties("*/class/attribute"); + d.addSetNext("*/class/attribute", "addAttribute"); + + d.addObjectCreate("*/class/interface", ObjectModelImplRef.class); + d.addSetProperties("*/class/interface"); + d.addSetNext("*/class/interface", "addInterface"); + + d.addObjectCreate("*/superclass", ObjectModelImplSuperClassRef.class); + d.addSetProperties("*/superclass"); + d.addSetNext("*/superclass", "addSuperclass"); + + d.addObjectCreate("*/operation", ObjectModelOperationImpl.class); + d.addSetProperties("*/operation"); + d.addSetNext("*/operation", "addOperation"); + + d.addObjectCreate("*/operation/returnParameter", ObjectModelParameterImpl.class); + d.addSetProperties("*/operation/returnParameter"); + d.addSetNext("*/operation/returnParameter", "setReturnParameter"); + + d.addObjectCreate("*/operation/parameter", ObjectModelParameterImpl.class); + d.addSetProperties("*/operation/parameter"); + d.addSetNext("*/operation/parameter", "addParameter"); + + d.addObjectCreate("*/operation/exceptionParameter", ObjectModelParameterImpl.class); + d.addSetProperties("*/operation/exceptionParameter"); + d.addSetNext("*/operation/exceptionParameter", "addExceptionParameter"); + } + +}