1 /* 2 ProgrammingLanguageContext.java 3 Creation date : 28/08/2010 4 Copyright © Benjamin Croizet (graffity2199@yahoo.fr) 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 or GNU Lesser General Public License as published by the 9 Free Software Foundation; either version 3 of the License, 10 or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received copies of the GNU General Public License 18 and GNU Lesser General Public License along with this program; 19 if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 http://www.fsf.org/licensing/licenses/gpl.html 22 http://www.gnu.org/licenses/lgpl.html 23 */ 24 25 package net.sourceforge.plantumldependency.cli.main.option.programminglanguage.context; 26 27 import java.io.Serializable; 28 import java.util.Collection; 29 30 import net.sourceforge.plantumldependency.cli.generic.GenericDependency; 31 import net.sourceforge.plantumldependency.cli.main.option.display.type.argument.DisplayType; 32 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.PlantUMLClassesDiagram; 33 import net.sourceforge.plantumldependency.common.clone.DeepCloneable; 34 35 /** 36 * The interface which describes a context shared by all dependencies which are parsed. It is mainly 37 * used to save all treated dependencies but also global states. 38 * 39 * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>) 40 * @since 1.0.0 41 * @version 1.4.0 42 */ 43 public interface ProgrammingLanguageContext extends Comparable < ProgrammingLanguageContext >, Serializable, 44 DeepCloneable < ProgrammingLanguageContext > { 45 46 /** 47 * Adds the dependency in the parsed and seen dependencies in the context. If the dependency is 48 * already in the context, it is replaced. 49 * 50 * @param dependency 51 * the {@link GenericDependency} instance to add, mustn't be <code>null</code>. 52 * @since 1.0.0 53 */ 54 void addParsedAndSeenDependencies(GenericDependency dependency); 55 56 /** 57 * Adds the dependency in the parsed and seen dependencies in the context and marks it as a 58 * potential "java.lang" dependency. This should be used when the dependency package can be 59 * known between the current package and the "java.lang" package because dependencies are read 60 * in a sequential way. If the dependency is already in the context, it is replaced. 61 * 62 * @param dependency 63 * the {@link GenericDependency} instance to add, mustn't be <code>null</code>. 64 * @see #getPotentialJavaLangSeenDependencies() 65 * @see #removePotentialJavaLangSeenDependency(String) 66 * @see #removeAllPotentialJavaLangSeenDependencyAndChangePackageToJavaLang() 67 * @since 1.2.0 68 */ 69 void addPotentialJavaLangSeenDependencies(GenericDependency dependency); 70 71 /** 72 * Adds the dependency in the seen dependencies in the context. 73 * 74 * @param dependency 75 * the {@link GenericDependency} instance to add, mustn't be <code>null</code>. 76 * @since 1.0.0 77 */ 78 void addSeenDependencies(GenericDependency dependency); 79 80 /** 81 * Gets all dependencies which have been seen (as import for instance) and parsed within the 82 * context. 83 * 84 * @return the {@link Collection} of all {@link GenericDependency} which have been seen (as 85 * import for instance) and parsed and associated with this context. 86 * @since 1.0.0 87 */ 88 Collection < GenericDependency > getParsedAndSeenDependencies(); 89 90 /** 91 * Gets all dependencies which have been parsed within the context. 92 * 93 * @return the {@link Collection} of all {@link GenericDependency} which have been parsed and 94 * associated with this context. 95 * @since 1.0.0 96 */ 97 Collection < GenericDependency > getParsedDependencies(); 98 99 /** 100 * Gets the dependency in the parsed context following its name. 101 * 102 * @param fullName 103 * the dependency full name to get, mustn't be <code>null</code>. 104 * @return the {@link GenericDependency} instance following its full name if found in the parsed 105 * context, <code>null</code> otherwise. 106 * @since 1.2.0 107 */ 108 GenericDependency getParsedDependency(String fullName); 109 110 /** 111 * Gets the dependency in the parsed and seen context following its name. 112 * 113 * @param fullName 114 * the dependency full name to get, mustn't be <code>null</code>. 115 * @return the {@link GenericDependency} instance following its full name if found in the parsed 116 * and seen context, <code>null</code> otherwise. 117 * @since 1.0.0 118 */ 119 GenericDependency getParsedOrSeenDependency(String fullName); 120 121 /** 122 * Gets the {@link PlantUMLClassesDiagram} instance representing the context, following display 123 * options (type, name and package name). 124 * 125 * @return the plantUML diagram instance representing the context, following display types 126 * options. 127 * @since 1.1.1 128 */ 129 PlantUMLClassesDiagram getPlantUMLClassesDiagram(); 130 131 /** 132 * Gets all dependencies which have been marked as potential "java.lang" dependencies within the 133 * context. 134 * 135 * @return the {@link Collection} of all {@link GenericDependency} which have been marked as 136 * potential "java.lang" dependencies within the context. 137 * @see #addPotentialJavaLangSeenDependencies() 138 * @see #removePotentialJavaLangSeenDependency(String) 139 * @see #removeAllPotentialJavaLangSeenDependencyAndChangePackageToJavaLang() 140 * @since 1.2.0 141 */ 142 Collection < GenericDependency > getPotentialJavaLangSeenDependencies(); 143 144 /** 145 * Tells if the following {@link DisplayType} is managed or not by this context. 146 * 147 * @param displayType 148 * the {@link DisplayType}, mustn't be <code>null</code>. 149 * @return <code>true</code> if the {@link DisplayType} is managed by the context, 150 * <code>false</code> otherwise. 151 * @since 1.0.0 152 */ 153 boolean hasToDisplay(DisplayType displayType); 154 155 /** 156 * Removes all the marked as potential "java.lang" dependencies from the context and change 157 * their package to "java.lang". This should be used at the end of the parsing process because 158 * it means that marked dependencies haven't been parsed. 159 * 160 * @since 1.2.0 161 */ 162 void removeAllPotentialJavaLangSeenDependencyAndChangePackageToJavaLang(); 163 164 /** 165 * Remove the marked as potential "java.lang" dependency from the context. This should be used 166 * each time a new dependency is parsed. If the dependency full name isn't marked as potential 167 * "java.lang" dependency, this method doesn't do anything. 168 * 169 * @param fullName 170 * the dependency full name, usually the package and the dependency name. 171 * <p> 172 * For instance, in java it can be :<br> 173 * <i>java.lang.String</i><br> 174 * <i>java.io.Serializable</i><br> 175 * <i>sun.font.Decoration</i> 176 * </p> 177 * @since 1.2.0 178 */ 179 void removePotentialJavaLangSeenDependency(String fullName); 180 }