Author: tchemit Date: 2011-01-26 13:45:00 +0100 (Wed, 26 Jan 2011) New Revision: 1034 Url: http://nuiton.org/repositories/revision/eugene/1034 Log: Evolution #1248: Remove deprecated extensions in 2.3 Removed: trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManager.java trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManagerExtension.java trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManager.java trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManagerExtension.java trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManager.java trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManagerExtension.java trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManager.java trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManagerExtension.java Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManager.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManager.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManager.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,90 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -import org.nuiton.eugene.models.object.ObjectModelElement; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * To manage annotations for any {@link ObjectModelElement} of a classifier. - * <p/> - * Created: 17 déc. 2009 - * - * @author tchemit <chemit@codelutin.com> - * @version $Revision$ - * @since 2.0.0 - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.AnnotationsManager} - */ -@Deprecated -public class AnnotationsManager { - - private static final String[] EMPTY_STRING_ARRAY = new String[]{}; - - protected Map<ObjectModelElement, List<String>> annotations; - - /** - * Add the {@code annotation} for the given {@code element} of - * the classifier. - * - * @param element the element where to register the annotation - * @param annotation the annotation to register - */ - public void addAnnotation(ObjectModelElement element, String annotation) { - Map<ObjectModelElement, List<String>> map = getAnnotations(); - List<String> list = map.get(element); - if (list == null) { - list = new ArrayList<String>(); - map.put(element, list); - } - list.add(annotation); - } - - /** - * Obtain the array of annotations registred for a given element of - * the classifier. - * - * @param element the element where to search for annotations - * @return the annotations for the element (empty arry if none found - */ - public String[] getAnnotations(ObjectModelElement element) { - Map<ObjectModelElement, List<String>> map = getAnnotations(); - List<String> list = map.get(element); - return list == null ? EMPTY_STRING_ARRAY : - list.toArray(new String[list.size()]); - } - - protected Map<ObjectModelElement, List<String>> getAnnotations() { - if (annotations == null) { - annotations = new HashMap<ObjectModelElement, List<String>>(); - } - return annotations; - } - -} Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManagerExtension.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManagerExtension.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/AnnotationsManagerExtension.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,111 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelElement; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created: 17 déc. 2009 - * - * @author tchemit <chemit@codelutin.com> - * @version $Revision$ - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.AnnotationsManagerExtension} - */ -@Deprecated -public class AnnotationsManagerExtension { - - private static final Log log = LogFactory.getLog(AnnotationsManagerExtension.class); - - /** - * Extension static used to identify AnnotationsManagerExtension in - * ObjectModel. - */ - public static final String OBJECTMODEL_EXTENSION = "annotations"; - - /** - * Map of AnotationsManager with key equals to the classifier qualified - * name associated to the AnotationsManager - */ - protected Map<String, AnnotationsManager> managers; - - private static final String[] EMPTY_STRING_ARRAY = new String[]{}; - - /** - * Get the registred annotations for the given {@code element} in the - * given {@code classifier}. - * - * <b>Note:</b> The method always returns a {@code none null} value, but - * an empty array when no annotation when no annotation found for the - * element. - * - * @param classifier the classifier where is the element - * @param element the element on which searching annotations - * @return the array of annotation registred or an empty array if none. - */ - public String[] getAnnotations(ObjectModelClassifier classifier, - ObjectModelElement element) { - AnnotationsManager annotationsManager = getManager(classifier); - String[] result = null; - if (annotationsManager != null) { - result = annotationsManager.getAnnotations(element); - } - return result == null ? EMPTY_STRING_ARRAY : result; - } - - /** - * Get the AnotationsManager associated to the classifier. If not exist, - * it will be created. - * - * @param classifier reference for the AnotationsManager - * @return the annotationsManager associated to the classifier (never null) - */ - public AnnotationsManager getManager(ObjectModelClassifier classifier) { - Map<String, AnnotationsManager> managers = getManagers(); - String fqn = classifier.getQualifiedName(); - AnnotationsManager manager = managers.get(fqn); - if (manager == null) { - manager = new AnnotationsManager(); - managers.put(fqn, manager); - if (log.isDebugEnabled()) { - log.debug("Add new annotationsManager for : " + fqn); - } - } - return manager; - } - - protected Map<String, AnnotationsManager> getManagers() { - if (managers == null) { - managers = new HashMap<String, AnnotationsManager>(); - } - return managers; - } -} Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManager.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManager.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManager.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,83 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ -package org.nuiton.eugene.java; - -import org.nuiton.eugene.models.object.ObjectModelOperation; - -import java.util.HashMap; -import java.util.Map; - -/** - * To manage some verbatim code to inject in operations. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0.2 - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.CodesManager} - */ -@Deprecated -public class CodesManager { - - private static final String EMPTY_STRING = ""; - - /** store of codes associated to operations */ - protected Map<ObjectModelOperation, StringBuilder> codes; - - /** - * Add the {@code annotation} for the given {@code element} of - * the classifier. - * - * @param operation the operation on which add the code - * @param code the code to add - */ - public void addCode(ObjectModelOperation operation, String code) { - Map<ObjectModelOperation, StringBuilder> map = getCodes(); - - StringBuilder buffer = map.get(operation); - if (buffer == null) { - buffer = new StringBuilder(); - map.put(operation, buffer); - } - buffer.append('\n').append(code); - } - - /** - * Obtain the codes registred for a given operation of the classifier. - * - * @param operation the operation where to search for code - * @return the code for the operation (empty if none found) - */ - public String getCode(ObjectModelOperation operation) { - Map<ObjectModelOperation, StringBuilder> map = getCodes(); - StringBuilder buffer = map.get(operation); - return buffer == null ? EMPTY_STRING : buffer.toString(); - } - - protected Map<ObjectModelOperation, StringBuilder> getCodes() { - if (codes == null) { - codes = new HashMap<ObjectModelOperation, StringBuilder>(); - } - return codes; - } -} Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManagerExtension.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManagerExtension.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/CodesManagerExtension.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,115 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ -package org.nuiton.eugene.java; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelOperation; - -import java.util.HashMap; -import java.util.Map; - -/** - * Object model extensions to manage verbatim code to attzach to operations. - * - * @author tchemit <chemit@codelutin.com> - * @see CodesManager - * @since 2.0.2 - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.CodesManagerExtension} - */ -@Deprecated -public class CodesManagerExtension { - - private static final Log log = LogFactory.getLog(CodesManagerExtension.class); - - /** Extension static used to identify CodesManagerExtension in ObjectModel */ - public static final String OBJECTMODEL_EXTENSION = "codes"; - - /** - * Map of CodesManager with key equals to the classifier qualified name - * associated to the CodesManager - */ - protected Map<String, CodesManager> managers; - - /** - * Add the {@code code} for the given {@code operation} of the - * given {@code classifier}. - * - * @param classifier the classifier container of the operation - * @param operation the operation on which to add the code - * @param code the code to add for the operation - */ - public void addcode(ObjectModelClassifier classifier, - ObjectModelOperation operation, - String code) { - CodesManager codesManager = getManager(classifier); - codesManager.addCode(operation, code); - } - - /** - * Get body code for a operation of the given classifier. - * <p/> - * The CodesManager must be defined in the model. - * - * @param classifier reference for the codes - * @param operation the operation to seek - * @return the body code of the method - */ - public String getCode(ObjectModelClassifier classifier, - ObjectModelOperation operation) { - CodesManager manager = getManager(classifier); - return manager.getCode(operation); - } - - /** - * Get the CodesManager associated to the classifier. - * <p/> - * <b>Note:</b> If not exist, it will be created. - * - * @param classifier reference for the ImportsManager - * @return the codesManager associated to the classifier (never null) - */ - protected CodesManager getManager(ObjectModelClassifier classifier) { - Map<String, CodesManager> managers = getManagers(); - String fqn = classifier.getQualifiedName(); - CodesManager manager = managers.get(fqn); - if (manager == null) { - manager = new CodesManager(); - managers.put(fqn, manager); - if (log.isDebugEnabled()) { - log.debug("Add new codesManager for : " + fqn); - } - } - return manager; - } - - protected Map<String, CodesManager> getManagers() { - if (managers == null) { - managers = new HashMap<String, CodesManager>(); - } - return managers; - } -} Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManager.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManager.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManager.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,72 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -import org.nuiton.eugene.GeneratorUtil; - -import java.util.Map; -import java.util.TreeMap; - -/** - * Manager of constant names. - * - * @author tchemit <chemit@codelutin.com> - * @since ? - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.ConstantsManager} - */ -@Deprecated -public class ConstantsManager { - /** - * cache of constant name (values) for property name (keys) - */ - protected Map<String, String> nameToConstant; - - /** - * Obtain a constant nmae from a property name and store it in cache - * the first time it had to build it. - * - * @param propertyName the propertyName to convert - * @return the equivalent constant name - */ - public String getConstantName(String propertyName) { - Map<String, String> map = getNameToConstant(); - if (map.containsKey(propertyName)) { - return map.get(propertyName); - } - // convert propertyName to constant name - String constantName = - GeneratorUtil.convertVariableNameToConstantName(propertyName); - map.put(propertyName,constantName); - return constantName; - } - - protected Map<String, String> getNameToConstant() { - if (nameToConstant == null) { - nameToConstant = new TreeMap<String, String>(); - } - return nameToConstant; - } -} \ No newline at end of file Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManagerExtension.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManagerExtension.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ConstantsManagerExtension.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,57 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -/** - * @author tchemit <chemit@codelutin.com> - * @since ? - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.ConstantsManagerExtension} - */ -@Deprecated -public class ConstantsManagerExtension { - - /** - * Extension static used to identify {@code ConstantsManagerExtension} in - * ObjectModel - */ - public static final String OBJECTMODEL_EXTENSION = "constants"; - - /** - * the unique manager to use - */ - protected ConstantsManager manager = new ConstantsManager(); - - /** - * Obtain a constant nmae from a property name and store it in cache - * the first time it had to build it. - * - * @param propertyName the propertyName to convert - * @return the equivalent constant name - */ - public String getConstantName(String propertyName) { - return manager.getConstantName(propertyName); - } -} \ No newline at end of file Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManager.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManager.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManager.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,188 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Class used in generators that allows to manage easily imports. A first-pass - * allow to register imports, and in a second-pass, returns the type to use in - * generated code. - * - * @author thimel, chemit - * @version $Revision$ - - * @since 2.0.0 - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.ImportsManager} - */ -@Deprecated -public class ImportsManager { - - private static Set<String> primitiveTypes; - - static { - primitiveTypes = new HashSet<String>(); - - primitiveTypes.add("byte"); - primitiveTypes.add("Byte"); - primitiveTypes.add("short"); - primitiveTypes.add("Short"); - primitiveTypes.add("int"); - primitiveTypes.add("Integer"); - primitiveTypes.add("long"); - primitiveTypes.add("Long"); - primitiveTypes.add("float"); - primitiveTypes.add("Float"); - primitiveTypes.add("double"); - primitiveTypes.add("Double"); - - primitiveTypes.add("char"); - primitiveTypes.add("Char"); - primitiveTypes.add("String"); - - primitiveTypes.add("boolean"); - primitiveTypes.add("Boolean"); - - primitiveTypes.add("void"); - - } - private Map<String, String> imports = new HashMap<String, String>(); - private State state = State.FILLING; - - /** - * From the given class, add it to the imports list. - * @param clazz the class to import - * @return true if import add was successful - * @see ImportsManager#addImport(String) - */ - public boolean addImport(Class<?> clazz) { - return addImport(clazz.getName()); - } - - /** - * From the given fqn (fully qualified name), add it to the imports list. - * If there is a conflict adding this import, will return false. - * If reading of the imports has started, this method will return false, - * unless type does not need to be imported. - * @param fqn the fully qualified name to import - * @return true if import add was successful - */ - public boolean addImport(String fqn) { - // if no package don't include it - if (fqn.indexOf(".") == -1) { - return true; - } - - // Exclude java.lang classes - if (fqn == null || fqn.trim().isEmpty() || - (fqn.startsWith("java.lang.") && fqn.lastIndexOf(".") == 9)) { - return true; - } - // Exclude primitive types - if (primitiveTypes.contains(fqn)) { - return true; - } - // Reject generics - if (fqn.indexOf("<") != -1 || fqn.indexOf(">") != -1) { - return false; - } - String name = fqn.substring(fqn.lastIndexOf(".") + 1); - String inPlaceFqn = imports.get(name); - if (inPlaceFqn == null) { - // Someone has started to read imports, impossible to add some more - if (state == State.READING) { - return false; - } else { - imports.put(name, fqn); - return true; - } - } - // if fqn is not the same, return false. Otherwise, no need to override. - return inPlaceFqn.equals(fqn); - } - - /** - * Accorging to the already added types, returns the type to write in file. - * If there is a conflict, returns the fully qualified name, otherwise - * returns the simple name - * @param fqn the fully qualified name to add - * @return the fqn or simple name according to in-place imports - */ - public String getType(String fqn) { - boolean importResult = addImport(fqn); - if (!importResult) { - // There is a conflict, do not use simple name - return fqn; - } else { - // No conflict, use simple name - int packageEndIndex = fqn.lastIndexOf("."); - if (packageEndIndex == -1) { - return fqn; - } else { - return fqn.substring(packageEndIndex + 1); - } - } - } - - /** - * List the imports. This method will remove the useless imports according - * to the given packageName (no need to import a class in the same package) - * @param packageName the current package name (to avoid useless imports) - * @return the imports alphabeticaly sorted - */ - public List<String> getImports(String packageName) { - state = State.READING; - List<String> result = new ArrayList<String>(); - for (String fqn : imports.values()) { - if (!(fqn.lastIndexOf(".") == packageName.length() && - fqn.startsWith(packageName + "."))) { - result.add(fqn); - } - } - Collections.sort(result); - return result; - } - - /** - * Method to reset imports list. If imports has been listed, it becomes back - * possible to add imports. - */ - public void clearImports() { - imports.clear(); - state = State.FILLING; - } - - private enum State { - - FILLING, READING - } -} Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManagerExtension.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManagerExtension.java 2011-01-26 12:44:37 UTC (rev 1033) +++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ImportsManagerExtension.java 2011-01-26 12:45:00 UTC (rev 1034) @@ -1,101 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2004 - 2010 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>. - * #L% - */ - -package org.nuiton.eugene.java; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.object.ObjectModelClassifier; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * ImportsManagerExtension - * - * Created: 2 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Extension for ObjectModel to manage imports for all classifiers in the model. - * - * @deprecated since 2.3, use now the class {@link org.nuiton.eugene.java.extension.ImportsManagerExtension} - * */ -@Deprecated -public class ImportsManagerExtension { - - private static final Log log = LogFactory.getLog(ImportsManagerExtension.class); - - /** - * Extension static used to identify ImportsManagerExtension in ObjectModel - */ - public static final String OBJECTMODEL_EXTENSION = "imports"; - - /** - * Map of ImportsManager with key equals to the classifier qualified name associated to - * the ImportsManager - */ - protected Map<String, ImportsManager> managers; - - /** - * Get the ImportsManager associated to the classifier. If not exist, it will be created. - * - * @param classifier reference for the ImportsManager - * @return the importsManager associated to the classifier (never null) - */ - public ImportsManager getManager(ObjectModelClassifier classifier) { - Map<String, ImportsManager> managers = getManagers(); - String fqn = classifier.getQualifiedName(); - ImportsManager manager = managers.get(fqn); - if (manager == null) { - manager = new ImportsManager(); - managers.put(fqn, manager); - if (log.isDebugEnabled()) { - log.debug("Add new importsManager for : " + fqn); - } - } - return manager; - } - - /** - * Get imports for a classifier. The ImportsManager must be defined in the model. - * - * @param classifier reference for the imports - * @return a List of String which contains all imports for the classifier - */ - public List<String> getImports(ObjectModelClassifier classifier) { - ImportsManager manager = getManager(classifier); - return manager.getImports(classifier.getPackageName()); - } - - protected Map<String, ImportsManager> getManagers() { - if (managers == null) { - managers = new HashMap<String, ImportsManager>(); - } - return managers; - } -}