1 /**
2 * Cecilia ADL Parser
3 * Copyright (C) 2008 STMicroelectronics
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Contact: fractal@objectweb.org
20 *
21 * Author: Matthieu Leclercq
22 */
23
24 package org.objectweb.fractal.cecilia.adl.implementations;
25
26 import static org.objectweb.fractal.adl.error.ErrorTemplateValidator.validErrorTemplate;
27
28 import org.objectweb.fractal.adl.error.ErrorTemplate;
29 import org.objectweb.fractal.adl.implementations.ImplementationCodeLoader;
30
31 /**
32 * {@link ErrorTemplate} group for the implementations package. This enumeration
33 * complete the
34 * {@link org.objectweb.fractal.adl.implementations.ImplementationErrors fractalADL ImplementationErrors enumeration}.
35 * {@link #getErrorId() errorIds} defined in this enumeration starts at
36 * <code>100</code>.
37 */
38 public enum ImplementationErrors implements ErrorTemplate {
39
40 /**
41 * Template used when an {@link ImplementationCodeLoader} plugin can't be
42 * found.
43 */
44 IMPL_LOADER_PLUGIN_NOT_FOUND(
45 "Can't find ImplementationCodeLoader plugin for language \"%s\". Checks 'language' attribute.",
46 "language"),
47
48 /**
49 * Template used when a language visitor plugin can't be found.
50 */
51 LANGUAGE_VISITOR_PLUGIN_NOT_FOUND(
52 "Can't find visitory plugin for language \"%s\". Checks 'language' attribute.",
53 "language"),
54
55 /** Template used when the implementation language is missing. */
56 MISSING_LANGUAGE("Implementation language missing");
57
58 private static final int ORDINAL_OFFSET = 100;
59
60 private int id;
61 private String format;
62
63 private ImplementationErrors(final String format, final Object... args) {
64 this.id = ORDINAL_OFFSET + ordinal();
65 this.format = format;
66
67 assert validErrorTemplate(this, args);
68 }
69
70 public int getErrorId() {
71 return id;
72 }
73
74 public String getGroupId() {
75 return org.objectweb.fractal.adl.implementations.ImplementationErrors.GROUP_ID;
76 }
77
78 public String getFormatedMessage(final Object... args) {
79 return String.format(format, args);
80 }
81
82 public String getFormat() {
83 return format;
84 }
85 }