Converted all CRLF to LF.
[indepmod/experimental.git] / IndependentModeler / src / cz / cvut / promod / services / pluginLoaderService / utils / PluginLoadErrors.java
blob4bf35ab59add9b8fffbfc5da87bb9ff97a984562
1 package cz.cvut.promod.services.pluginLoaderService.utils;
3 import cz.cvut.promod.services.ModelerSession;
5 import java.util.List;
7 /**
8 * ProMod, master thesis project
9 * User: Petr Zverina, petr.zverina@gmail.com
10 * Date: 13:59:06, 12.12.2009
13 /**
14 * PluginLoadErrors class make possible to collect error that occur during plugin loading and instantiating
15 * and publish them later.
17 public class PluginLoadErrors {
19 public static final String MISSING_XSD_ERROR =
20 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.missing.xsd");
21 public static final String NO_ERROR =
22 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.noError");
23 public static final String XML_PARSING_ERROR =
24 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.xmlParsing");
25 public static final String CLASS_NAME_ERROR =
26 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.className");
27 public static final String FIND_CLASS_ERROR =
28 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.findClass");
29 public static final String CLASS_HIERARCHY_ERROR =
30 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.classHierarchy");
31 public static final String INSTANTIATION_ERROR =
32 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.instantiation");
33 public static final String NULLARY_NOTATION_NAME_ERROR =
34 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryNotationName");
35 public static final String EMPTY_NOTATION_NAME =
36 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyNotationName");
37 public static final String NO_MODEL_FACTORY_ERROR =
38 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.noModelFactory");
39 public static final String INVALID_MODEL_FACTORY_ERROR =
40 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.invalidModelFactory");
41 public static final String NULLARY_ABBREVIATION_ERROR =
42 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryAbbreviation");
43 public static final String EMPTY_ABREVIATION_ERROR =
44 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyAbbreviation");
45 public static final String IO_CONTROLLER_ERROR =
46 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.ioController");
47 public static final String NULLARY_FILE_EXTENSION_ERROR =
48 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryFileExtension");
49 public static final String EMPTY_FILE_EXTENSION_ERROR =
50 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyFileExtension");
51 public static final String NOTATION_IDENTIFIER_DUPLICITY =
52 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.notationIdentifierDuplicity");
53 public static final String NULLARY_PLUGIN_IDENTIFIER =
54 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryPluginIdentifier");
55 public static final String LIKE_MODELER_PLUGIN_IDENTIFIER_ERROR =
56 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.likeModelerpluginIdentifier");
57 public static final String EMPTY_PLUGIN_IDENTIFIER_ERROR =
58 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyPluginIdentifier");
59 public static final String NO_RELATED_NOTATION_IDENTIFIER =
60 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.noRelatedNotationIdentifier");
61 public static final String NULLARY_RELATED_NOTATION_IDENTIFIER_ERROR =
62 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryRelatedNotationIdentifier");
63 public static final String EMPTY_RELATED_NOTATION_IDENTIFIER_ERROR =
64 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyRelatedNotationIdentifier");
65 public static final String MODULE_IDENTIFIER_DUPLICITY_ERROR =
66 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.moduleIdentifierDuplicity");
67 public static final String EXTENSION_IDENIFIER_DUPLICITY_ERROR =
68 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.extensionIdentifierDuplicity");
69 public static final String PROJECT_FILE_LIKE_EXTENSION =
70 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.projectFileLikeNotation");
71 public static final String DUPLICITY_EXTENSION =
72 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.notationExtensionDuplicity");
73 public static final String TOO_LONG_IDENTIFIER =
74 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.too.long.identifier");
75 public static final String NULLARY_NAME_ERROR =
76 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.nullaryPluginName");
77 public static final String EMPTY_NAME_ERROR =
78 ModelerSession.getCommonResourceBundle().getString("pluginLoaderService.error.emptyPluginName");
80 private final String alias; // alias as is in the properties file where all plugin are
82 private String fullClassName = null;
84 public enum ERRORS {
85 /** initial value, no error has occurred */
86 noError,
88 /** not possible to parse plugin definition file, file doesn't fulfil the xsd schema is one of possible reasons */
89 missingXSD,
91 /** not possible to parse plugin definition file, file doesn't fulfil the xsd schema is one of possible reasons */
92 xmlParsing,
94 /** invalid class name, null or empty */
95 className,
97 /** ClassLoader couldn't find the class */
98 findClass,
100 /** class does NOT implement necessary interface (Notation, Module, ...) */
101 classHierarchy,
103 /** and error during class instantiation has occurred */
104 instantiation,
106 /** notation returns nullary notation name */
107 nullaryNotationName,
109 /** notation returns an empty string as it's notation name */
110 emptyNotationName,
112 /** notation doesn't provide ModelFactory definition */
113 noModelFactory,
115 /** notation doesn't provide valid ModelFactory definition */
116 invalidModelFactory,
118 /** notation returns nullary abbreviation */
119 nullaryAbbreviation,
121 /** notation returns an empty String as it's abbreviation */
122 emptyAbbreviation,
124 /** notation doesn't provide IOController definition */
125 ioController,
127 /** notation's ioController provides nullary file extension */
128 nullaryFileExtension,
130 /** notation's ioController provides an empty string as it's file extension */
131 emptyFileExtension,
133 /** notation has the same file extension like the ProMod project file */
134 projectFileLikeExtension,
136 /** notation has the same file extension like the ProMod project file */
137 notationExtensionDuplicity,
139 /** notation has the same identifier as another notation that has been already loaded */
140 notationIdentifierDuplicity,
142 /** nullary plugin name */
143 nullaryName,
145 /** an empty string for plugin name */
146 emptyName,
148 /** plugin returns nullary identifier */
149 nullaryPluginIdentifier,
151 /** plugin returns identifier that is same like modeler identifier */
152 likeModelerpluginIdentifier,
154 /** plugin returns an empty string as it's identifier */
155 emptyPluginIdentifier,
157 /** plugin returns an too long identifier */
158 tooLongPluginIdentifier,
160 /** module provides no existing notation identifier */
161 noRelatedNotationIdentifier,
163 /** module provides nullary related notation identifier */
164 nullaryRelatedNotationIdentifier,
166 /** module provides an empty string as related notation identifier */
167 emptyRelatedNotationIdentifier,
169 /** more than one module for the same notation have the same identifier */
170 moduleIdentifierDuplicity,
172 /** extension has the same identifier as another extension that has been already loaded */
173 extensionIdentifierDuplicity,
176 private ERRORS error = ERRORS.noError;
178 private String message = null;
181 * Constructs new PluginLoadErrors for plugin with alias.
183 * @param alias is the plugin's alias
185 public PluginLoadErrors(final String alias) {
186 this.alias = alias;
190 * Stores error type that has occurred and adds the error to the list of errors.
192 * @param error is the error that has occurred
193 * @param errorList is the list of errors
195 public void reportError(final ERRORS error, final List<PluginLoadErrors> errorList){
196 this.error = error;
197 errorList.add(this);
201 * Stores error type that has occurred with additional message specification and
202 * adds the error to the list of errors.
204 * @param error is the error that has occurred
205 * @param message is detail info about the error
206 * @param errorList is the list of errors
208 public void reportError(final ERRORS error, final String message, final List<PluginLoadErrors> errorList){
209 this.error = error;
210 this.message = message;
211 errorList.add(this);
215 * Returns the error type.
217 * @return error type
219 public ERRORS getError() {
220 return error;
224 * Returns translation for the error.
226 * @return translated error information
228 public String getTranslatedError(){
229 switch (error){
230 case missingXSD:
231 return MISSING_XSD_ERROR;
232 case noError:
233 return NO_ERROR;
234 case xmlParsing:
235 return XML_PARSING_ERROR;
236 case className:
237 return CLASS_NAME_ERROR;
238 case findClass:
239 return FIND_CLASS_ERROR;
240 case classHierarchy:
241 return CLASS_HIERARCHY_ERROR;
242 case instantiation:
243 return INSTANTIATION_ERROR;
244 case nullaryNotationName:
245 return NULLARY_NOTATION_NAME_ERROR;
246 case emptyNotationName:
247 return EMPTY_NOTATION_NAME;
248 case noModelFactory:
249 return NO_MODEL_FACTORY_ERROR;
250 case invalidModelFactory:
251 return INVALID_MODEL_FACTORY_ERROR;
252 case nullaryAbbreviation:
253 return NULLARY_ABBREVIATION_ERROR;
254 case emptyAbbreviation:
255 return EMPTY_ABREVIATION_ERROR;
256 case ioController:
257 return IO_CONTROLLER_ERROR;
258 case nullaryFileExtension:
259 return NULLARY_FILE_EXTENSION_ERROR;
260 case emptyFileExtension:
261 return EMPTY_FILE_EXTENSION_ERROR;
262 case notationIdentifierDuplicity:
263 return NOTATION_IDENTIFIER_DUPLICITY;
264 case nullaryPluginIdentifier:
265 return NULLARY_PLUGIN_IDENTIFIER;
266 case likeModelerpluginIdentifier:
267 return LIKE_MODELER_PLUGIN_IDENTIFIER_ERROR;
268 case emptyPluginIdentifier:
269 return EMPTY_PLUGIN_IDENTIFIER_ERROR;
270 case noRelatedNotationIdentifier:
271 return NO_RELATED_NOTATION_IDENTIFIER;
272 case nullaryRelatedNotationIdentifier:
273 return NULLARY_RELATED_NOTATION_IDENTIFIER_ERROR;
274 case emptyRelatedNotationIdentifier:
275 return EMPTY_RELATED_NOTATION_IDENTIFIER_ERROR;
276 case moduleIdentifierDuplicity:
277 return MODULE_IDENTIFIER_DUPLICITY_ERROR;
278 case extensionIdentifierDuplicity:
279 return EXTENSION_IDENIFIER_DUPLICITY_ERROR;
280 case nullaryName:
281 return NULLARY_NAME_ERROR;
282 case emptyName:
283 return EMPTY_NAME_ERROR;
284 case projectFileLikeExtension:
285 return PROJECT_FILE_LIKE_EXTENSION;
286 case notationExtensionDuplicity:
287 return DUPLICITY_EXTENSION;
288 case tooLongPluginIdentifier:
289 return TOO_LONG_IDENTIFIER;
290 default:
291 return error.toString();
296 * Returns the detail message about the error
298 * @return detail info about the error
300 public String getMessage() {
301 return message;
305 * Returns the plugin's alias
307 * @return plugin's alias
309 public String getAlias() {
310 return alias;
314 * Sets the plugin's class qualified name for better detail about the pertinent error
316 * @param fullClassName is the plugin's class qualified name
318 public void setFullClassName(final String fullClassName) {
319 this.fullClassName = fullClassName;
323 * Returns the plugin's class qualified name for better detail about the pertinent error
325 * @return plugin's class qualified name for better detail about the pertinent error
327 public String getFullClassName() {
328 return fullClassName;