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.20 lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java:1.21 --- lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java:1.20 Fri Jul 16 12:22:08 2004 +++ lutingenerator/src/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java Thu Feb 23 14:03:05 2006 @@ -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. -*##%*/ - -/* * -* ObjectModelAttributeImpl.java -* -* Created: 14 janv. 2004 -* -* @author C�dric Pineau -* Copyright Code Lutin -* @version $Revision: 1.20 $ -* -* Last update : $Date: 2004/07/16 12:22:08 $ -* by : $Author: pineau $ -*/ +/* + * *##% 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. ##% + */ + +/******************************************************************************* + * ObjectModelAttributeImpl.java + * + * Created: 14 janv. 2004 + * + * @author C�dric Pineau Copyright Code Lutin + * + * @version $Revision: 1.21 $ + * + * Last update : $Date: 2006/02/23 14:03:05 $ by : $Author: bpoussin $ + */ + package org.codelutin.generator.models.object.xml; import org.codelutin.generator.Util; @@ -36,37 +36,61 @@ import org.codelutin.generator.models.object.ObjectModelClassifier; import org.codelutin.generator.models.object.ObjectModelElement; -public class ObjectModelAttributeImpl extends ObjectModelParameterImpl implements ObjectModelAttribute { +public class ObjectModelAttributeImpl extends ObjectModelParameterImpl + implements ObjectModelAttribute { protected String reverseAttributeName = null; - protected String associationType=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; - public ObjectModelAttributeImpl(ObjectModelImpl objectModelImpl, ObjectModelElement declaringElement) { + protected boolean isNavigable = true; + + protected boolean isOrdered = false; + + public ObjectModelAttributeImpl(ObjectModelImpl objectModelImpl, + ObjectModelElement declaringElement) { super(objectModelImpl, declaringElement); } public void postInit() { if (name == null) - name = Util.toLowerCaseFirstLetter(Util.getClassNameFromQualifiedName(type)); + name = Util.toLowerCaseFirstLetter(Util + .getClassNameFromQualifiedName(type)); super.postInit(); } public void parsetAssociationType(String associationType) { this.associationType = associationType; } + public void parsetType(String type) { this.type = type; } + public void parsetReverseAttribute(String reverseAttributeName) { this.reverseAttributeName = reverseAttributeName; } + + public void parsetReverseMaxMultiplicity(int reverseMaxMultiplicity) { + this.reverseMaxMultiplicity = reverseMaxMultiplicity; + } + public void parsetVisibility(String visibility) { this.visibility = visibility; } @@ -87,24 +111,34 @@ this.maxMultiplicity = maxMultiplicity; } + public void parsetNavigable(boolean isNavigable) { + this.isNavigable = isNavigable; + } + + public void parsetOrdering(String ordering) { + this.isOrdered = "ordered".equals(ordering); + } + public String getType() { return type; } /** - * Returns whether this attribute is an aggregate or not. - * - * @return a boolean indicating whether this attribute is an aggregate or not. - */ + * Returns whether this attribute is an aggregate or not. + * + * @return a boolean indicating whether this attribute is an aggregate or + * not. + */ public boolean isAggregate() { return "aggregate".equals(associationType); } /** - * Returns whether this attribute is an composite or not. - * - * @return a boolean indicating whether this attribute is an composite or not. - */ + * Returns whether this attribute is an composite or not. + * + * @return a boolean indicating whether this attribute is an composite or + * not. + */ public boolean isComposite() { return "composite".equals(associationType); } @@ -126,77 +160,127 @@ } /** - * Returns whether this attribute reference a model classifier or not. - * - * @return a boolean indicating whether this attribute reference a model classifier or not. - */ + * Returns whether this attribute reference a model classifier or not. + * + * @return a boolean indicating whether this attribute reference a model + * classifier or not. + */ public boolean referenceClassifier() { return (getClassifier() != null); } /** - * Returns the classifier referenced by this attribute or null if it does not reference a model classifier. - * - * @return the ObjectModelClassfifier referenced by this attribute or null if it does not reference a model classifier. - */ + * Returns the classifier referenced by this attribute or null if it does + * not reference a model classifier. + * + * @return the ObjectModelClassfifier referenced by this attribute or null + * if it does not reference a model classifier. + */ public ObjectModelClassifier getClassifier() { return objectModelImpl.getClassifier(type); } /** - * Returns the attribute used to reference this class at the other end of the association or null if this is not an association, or if it is not bi-directionnal. - * @ see #getClassifier() - * - * @return the ObjectModelAttribute used to reference this class at the other end of the association or null if this is not an association, or if it is not bi-directionnal. - */ + * Returns the attribute used to reference this class at the other end of + * the association or null if this is not an association, or if it is not + * bi-directionnal. @ see #getClassifier() + * + * @return the ObjectModelAttribute used to reference this class at the + * other end of the association or null if this is not an + * association, or if it is not bi-directionnal. + */ public ObjectModelAttribute getReverseAttribute() { ObjectModelAttribute reverseAttribute = null; ObjectModelClassifier classifier = getClassifier(); if (classifier instanceof ObjectModelClass) { - if ((reverseAttributeName == null) || ("".equals(reverseAttributeName))) { - reverseAttributeName = Util.toLowerCaseFirstLetter(getDeclaringElement().getName()); - } -// System.out.println("Searching reverse attribute "+reverseAttributeName+" in "+classifier.getName()); - reverseAttribute = ((ObjectModelClass) classifier).getAttribute(reverseAttributeName); + // System.out.println("Searching reverse attribute + // "+reverseAttributeName+" in "+classifier.getName()); + reverseAttribute = ((ObjectModelClass) classifier) + .getAttribute(getReverseAttributeName()); } return reverseAttribute; } + public String getReverseAttributeName() { + if ((reverseAttributeName == null) + || ("".equals(reverseAttributeName))) { + reverseAttributeName = Util + .toLowerCaseFirstLetter(getDeclaringElement().getName()); + } + return reverseAttributeName; + } + + public String getName() { + if ((name == null || "".equals(name)) && getClassifier() != null) { + name = Util.toLowerCaseFirstLetter(getClassifier().getName()); + } + return name; + } + + /* + * (non-Javadoc) + * + * @see org.codelutin.generator.models.object.ObjectModelAttribute#getReverseMaxMultiplicity() + */ + public int getReverseMaxMultiplicity() { + return reverseMaxMultiplicity; + } + /** - * Returns the association class associated with this association, or null if there is none. - * - * @return a ObjectModelClass corresponding to the association class associated with this association, or null if there is none. - */ + * Returns the association class associated with this association, or null + * if there is none. + * + * @return a ObjectModelClass corresponding to the association class + * associated with this association, or null if there is none. + */ public ObjectModelClass getAssociationClass() { return objectModelImpl.getClass(associationClassName); } /** - * Returns whether this association has an associated association class, ot not. - * - * @return a boolean indicating whether this association has an associated association class, ot not. - */ + * Returns whether this association has an associated association class, ot + * not. + * + * @return a boolean indicating whether this association has an associated + * association class, ot not. + */ public boolean hasAssociationClass() { return (getAssociationClass() != null); } /** * Returns whether this attribute is static or not. - * + * * @return a boolean indicating whether this attribute is static or not. */ - public boolean isStatic() { - return isStatic; - } - - /** - * Returns whether this attribute is final or not. - * - * @return a boolean indicating whether this attribute is final or not. - */ - public boolean isFinal() { - return isFinal; - } + public boolean isStatic() { + return isStatic; + } + /** + * Returns whether this attribute is final or not. + * + * @return a boolean indicating whether this attribute is final or not. + */ + public boolean isFinal() { + return isFinal; + } + /* + * (non-Javadoc) + * + * @see org.codelutin.generator.models.object.ObjectModelAttribute#isNavigable() + */ + public boolean isNavigable() { + return isNavigable; + } + + /* + * (non-Javadoc) + * + * @see org.codelutin.generator.models.object.ObjectModelAttribute#isOrdered() + */ + public boolean isOrdered() { + return isOrdered; + } }