Eugene-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
January 2009
- 3 participants
- 3 discussions
[Lutingenerator-commits] r411 - lutingenerator/trunk maven-generator-plugin/trunk
by tchemit@users.labs.libre-entreprise.org 29 Jan '09
by tchemit@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: tchemit
Date: 2009-01-29 14:22:09 +0000 (Thu, 29 Jan 2009)
New Revision: 411
Modified:
lutingenerator/trunk/changelog.txt
lutingenerator/trunk/pom.xml
maven-generator-plugin/trunk/changelog.txt
maven-generator-plugin/trunk/pom.xml
Log:
use lutinproject 3.4 (suppress javadoc plugin invocation)
Modified: lutingenerator/trunk/changelog.txt
===================================================================
--- lutingenerator/trunk/changelog.txt 2009-01-29 10:58:54 UTC (rev 410)
+++ lutingenerator/trunk/changelog.txt 2009-01-29 14:22:09 UTC (rev 411)
@@ -1,4 +1,6 @@
0.64 ?? 200812??
+ * 20090129 [thimel] renmae Util class to GeneratorUtil
+ * 20090129 [chemit] use lutinproject 3.4 (suppress javadoc plugin invocation)
0.63 chemit 20081215
* 20081215 [chemit] fix up to date regression on generation
Modified: lutingenerator/trunk/pom.xml
===================================================================
--- lutingenerator/trunk/pom.xml 2009-01-29 10:58:54 UTC (rev 410)
+++ lutingenerator/trunk/pom.xml 2009-01-29 14:22:09 UTC (rev 411)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>lutinproject</artifactId>
- <version>3.2</version>
+ <version>3.4-SNAPSHOT</version>
</parent>
<artifactId>lutingenerator</artifactId>
@@ -93,18 +93,17 @@
<labs.project>lutingenerator</labs.project>
<!-- lutinutil version -->
- <lutinutil.version>1.0</lutinutil.version>
+ <!--lutinutil.version>1.0</lutinutil.version-->
+
+ <!-- todo pour la montee de version voir la doc -->
+ <lutingenerator.version>${project.version}</lutingenerator.version>
</properties>
<build>
- <plugins>
+
+ <defaultGoal>install</defaultGoal>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
-
- </plugins>
</build>
<!-- ************************************************************* -->
Modified: maven-generator-plugin/trunk/changelog.txt
===================================================================
--- maven-generator-plugin/trunk/changelog.txt 2009-01-29 10:58:54 UTC (rev 410)
+++ maven-generator-plugin/trunk/changelog.txt 2009-01-29 14:22:09 UTC (rev 411)
@@ -1,5 +1,6 @@
0.64 ?? 200812??
-
+ * 20090129 [chemit] - use lutinproject 3.4 (suppress javadoc plugin invocation)
+
0.63 chemit 20081215
* 20081215 [chemit] follow lutingenerator release
Modified: maven-generator-plugin/trunk/pom.xml
===================================================================
--- maven-generator-plugin/trunk/pom.xml 2009-01-29 10:58:54 UTC (rev 410)
+++ maven-generator-plugin/trunk/pom.xml 2009-01-29 14:22:09 UTC (rev 411)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>lutinpluginproject</artifactId>
- <version>3.2</version>
+ <version>3.4-SNAPSHOT</version>
</parent>
<artifactId>maven-generator-plugin</artifactId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>org.codelutin</groupId>
<artifactId>lutingenerator</artifactId>
- <version>0.64-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>compile</scope>
</dependency>
@@ -60,12 +60,15 @@
<!-- nom du projet sur le labs -->
<labs.project>lutingenerator</labs.project>
+ <!-- todo pour la montee de version voir la doc -->
+ <lutingenerator.version>${project.version}</lutingenerator.version>
+
</properties>
<build>
- <plugins>
-
- </plugins>
+
+ <defaultGoal>install</defaultGoal>
+
</build>
1
0
[Lutingenerator-commits] r410 - in lutingenerator/trunk/src/main/java/org/codelutin/generator: . models/object models/object/xml
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 10:58:54 +0000 (Thu, 29 Jan 2009)
New Revision: 410
Added:
lutingenerator/trunk/src/main/java/org/codelutin/generator/GeneratorUtil.java
Removed:
lutingenerator/trunk/src/main/java/org/codelutin/generator/Util.java
Modified:
lutingenerator/trunk/src/main/java/org/codelutin/generator/AbstractObjectModelGenerator.java
lutingenerator/trunk/src/main/java/org/codelutin/generator/UIModelGenerator.java
lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/ObjectModelElement.java
lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java
lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java
lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java
Log:
Rename Util to GeneratorUtil
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/AbstractObjectModelGenerator.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/AbstractObjectModelGenerator.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/AbstractObjectModelGenerator.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -47,7 +47,7 @@
if(name == null){
throw new GeneratorException("L'element "+ e +" doit avoir un nom valide" );
}else{
- return Util.capitalize(name);
+ return GeneratorUtil.capitalize(name);
}
}
Added: lutingenerator/trunk/src/main/java/org/codelutin/generator/GeneratorUtil.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/GeneratorUtil.java (rev 0)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/GeneratorUtil.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -0,0 +1,383 @@
+/*
+ * *##% Lutin Generator
+ * Copyright (C) 2004 - 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+/* *
+ * Util.java Created: 25 ao?t 2003
+ *
+ *@author Benjamin Poussin <poussin(a)codelutin.com>
+ *
+ * Copyright Code Lutin
+ *@version $Revision: 317 $ Mise a jour: $Date: 2008-09-25 10:45:22 +0200 (jeu 25 sep 2008) $ par :
+ * $Author: thimel $
+ */
+
+package org.codelutin.generator;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+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.ObjectModelOperation;
+import org.codelutin.generator.models.object.ObjectModelParameter;
+
+/**
+ * TODO Description of the Class
+ *
+ *@author poussin
+ *@created 26 ao?t 2003
+ */
+public class GeneratorUtil {
+
+ /**
+ * return parent package of given package (return given package if it is a root package)
+ * eg : org.codelutin.generator.models -> org.codelutin.generator
+ * eg : org -> org
+ * warning : org.codelutin.generator. -> org.codelutin.generator
+ */
+ public static String getParentPackageName(String packageName) {
+ String parentPackageName = packageName;
+ int index = packageName.lastIndexOf('.');
+ if (index != -1) {
+ parentPackageName = packageName.substring(0,index);
+ }
+ return parentPackageName;
+ }
+
+ /**
+ * return class name fr given fully qualified name (return given name if it is not fully qualified)
+ * eg : org.codelutin.generator.models.ObjectClass -> ObjectClass
+ * eg : ObjectClass-> ObjectClass
+ */
+ public static String getClassNameFromQualifiedName(String qualifiedName) {
+ String className = qualifiedName;
+ int index = qualifiedName.lastIndexOf('.');
+ if (index != -1) {
+ className = qualifiedName.substring(index+1);
+ }
+ return className;
+ }
+
+ /**
+ *
+ */
+ public static String getFilenameFromQualifiedName(String qualifiedName) {
+ return qualifiedName.replace('.', File.separatorChar);
+ }
+
+
+ /**
+ * return all classifiers belonging to the given package recursively. The Collection may be empty.
+ * @see ObjectModelCassifier
+ *
+ * @return a Collection containing all classifiers belonging to the given package recursively.
+ */
+ public static Collection<ObjectModelClassifier> getClassifiers(ObjectModel model, String packageName) {
+ List<ObjectModelClassifier> classifiers = new ArrayList<ObjectModelClassifier>();
+ for (Iterator i = model.getClassifiers().iterator(); i.hasNext();) {
+ ObjectModelClassifier classifier = (ObjectModelClassifier) i.next();
+ if (classifier.getPackageName().startsWith(packageName)) {
+ classifiers.add(classifier);
+ }
+ }
+ return classifiers;
+ }
+
+ /**
+ * @see {@link #getAttributeType(ObjectModelParameter, boolean)}
+ */
+ public static String getAttributeType(ObjectModelParameter attribute) {
+ return getAttributeType(attribute, false);
+ }
+
+ /**
+ * Retourne le type de l'attribut, c-a-d une List ou une collection
+ * ou le type defini si la cardinalité n'est pas multiple
+ *
+ * @param attribute
+ * @return
+ */
+ public static String getAttributeType(ObjectModelParameter attribute, boolean useGenerics) {
+ String result;
+ if (attribute instanceof ObjectModelAttribute
+ && isNMultiplicity((ObjectModelAttribute)attribute)) {
+ if (((ObjectModelAttribute)attribute).isOrdered()) {
+ result = "java.util.List";
+ } else {
+ result = "java.util.Collection";
+ }
+ if (useGenerics) {
+ result += "<" + attribute.getType() + ">";
+ }
+ } else {
+ result = attribute.getType();
+ }
+ return result;
+ }
+
+ /**
+ * Indicates if the specified attribute has a primitive type (byte, boolean, ...)
+ * @return true if the atribute has a primitive type
+ */
+ public static boolean isPrimitiveAttributeType(ObjectModelAttribute attribute) {
+ if (isNMultiplicity(attribute))
+ return false;
+ String type = attribute.getType();
+ return ("byte".equals(type) || "short".equals(type) ||
+ "int".equals(type) || "long".equals(type) ||
+ "float".equals(type) || "double".equals(type) ||
+ "char".equals(type) || "boolean".equals(type));
+ }
+
+ /**
+ * return an init value for the specified attribute
+ * @return a String with the corresponding attribute init value
+ */
+ public static String getInitValue(ObjectModelAttribute attribute) {
+ if (isNMultiplicity(attribute)) return "new java.util.ArrayList()";
+ return getInitValue(attribute.getType());
+ }
+
+ public static String getInitValue(String type){
+ if ("byte".equals(type)) return "0";
+ if ("short".equals(type)) return "0";
+ if ("int".equals(type)) return "0";
+ if ("long".equals(type)) return "0";
+ if ("float".equals(type)) return "0";
+ if ("double".equals(type)) return "0";
+ if ("char".equals(type)) return "\u0000";
+ if ("boolean".equals(type)) return "false";
+ if ("java.lang.String".equals(type)) return null;
+ if ("java.lang.Date".equals(type)) return null;
+ return null;
+ }
+
+ public static String getCastValue(String type, String o){
+ if ("byte".equals(type)) return "((Byte)"+o+").byteValue()";
+ if ("short".equals(type)) return "((Short)"+o+").shortValue()";
+ if ("int".equals(type)) return "((Integer)"+o+").intValue()";
+ if ("long".equals(type)) return "((Long)"+o+").longValue()";
+ if ("float".equals(type)) return "((Float)"+o+").floatValue()";
+ if ("double".equals(type)) return "((Double)"+o+").doubleValue()";
+ if ("char".equals(type)) return "((Character)"+o+").charValue()";
+ if ("boolean".equals(type)) return "((Boolean)"+o+").booleanValue()";
+ if ("void".equals(type)) return "";
+ return "(" + type + ")" + o;
+ }
+
+ public static String getHashCodeExpression(String type, String o){
+ String result = o;
+ if ("byte".equals(type)) result = "new Byte("+o+")";
+ if ("short".equals(type)) result = "new Short("+o+")";
+ if ("int".equals(type)) result = "new Integer("+o+")";
+ if ("long".equals(type)) result = "new Long("+o+")";
+ if ("float".equals(type)) result = "new Float("+o+")";
+ if ("double".equals(type)) result = "new Double("+o+")";
+ if ("char".equals(type)) result = "new Character("+o+")";
+ if ("boolean".equals(type)) result = "new Boolean("+o+")";
+ return result +".hashCode()";
+ }
+
+ /**
+ * Retourne la chaine de caractere dont on a besoin pour la declaration
+ * des parametres d'une methode.
+ */
+ public static String getMethodParameterDeclaration(Collection params){
+ StringBuffer result = new StringBuffer();
+ for (Iterator j = params.iterator(); j.hasNext();){
+ ObjectModelParameter parameter = (ObjectModelParameter) j.next();
+ result.append(getAttributeType(parameter)+" "+parameter.getName());
+ if (j.hasNext()) {
+ result.append(", ");
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Retourne la chaine de caractere qui represente chaque nom de parametre
+ * separer par des ','.
+ */
+ public static String getMethodParameterListName(Collection params){
+ StringBuffer result = new StringBuffer();
+ for (Iterator j = params.iterator(); j.hasNext();){
+ ObjectModelParameter parameter = (ObjectModelParameter) j.next();
+ result.append(parameter.getName());
+ if (j.hasNext()) {
+ result.append(", ");
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ *@return vrai si la cardinalite de l'attribut est superieur a 1, c-a-d
+ * si MaxMultiplicity == -1 ou > 1
+ */
+ public static boolean isNMultiplicity(ObjectModelAttribute attribute){
+ return isNMultiplicity(attribute.getMaxMultiplicity());
+ }
+
+ public static boolean isNMultiplicity(int multiplicity){
+ return (multiplicity == -1) || (multiplicity>1);
+ }
+
+ /**
+ * @return true is the multiplicity of the given attribute is exactly 1
+ */
+ public static boolean isOneMultiplicity(ObjectModelAttribute attribute) {
+ if (attribute == null)
+ return false;
+ return ((attribute.getMinMultiplicity() == 1) && (attribute.getMaxMultiplicity() == 1));
+ }
+
+
+ /**
+ *
+ */
+ public static String toUpperCaseFirstLetter(String word) {
+ return capitalize(word);
+ }
+
+ public static String capitalize(String word){
+ return StringUtils.capitalize(word);
+ }
+
+ /**
+ *
+ */
+ public static String toLowerCaseFirstLetter(String word) {
+ return word.substring(0, 1).toLowerCase() + word.substring(1);
+ }
+
+ /**
+ * @return true if the given attribute is a composition (composant of the reverse attribute)
+ */
+ public static boolean isComposition(ObjectModelAttribute attribute) {
+ if (attribute == null)
+ return false;
+ if (attribute.getReverseAttribute() == null)
+ return false;
+ return attribute.getReverseAttribute().isComposite();
+ }
+
+
+
+
+ public static String getParsingExpression(String type, String attributeStringName){
+ if ("byte".equals(type)) return "Byte.parseByte("+attributeStringName+")";
+ if ("short".equals(type)) return "Short.parseShort("+attributeStringName+")";
+ if ("int".equals(type)) return "Integer.parseInt("+attributeStringName+")";
+ if ("long".equals(type)) return "Long.parseLong("+attributeStringName+")";
+ if ("float".equals(type)) return "Float.parseFloat("+attributeStringName+")";
+ if ("double".equals(type)) return "Double.parseDouble("+attributeStringName+")";
+ if ("char".equals(type)) return attributeStringName+".charAt(0)";
+ if ("boolean".equals(type)) return "Boolean.parseBoolean("+attributeStringName+")";
+ if ("java.lang.String".equals(type)) return attributeStringName;
+ if ("java.util.Date".equals(type)) return "dateParser.parse("+attributeStringName+")";
+ return null;
+ }
+
+ public static String getFormatingExpression(String type, String attributeStringName){
+ if ("byte".equals(type)) return "Byte.toString("+attributeStringName+")";
+ if ("short".equals(type)) return "Short.toString("+attributeStringName+")";
+ if ("int".equals(type)) return "Integer.toString("+attributeStringName+")";
+ if ("long".equals(type)) return "Long.toString("+attributeStringName+")";
+ if ("float".equals(type)) return "Float.toString("+attributeStringName+")";
+ if ("double".equals(type)) return "Double.toString("+attributeStringName+")";
+ if ("char".equals(type)) return "Character.toString("+attributeStringName+")";
+ if ("boolean".equals(type)) return "Boolean.parseBoolean("+attributeStringName+")";
+ if ("java.lang.String".equals(type)) return attributeStringName;
+ if ("java.util.Date".equals(type)) return "dateParser.format("+attributeStringName+")";
+ return null;
+ }
+
+
+
+ /**
+ * Retourne la chaine de caractere dont on a besoin pour la declaration
+ * des parametres d'une methode.
+ */
+ public static String getOperationParametersListDeclaration(ObjectModelOperation operation){
+ StringBuffer result = new StringBuffer();
+
+ Collection params = operation.getParameters();
+ for (Iterator j = params.iterator(); j.hasNext();){
+ ObjectModelParameter parameter = (ObjectModelParameter) j.next();
+ result.append(getAttributeType(parameter)+" "+parameter.getName());
+ if (j.hasNext()) {
+ result.append(", ");
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Retourne la chaine de caractere qui represente chaque nom de parametre
+ * separer par des ','.
+ */
+ public static String getOperationParametersListName(ObjectModelOperation operation) {
+ Collection params = operation.getParameters();
+ StringBuffer result = new StringBuffer();
+ for (Iterator j = params.iterator(); j.hasNext();){
+ ObjectModelParameter parameter = (ObjectModelParameter) j.next();
+ result.append(parameter.getName());
+ if (j.hasNext()) {
+ result.append(", ");
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Renvoie sous forme de String la liste des déclarations des attributes d'une classe donnée
+ */
+ public static String getClassAttributesListDeclaration(ObjectModelClass clazz) {
+ StringBuffer result = new StringBuffer();
+
+ Collection params = clazz.getAttributes();
+ for (Iterator j = params.iterator(); j.hasNext();){
+ ObjectModelAttribute attr = (ObjectModelAttribute) j.next();
+ result.append(getAttributeType(attr, true)+" "+attr.getName());
+ if (j.hasNext()) {
+ result.append(", ");
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Renvoie si l'attribut passé en paramètre est premier lexicographiquement
+ * par rapport à son attribut inverse (si celui ci existe).
+ * @param attr L'attribut dont on veut savoir s'il est le premier
+ * @return true, si l'attribut est premier (lexico ou pas de reverse attribute), false dans les autres cas
+ */
+ public static boolean isFirstAttribute(ObjectModelAttribute attr) {
+ if (attr.getReverseAttribute() == null)
+ return true;
+ return (attr.getName().compareTo(attr.getReverseAttribute().getName()) < 0);
+ }
+
+} // Util
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/UIModelGenerator.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/UIModelGenerator.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/UIModelGenerator.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -175,7 +175,7 @@
if(name == null){
throw new GeneratorException("L'objet "+ o.getType() +" doit avoir un nom valide" );
}else{
- return Util.capitalize(name);
+ return GeneratorUtil.capitalize(name);
}
}
@@ -184,7 +184,7 @@
if(name == null){
throw new GeneratorException("La propriete "+ p +" doit avoir un nom valide");
}else{
- return Util.capitalize(name);
+ return GeneratorUtil.capitalize(name);
}
}
}
Deleted: lutingenerator/trunk/src/main/java/org/codelutin/generator/Util.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/Util.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/Util.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -1,383 +0,0 @@
-/*
- * *##% Lutin Generator
- * Copyright (C) 2004 - 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-/* *
- * Util.java Created: 25 ao?t 2003
- *
- *@author Benjamin Poussin <poussin(a)codelutin.com>
- *
- * Copyright Code Lutin
- *@version $Revision$ Mise a jour: $Date$ par :
- * $Author$
- */
-
-package org.codelutin.generator;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-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.ObjectModelOperation;
-import org.codelutin.generator.models.object.ObjectModelParameter;
-
-/**
- * TODO Description of the Class
- *
- *@author poussin
- *@created 26 ao?t 2003
- */
-public class Util {
-
- /**
- * return parent package of given package (return given package if it is a root package)
- * eg : org.codelutin.generator.models -> org.codelutin.generator
- * eg : org -> org
- * warning : org.codelutin.generator. -> org.codelutin.generator
- */
- public static String getParentPackageName(String packageName) {
- String parentPackageName = packageName;
- int index = packageName.lastIndexOf('.');
- if (index != -1) {
- parentPackageName = packageName.substring(0,index);
- }
- return parentPackageName;
- }
-
- /**
- * return class name fr given fully qualified name (return given name if it is not fully qualified)
- * eg : org.codelutin.generator.models.ObjectClass -> ObjectClass
- * eg : ObjectClass-> ObjectClass
- */
- public static String getClassNameFromQualifiedName(String qualifiedName) {
- String className = qualifiedName;
- int index = qualifiedName.lastIndexOf('.');
- if (index != -1) {
- className = qualifiedName.substring(index+1);
- }
- return className;
- }
-
- /**
- *
- */
- public static String getFilenameFromQualifiedName(String qualifiedName) {
- return qualifiedName.replace('.', File.separatorChar);
- }
-
-
- /**
- * return all classifiers belonging to the given package recursively. The Collection may be empty.
- * @see ObjectModelCassifier
- *
- * @return a Collection containing all classifiers belonging to the given package recursively.
- */
- public static Collection<ObjectModelClassifier> getClassifiers(ObjectModel model, String packageName) {
- List<ObjectModelClassifier> classifiers = new ArrayList<ObjectModelClassifier>();
- for (Iterator i = model.getClassifiers().iterator(); i.hasNext();) {
- ObjectModelClassifier classifier = (ObjectModelClassifier) i.next();
- if (classifier.getPackageName().startsWith(packageName)) {
- classifiers.add(classifier);
- }
- }
- return classifiers;
- }
-
- /**
- * @see {@link #getAttributeType(ObjectModelParameter, boolean)}
- */
- public static String getAttributeType(ObjectModelParameter attribute) {
- return getAttributeType(attribute, false);
- }
-
- /**
- * Retourne le type de l'attribut, c-a-d une List ou une collection
- * ou le type defini si la cardinalité n'est pas multiple
- *
- * @param attribute
- * @return
- */
- public static String getAttributeType(ObjectModelParameter attribute, boolean useGenerics) {
- String result;
- if (attribute instanceof ObjectModelAttribute
- && isNMultiplicity((ObjectModelAttribute)attribute)) {
- if (((ObjectModelAttribute)attribute).isOrdered()) {
- result = "java.util.List";
- } else {
- result = "java.util.Collection";
- }
- if (useGenerics) {
- result += "<" + attribute.getType() + ">";
- }
- } else {
- result = attribute.getType();
- }
- return result;
- }
-
- /**
- * Indicates if the specified attribute has a primitive type (byte, boolean, ...)
- * @return true if the atribute has a primitive type
- */
- public static boolean isPrimitiveAttributeType(ObjectModelAttribute attribute) {
- if (isNMultiplicity(attribute))
- return false;
- String type = attribute.getType();
- return ("byte".equals(type) || "short".equals(type) ||
- "int".equals(type) || "long".equals(type) ||
- "float".equals(type) || "double".equals(type) ||
- "char".equals(type) || "boolean".equals(type));
- }
-
- /**
- * return an init value for the specified attribute
- * @return a String with the corresponding attribute init value
- */
- public static String getInitValue(ObjectModelAttribute attribute) {
- if (isNMultiplicity(attribute)) return "new java.util.ArrayList()";
- return getInitValue(attribute.getType());
- }
-
- public static String getInitValue(String type){
- if ("byte".equals(type)) return "0";
- if ("short".equals(type)) return "0";
- if ("int".equals(type)) return "0";
- if ("long".equals(type)) return "0";
- if ("float".equals(type)) return "0";
- if ("double".equals(type)) return "0";
- if ("char".equals(type)) return "\u0000";
- if ("boolean".equals(type)) return "false";
- if ("java.lang.String".equals(type)) return null;
- if ("java.lang.Date".equals(type)) return null;
- return null;
- }
-
- public static String getCastValue(String type, String o){
- if ("byte".equals(type)) return "((Byte)"+o+").byteValue()";
- if ("short".equals(type)) return "((Short)"+o+").shortValue()";
- if ("int".equals(type)) return "((Integer)"+o+").intValue()";
- if ("long".equals(type)) return "((Long)"+o+").longValue()";
- if ("float".equals(type)) return "((Float)"+o+").floatValue()";
- if ("double".equals(type)) return "((Double)"+o+").doubleValue()";
- if ("char".equals(type)) return "((Character)"+o+").charValue()";
- if ("boolean".equals(type)) return "((Boolean)"+o+").booleanValue()";
- if ("void".equals(type)) return "";
- return "(" + type + ")" + o;
- }
-
- public static String getHashCodeExpression(String type, String o){
- String result = o;
- if ("byte".equals(type)) result = "new Byte("+o+")";
- if ("short".equals(type)) result = "new Short("+o+")";
- if ("int".equals(type)) result = "new Integer("+o+")";
- if ("long".equals(type)) result = "new Long("+o+")";
- if ("float".equals(type)) result = "new Float("+o+")";
- if ("double".equals(type)) result = "new Double("+o+")";
- if ("char".equals(type)) result = "new Character("+o+")";
- if ("boolean".equals(type)) result = "new Boolean("+o+")";
- return result +".hashCode()";
- }
-
- /**
- * Retourne la chaine de caractere dont on a besoin pour la declaration
- * des parametres d'une methode.
- */
- public static String getMethodParameterDeclaration(Collection params){
- StringBuffer result = new StringBuffer();
- for (Iterator j = params.iterator(); j.hasNext();){
- ObjectModelParameter parameter = (ObjectModelParameter) j.next();
- result.append(getAttributeType(parameter)+" "+parameter.getName());
- if (j.hasNext()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /**
- * Retourne la chaine de caractere qui represente chaque nom de parametre
- * separer par des ','.
- */
- public static String getMethodParameterListName(Collection params){
- StringBuffer result = new StringBuffer();
- for (Iterator j = params.iterator(); j.hasNext();){
- ObjectModelParameter parameter = (ObjectModelParameter) j.next();
- result.append(parameter.getName());
- if (j.hasNext()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /**
- *@return vrai si la cardinalite de l'attribut est superieur a 1, c-a-d
- * si MaxMultiplicity == -1 ou > 1
- */
- public static boolean isNMultiplicity(ObjectModelAttribute attribute){
- return isNMultiplicity(attribute.getMaxMultiplicity());
- }
-
- public static boolean isNMultiplicity(int multiplicity){
- return (multiplicity == -1) || (multiplicity>1);
- }
-
- /**
- * @return true is the multiplicity of the given attribute is exactly 1
- */
- public static boolean isOneMultiplicity(ObjectModelAttribute attribute) {
- if (attribute == null)
- return false;
- return ((attribute.getMinMultiplicity() == 1) && (attribute.getMaxMultiplicity() == 1));
- }
-
-
- /**
- *
- */
- public static String toUpperCaseFirstLetter(String word) {
- return capitalize(word);
- }
-
- public static String capitalize(String word){
- return StringUtils.capitalize(word);
- }
-
- /**
- *
- */
- public static String toLowerCaseFirstLetter(String word) {
- return word.substring(0, 1).toLowerCase() + word.substring(1);
- }
-
- /**
- * @return true if the given attribute is a composition (composant of the reverse attribute)
- */
- public static boolean isComposition(ObjectModelAttribute attribute) {
- if (attribute == null)
- return false;
- if (attribute.getReverseAttribute() == null)
- return false;
- return attribute.getReverseAttribute().isComposite();
- }
-
-
-
-
- public static String getParsingExpression(String type, String attributeStringName){
- if ("byte".equals(type)) return "Byte.parseByte("+attributeStringName+")";
- if ("short".equals(type)) return "Short.parseShort("+attributeStringName+")";
- if ("int".equals(type)) return "Integer.parseInt("+attributeStringName+")";
- if ("long".equals(type)) return "Long.parseLong("+attributeStringName+")";
- if ("float".equals(type)) return "Float.parseFloat("+attributeStringName+")";
- if ("double".equals(type)) return "Double.parseDouble("+attributeStringName+")";
- if ("char".equals(type)) return attributeStringName+".charAt(0)";
- if ("boolean".equals(type)) return "Boolean.parseBoolean("+attributeStringName+")";
- if ("java.lang.String".equals(type)) return attributeStringName;
- if ("java.util.Date".equals(type)) return "dateParser.parse("+attributeStringName+")";
- return null;
- }
-
- public static String getFormatingExpression(String type, String attributeStringName){
- if ("byte".equals(type)) return "Byte.toString("+attributeStringName+")";
- if ("short".equals(type)) return "Short.toString("+attributeStringName+")";
- if ("int".equals(type)) return "Integer.toString("+attributeStringName+")";
- if ("long".equals(type)) return "Long.toString("+attributeStringName+")";
- if ("float".equals(type)) return "Float.toString("+attributeStringName+")";
- if ("double".equals(type)) return "Double.toString("+attributeStringName+")";
- if ("char".equals(type)) return "Character.toString("+attributeStringName+")";
- if ("boolean".equals(type)) return "Boolean.parseBoolean("+attributeStringName+")";
- if ("java.lang.String".equals(type)) return attributeStringName;
- if ("java.util.Date".equals(type)) return "dateParser.format("+attributeStringName+")";
- return null;
- }
-
-
-
- /**
- * Retourne la chaine de caractere dont on a besoin pour la declaration
- * des parametres d'une methode.
- */
- public static String getOperationParametersListDeclaration(ObjectModelOperation operation){
- StringBuffer result = new StringBuffer();
-
- Collection params = operation.getParameters();
- for (Iterator j = params.iterator(); j.hasNext();){
- ObjectModelParameter parameter = (ObjectModelParameter) j.next();
- result.append(getAttributeType(parameter)+" "+parameter.getName());
- if (j.hasNext()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /**
- * Retourne la chaine de caractere qui represente chaque nom de parametre
- * separer par des ','.
- */
- public static String getOperationParametersListName(ObjectModelOperation operation) {
- Collection params = operation.getParameters();
- StringBuffer result = new StringBuffer();
- for (Iterator j = params.iterator(); j.hasNext();){
- ObjectModelParameter parameter = (ObjectModelParameter) j.next();
- result.append(parameter.getName());
- if (j.hasNext()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /**
- * Renvoie sous forme de String la liste des déclarations des attributes d'une classe donnée
- */
- public static String getClassAttributesListDeclaration(ObjectModelClass clazz) {
- StringBuffer result = new StringBuffer();
-
- Collection params = clazz.getAttributes();
- for (Iterator j = params.iterator(); j.hasNext();){
- ObjectModelAttribute attr = (ObjectModelAttribute) j.next();
- result.append(getAttributeType(attr, true)+" "+attr.getName());
- if (j.hasNext()) {
- result.append(", ");
- }
- }
- return result.toString();
- }
-
- /**
- * Renvoie si l'attribut passé en paramètre est premier lexicographiquement
- * par rapport à son attribut inverse (si celui ci existe).
- * @param attr L'attribut dont on veut savoir s'il est le premier
- * @return true, si l'attribut est premier (lexico ou pas de reverse attribute), false dans les autres cas
- */
- public static boolean isFirstAttribute(ObjectModelAttribute attr) {
- if (attr.getReverseAttribute() == null)
- return true;
- return (attr.getName().compareTo(attr.getReverseAttribute().getName()) < 0);
- }
-
-} // Util
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/ObjectModelElement.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/ObjectModelElement.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/ObjectModelElement.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -101,6 +101,13 @@
public abstract String getTagValue(String tagValue);
/**
+ * Returns whether this element has a tagValue corresponding to the given name, or not.
+ *
+ * @return a boolean indicating whether this element has a tagValue corresponding to the given name, or not.
+ */
+ public abstract boolean hasTagValue(String tagValue);
+
+ /**
* Returns all comments lied to this particular model element
*
* @return a List containing all comments for this element as Strings.
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModeImplAssociationClassParticipant.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -19,7 +19,7 @@
import java.util.Iterator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
/**
*
@@ -57,7 +57,7 @@
for (Iterator i = associationClass.getParticipantsRefs().iterator(); i.hasNext();) {
ObjectModeImplAssociationClassParticipant participant = (ObjectModeImplAssociationClassParticipant)i.next();
if (participant != this) {
- attributeName = Util.toLowerCaseFirstLetter(Util.getClassNameFromQualifiedName(participant.getName()));
+ attributeName = GeneratorUtil.toLowerCaseFirstLetter(GeneratorUtil.getClassNameFromQualifiedName(participant.getName()));
break;
}
}
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelAttributeImpl.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -29,7 +29,7 @@
package org.codelutin.generator.models.object.xml;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
import org.codelutin.generator.models.object.ObjectModelClassifier;
@@ -56,7 +56,7 @@
public void postInit() {
if (name == null)
- name = Util.toLowerCaseFirstLetter(Util
+ name = GeneratorUtil.toLowerCaseFirstLetter(GeneratorUtil
.getClassNameFromQualifiedName(type));
super.postInit();
}
@@ -180,7 +180,7 @@
public String getReverseAttributeName() {
if ((reverseAttributeName == null)
|| ("".equals(reverseAttributeName))) {
- reverseAttributeName = Util
+ reverseAttributeName = GeneratorUtil
.toLowerCaseFirstLetter(getDeclaringElement().getName());
}
return reverseAttributeName;
@@ -188,7 +188,7 @@
public String getName() {
if ((name == null || "".equals(name)) && getClassifier() != null) {
- name = Util.toLowerCaseFirstLetter(getClassifier().getName());
+ name = GeneratorUtil.toLowerCaseFirstLetter(getClassifier().getName());
}
return name;
}
Modified: lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java
===================================================================
--- lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java 2009-01-06 13:36:31 UTC (rev 409)
+++ lutingenerator/trunk/src/main/java/org/codelutin/generator/models/object/xml/ObjectModelElementImpl.java 2009-01-29 10:58:54 UTC (rev 410)
@@ -193,6 +193,15 @@
}
/**
+ * Returns whether this element has a tagValue corresponding to the given name, or not.
+ *
+ * @return a boolean indicating whether this element has a tagValue corresponding to the given name, or not.
+ */
+ public boolean hasTagValue(String tagValue) {
+ return tagValues.containsKey(tagValue);
+ }
+
+ /**
* Returns all comments lied to this particular model element
*
* @return a List containing all comments for this element as Strings.
1
0
[Lutingenerator-commits] r409 - lutingenerator/trunk
by chatellier@users.labs.libre-entreprise.org 06 Jan '09
by chatellier@users.labs.libre-entreprise.org 06 Jan '09
06 Jan '09
Author: chatellier
Date: 2009-01-06 13:36:31 +0000 (Tue, 06 Jan 2009)
New Revision: 409
Modified:
lutingenerator/trunk/pom.xml
Log:
Update commons-digester to 2.0
Modified: lutingenerator/trunk/pom.xml
===================================================================
--- lutingenerator/trunk/pom.xml 2008-12-15 02:37:52 UTC (rev 408)
+++ lutingenerator/trunk/pom.xml 2009-01-06 13:36:31 UTC (rev 409)
@@ -28,9 +28,17 @@
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
- <version>1.8</version>
+ <version>2.0</version>
<scope>compile</scope>
</dependency>
+
+ <!-- JAXP parser impl for digester -->
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>commons-lang</groupId>
@@ -53,12 +61,14 @@
<scope>compile</scope>
</dependency>
+ <!-- dom4j dep -->
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
- <scope>compile</scope>
+ <scope>runtime</scope>
</dependency>
+
</dependencies>
<!-- ************************************************************* -->
1
0