1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.nabla;
18
19 import java.util.Locale;
20 import java.util.MissingResourceException;
21 import java.util.ResourceBundle;
22
23 import org.apache.commons.math3.exception.util.Localizable;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public enum NablaMessages implements Localizable {
41
42
43
44
45 CANNOT_READ_CLASS("class {0} cannot be read ({1})"),
46 CANNOT_INSTANTIATE_ABSTRACT_CLASS("abstract class {0} cannot be instantiated ({1})"),
47 ILLEGAL_ACCESS_TO_CONSTRUCTOR("illegal access to class {0} constructor ({1})"),
48 CANNOT_BUILD_CLASS_FROM_OTHER_CLASS("class {0} cannot be built from an instance of class {1} ({2})"),
49 CANNOT_INSTANTIATE_CLASS_FROM_OTHER_INSTANCE("class {0} instantiation from an instance of class {1} failed ({2})"),
50 INCORRECT_GENERATED_CODE("class {0} code generated from an instance of class {1} is incorrect ({2})"),
51 INTERFACE_NOT_FOUND_WHILE_DIFFERENTIATING("interface {0} not found while differentiating class {1}"),
52 CLASS_DOES_NOT_IMPLEMENT_INTERFACE("the {0} class does not implement the {1} interface"),
53 UNABLE_TO_ANALYZE_METHOD("unable to analyze the {0}.{1} method ({2})"),
54 UNKNOWN_METHOD("unknown method {0}.{1}"),
55 NUMBER_OF_TEMPORARY_VARIABLES_OUT_OF_RANGE("number of temporary variable ({0}) outside of [{1}, {2}] range"),
56 INDEX_OF_LOCAL_VARIABLE_OUT_OF_RANGE("index of size {0} local variable ({1}) outside of [{2}, {3}] range"),
57 UNEXPECTED_INSTRUCTION("unexpected instruction with opcode {0}"),
58 UNABLE_TO_HANDLE_INSTRUCTION("unable to handle instruction with opcode {0}"),
59 CANNOT_GET_VOID_FIELD("unable to get value of void type field {0}"),
60 ILLEGAL_LDC_CONSTANT("illegal LDC constant {0}"),
61 INTERNAL_ERROR("internal error, please fill a bug report at {0}");
62
63
64
65
66
67
68 private final String sourceFormat;
69
70
71
72
73
74 private NablaMessages(final String sourceFormat) {
75 this.sourceFormat = sourceFormat;
76 }
77
78
79 public String getSourceString() {
80 return sourceFormat;
81 }
82
83
84 public String getLocalizedString(final Locale locale) {
85 try {
86 final String path = NablaMessages.class.getName().replaceAll("\\.", "/");
87 final ResourceBundle bundle =
88 ResourceBundle.getBundle("assets/" + path, locale);
89 if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
90
91 return bundle.getString(toString());
92 }
93
94 } catch (MissingResourceException mre) {
95
96 }
97
98
99
100 return sourceFormat;
101
102 }
103
104 }