View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  /*
19   * This is not the original file distributed by the Apache Software Foundation
20   * It has been modified by the Hipparchus project
21   */
22  package org.hipparchus.exception;
23  
24  import java.util.Locale;
25  import java.util.MissingResourceException;
26  import java.util.ResourceBundle;
27  
28  /**
29   * Enumeration for localized messages formats used in exceptions messages.
30   * <p>
31   * The constants in this enumeration represent the available
32   * formats as localized strings. These formats are intended to be
33   * localized using simple properties files, using the constant
34   * name as the key and the property value as the message format.
35   * The source English format is provided in the constants themselves
36   * to serve both as a reminder for developers to understand the parameters
37   * needed by each format, as a basis for translators to create
38   * localized properties files, and as a default format if some
39   * translation is missing.
40   * </p>
41   */
42  public enum LocalizedCoreFormats implements Localizable {
43  
44      /** ARRAY_SIZE_EXCEEDS_MAX_VARIABLES. */
45      ARRAY_SIZE_EXCEEDS_MAX_VARIABLES("array size cannot be greater than {0}"),
46  
47      /** ARRAY_SIZES_SHOULD_HAVE_DIFFERENCE_1. */
48      ARRAY_SIZES_SHOULD_HAVE_DIFFERENCE_1("array sizes should have difference 1 ({0} != {1} + 1)"),
49  
50      /** ARRAY_SUMS_TO_ZERO. */
51      ARRAY_SUMS_TO_ZERO("array sums to zero"),
52  
53      /** AT_LEAST_ONE_COLUMN. */
54      AT_LEAST_ONE_COLUMN("matrix must have at least one column"),
55  
56      /** AT_LEAST_ONE_ROW. */
57      AT_LEAST_ONE_ROW("matrix must have at least one row"),
58  
59      /** BANDWIDTH. */
60      BANDWIDTH("bandwidth ({0})"),
61  
62      /** BESSEL_FUNCTION_BAD_ARGUMENT. */
63      BESSEL_FUNCTION_BAD_ARGUMENT("Bessel function of order {0} cannot be computed for x = {1}"),
64  
65      /** BESSEL_FUNCTION_FAILED_CONVERGENCE. */
66      BESSEL_FUNCTION_FAILED_CONVERGENCE("Bessel function of order {0} failed to converge for x = {1}"),
67  
68      /** BINOMIAL_INVALID_PARAMETERS_ORDER. */
69      BINOMIAL_INVALID_PARAMETERS_ORDER("must have n >= k for binomial coefficient (n, k), got k = {0}, n = {1}"),
70  
71      /** BINOMIAL_NEGATIVE_PARAMETER. */
72      BINOMIAL_NEGATIVE_PARAMETER("must have n >= 0 for binomial coefficient (n, k), got n = {0}"),
73  
74      /** CANNOT_COMPUTE_0TH_ROOT_OF_UNITY. */
75      CANNOT_COMPUTE_0TH_ROOT_OF_UNITY("cannot compute 0-th root of unity, indefinite result"),
76  
77      /** CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA. */
78      CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA("cannot compute beta density at 0 when alpha = {0,number}"),
79  
80      /** CANNOT_COMPUTE_BETA_DENSITY_AT_1_FOR_SOME_BETA. */
81      CANNOT_COMPUTE_BETA_DENSITY_AT_1_FOR_SOME_BETA("cannot compute beta density at 1 when beta = %.3g"),
82  
83      /** CANNOT_COMPUTE_NTH_ROOT_FOR_NEGATIVE_N. */
84      CANNOT_COMPUTE_NTH_ROOT_FOR_NEGATIVE_N("cannot compute nth root for null or negative n: {0}"),
85  
86      /** CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS. */
87      CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS("cannot discard a negative number of elements ({0})"),
88  
89      /** CANNOT_FORMAT_INSTANCE_AS_COMPLEX. */
90      CANNOT_FORMAT_INSTANCE_AS_COMPLEX("cannot format a {0} instance as a complex number"),
91  
92      /** CANNOT_FORMAT_OBJECT_TO_FRACTION. */
93      CANNOT_FORMAT_OBJECT_TO_FRACTION("cannot format given object as a fraction number"),
94  
95      /** CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY. */
96      CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY("cannot substitute an element from an empty array"),
97  
98      /** COLUMN_INDEX. */
99      COLUMN_INDEX("column index ({0})"), /* keep */
100 
101     /** COMPLEX_CANNOT_BE_CONSIDERED_A_REAL_NUMBER. */
102     COMPLEX_CANNOT_BE_CONSIDERED_A_REAL_NUMBER("complex number ({0},{1}) cannot be considered to be a real number"),
103 
104     /** CONSTRAINT. */
105     CONSTRAINT("constraint"), /* keep */
106 
107     /** CONTINUED_FRACTION_INFINITY_DIVERGENCE. */
108     CONTINUED_FRACTION_INFINITY_DIVERGENCE("Continued fraction convergents diverged to +/- infinity for value {0}"),
109 
110     /** CONTINUED_FRACTION_NAN_DIVERGENCE. */
111     CONTINUED_FRACTION_NAN_DIVERGENCE("Continued fraction diverged to NaN for value {0}"),
112 
113     /** CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR. */
114     CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR("contraction criteria ({0}) smaller than the expansion factor ({1}).  This would lead to a never ending loop of expansion and contraction as a newly expanded internal storage array would immediately satisfy the criteria for contraction."),
115 
116     /** CONTRACTION_CRITERIA_SMALLER_THAN_ONE. */
117     CONTRACTION_CRITERIA_SMALLER_THAN_ONE("contraction criteria smaller than one ({0}).  This would lead to a never ending loop of expansion and contraction as an internal storage array length equal to the number of elements would satisfy the contraction criteria."),
118 
119     /** CONVERGENCE_FAILED. */
120     CONVERGENCE_FAILED("convergence failed"), /* keep */
121 
122     /** CUMULATIVE_PROBABILITY_RETURNED_NAN. */
123     CUMULATIVE_PROBABILITY_RETURNED_NAN("Cumulative probability function returned NaN for argument {0} p = {1}"),
124 
125     /** DERIVATION_ORDER_NOT_ALLOWED. */
126     DERIVATION_ORDER_NOT_ALLOWED("derivation order {0} is not allowed here"),
127 
128     /** DIFFERENT_ROWS_LENGTHS. */
129     DIFFERENT_ROWS_LENGTHS("some rows have length {0} while others have length {1}"),
130 
131     /** DIGEST_NOT_INITIALIZED. */
132     DIGEST_NOT_INITIALIZED("digest not initialized"),
133 
134     /** DIMENSIONS_MISMATCH_2x2. */
135     DIMENSIONS_MISMATCH_2x2("got {0}x{1} but expected {2}x{3}"), /* keep */
136 
137     /** DIMENSIONS_MISMATCH. */
138     DIMENSIONS_MISMATCH("inconsistent dimensions: {0} != {1}"), /* keep */
139 
140     /** DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN. */
141     DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN("Discrete cumulative probability function returned NaN for argument {0}"),
142 
143     /** DISTRIBUTION_NOT_LOADED. */
144     DISTRIBUTION_NOT_LOADED("distribution not loaded"),
145 
146     /** DUPLICATED_ABSCISSA_DIVISION_BY_ZERO. */
147     DUPLICATED_ABSCISSA_DIVISION_BY_ZERO("duplicated abscissa {0} causes division by zero"),
148 
149     /** EMPTY_INTERPOLATION_SAMPLE. */
150     EMPTY_INTERPOLATION_SAMPLE("sample for interpolation is empty"),
151 
152     /** EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY. */
153     EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY("empty polynomials coefficients array"), /* keep */
154 
155     /** EMPTY_SELECTED_COLUMN_INDEX_ARRAY. */
156     EMPTY_SELECTED_COLUMN_INDEX_ARRAY("empty selected column index array"),
157 
158     /** EMPTY_SELECTED_ROW_INDEX_ARRAY. */
159     EMPTY_SELECTED_ROW_INDEX_ARRAY("empty selected row index array"),
160 
161     /** ENDPOINTS_NOT_AN_INTERVAL. */
162     ENDPOINTS_NOT_AN_INTERVAL("endpoints do not specify an interval: [{0}, {1}]"),
163 
164     /** EVALUATION. */
165     EVALUATION("evaluation"), /* keep */
166 
167     /** EXPANSION_FACTOR_SMALLER_THAN_ONE. */
168     EXPANSION_FACTOR_SMALLER_THAN_ONE("expansion factor smaller than one ({0})"),
169 
170     /** FACTORIAL_NEGATIVE_PARAMETER. */
171     FACTORIAL_NEGATIVE_PARAMETER("must have n >= 0 for n!, got n = {0}"),
172 
173     /** FAILED_BRACKETING. */
174     FAILED_BRACKETING("number of iterations={4}, maximum iterations={5}, initial={6}, lower bound={7}, upper bound={8}, final a value={0}, final b value={1}, f(a)={2}, f(b)={3}"),
175 
176     /** FAILED_DECOMPOSITION. */
177     FAILED_DECOMPOSITION("failed decomposition of a {0}x{1} matrix"),
178 
179     /** FAILED_FRACTION_CONVERSION. */
180     FAILED_FRACTION_CONVERSION("Unable to convert {0} to fraction after {1} iterations"),
181 
182     /** FIRST_COLUMNS_NOT_INITIALIZED_YET. */
183     FIRST_COLUMNS_NOT_INITIALIZED_YET("first {0} columns are not initialized yet"),
184 
185     /** FIRST_ROWS_NOT_INITIALIZED_YET. */
186     FIRST_ROWS_NOT_INITIALIZED_YET("first {0} rows are not initialized yet"),
187 
188     /** FRACTION_CONVERSION_OVERFLOW. */
189     FRACTION_CONVERSION_OVERFLOW("Overflow trying to convert {0} to fraction ({1}/{2})"),
190 
191     /** GCD_OVERFLOW_32_BITS. */
192     GCD_OVERFLOW_32_BITS("overflow: gcd({0}, {1}) is 2^31"),
193 
194     /** GCD_OVERFLOW_64_BITS. */
195     GCD_OVERFLOW_64_BITS("overflow: gcd({0}, {1}) is 2^63"),
196 
197     /** ILL_CONDITIONED_OPERATOR. */
198     ILL_CONDITIONED_OPERATOR("condition number {1} is too high "),
199 
200     /** INDEX_LARGER_THAN_MAX. */
201     INDEX_LARGER_THAN_MAX("the index specified: {0} is larger than the current maximal index {1}"),
202 
203     /** INDEX_NOT_POSITIVE. */
204     INDEX_NOT_POSITIVE("index ({0}) is not positive"),
205 
206     /** INDEX. */
207     INDEX("index ({0})"), /* keep */
208 
209     /** NOT_FINITE_NUMBER. */
210     NOT_FINITE_NUMBER("{0} is not a finite number"), /* keep */
211 
212     /** INFINITE_BOUND. */
213     INFINITE_BOUND("interval bounds must be finite"),
214 
215     /** ARRAY_ELEMENT. */
216     ARRAY_ELEMENT("value {0} at index {1}"), /* keep */
217 
218     /** INFINITE_ARRAY_ELEMENT. */
219     INFINITE_ARRAY_ELEMENT("Array contains an infinite element, {0} at index {1}"),
220 
221     /** INFINITE_VALUE_CONVERSION. */
222     INFINITE_VALUE_CONVERSION("cannot convert infinite value"),
223 
224     /** INITIAL_CAPACITY_NOT_POSITIVE. */
225     INITIAL_CAPACITY_NOT_POSITIVE("initial capacity ({0}) is not positive"),
226 
227     /** INITIAL_COLUMN_AFTER_FINAL_COLUMN. */
228     INITIAL_COLUMN_AFTER_FINAL_COLUMN("initial column {1} after final column {0}"),
229 
230     /** INITIAL_ROW_AFTER_FINAL_ROW. */
231     INITIAL_ROW_AFTER_FINAL_ROW("initial row {1} after final row {0}"),
232 
233     /** INSUFFICIENT_DATA. */
234     INSUFFICIENT_DATA("insufficient data"),
235 
236     /** INSUFFICIENT_DIMENSION. */
237     INSUFFICIENT_DIMENSION("insufficient dimension {0}, must be at least {1}"),
238 
239     /** DIMENSION. */
240     DIMENSION("dimension ({0})"), /* keep */
241 
242     /** INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE. */
243     INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE("sample contains {0} observed points, at least {1} are required"),
244 
245     /** INSUFFICIENT_ROWS_AND_COLUMNS. */
246     INSUFFICIENT_ROWS_AND_COLUMNS("insufficient data: only {0} rows and {1} columns."),
247 
248     /** INTERNAL_ERROR. */
249     INTERNAL_ERROR("internal error, please fill a bug report at {0}"),
250 
251     /** INVALID_MAX_ITERATIONS. */
252     INVALID_MAX_ITERATIONS("bad value for maximum iterations number: {0}"),
253 
254     /** ITERATIONS. */
255     ITERATIONS("iterations"), /* keep */
256 
257     /** LCM_OVERFLOW_32_BITS. */
258     LCM_OVERFLOW_32_BITS("overflow: lcm({0}, {1}) is 2^31"),
259 
260     /** LCM_OVERFLOW_64_BITS. */
261     LCM_OVERFLOW_64_BITS("overflow: lcm({0}, {1}) is 2^63"),
262 
263     /** LOWER_BOUND_NOT_BELOW_UPPER_BOUND. */
264     LOWER_BOUND_NOT_BELOW_UPPER_BOUND("lower bound ({0}) must be strictly less than upper bound ({1})"), /* keep */
265 
266     /** LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT. */
267     LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT("lower endpoint ({0}) must be less than or equal to upper endpoint ({1})"),
268 
269     /** EVALUATIONS. */
270     EVALUATIONS("evaluations"), /* keep */
271 
272     /** MAX_COUNT_EXCEEDED. */
273     MAX_COUNT_EXCEEDED("maximal count ({0}) exceeded"), /* keep */
274 
275     /** NAN_ELEMENT_AT_INDEX. */
276     NAN_ELEMENT_AT_INDEX("element {0} is NaN"),
277 
278     /** NAN_VALUE_CONVERSION. */
279     NAN_VALUE_CONVERSION("cannot convert NaN value"),
280 
281     /** NEGATIVE_DEFINITE_MATRIX. */
282     NEGATIVE_DEFINITE_MATRIX("negative definite matrix"),
283 
284     /** NEGATIVE_COMPLEX_MODULE. */
285     NEGATIVE_COMPLEX_MODULE("negative complex module {0}"),
286 
287     /** NEGATIVE_ELEMENT_AT_INDEX. */
288     NEGATIVE_ELEMENT_AT_INDEX("element {0} is negative: {1}"),
289 
290     /** NUMBER_OF_SUCCESSES. */
291     NUMBER_OF_SUCCESSES("number of successes ({0})"), /* keep */
292 
293     /** NUMBER_OF_INTERPOLATION_POINTS. */
294     NUMBER_OF_INTERPOLATION_POINTS("number of interpolation points ({0})"), /* keep */
295 
296     /** NUMBER_OF_TRIALS. */
297     NUMBER_OF_TRIALS("number of trials ({0})"),
298 
299     /** ROBUSTNESS_ITERATIONS. */
300     ROBUSTNESS_ITERATIONS("number of robustness iterations ({0})"),
301 
302     /** START_POSITION. */
303     START_POSITION("start position ({0})"), /* keep */
304 
305     /** NON_CONVERGENT_CONTINUED_FRACTION. */
306     NON_CONVERGENT_CONTINUED_FRACTION("Continued fraction convergents failed to converge (in less than {0} iterations) for value {1}"),
307 
308     /** NON_SQUARE_MATRIX. */
309     NON_SQUARE_MATRIX("non square ({0}x{1}) matrix"),
310 
311     /** NORM. */
312     NORM("Norm ({0})"), /* keep */
313 
314     /** NORMALIZE_INFINITE. */
315     NORMALIZE_INFINITE("Cannot normalize to an infinite value"),
316 
317     /** NORMALIZE_NAN. */
318     NORMALIZE_NAN("Cannot normalize to NaN"),
319 
320     /** NOT_DECREASING_SEQUENCE. */
321     NOT_DECREASING_SEQUENCE("points {3} and {2} are not decreasing ({1} < {0})"), /* keep */
322 
323     /** NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION. */
324     NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION("spline partition must have at least {0} points, got {1}"),
325 
326     /** NOT_INCREASING_SEQUENCE. */
327     NOT_INCREASING_SEQUENCE("points {3} and {2} are not increasing ({1} > {0})"), /* keep */
328 
329     /** NOT_POSITIVE_DEFINITE_MATRIX. */
330     NOT_POSITIVE_DEFINITE_MATRIX("not positive definite matrix"), /* keep */
331 
332     /** NON_POSITIVE_DEFINITE_OPERATOR. */
333     NON_POSITIVE_DEFINITE_OPERATOR("non positive definite linear operator"), /* keep */
334 
335     /** NON_SELF_ADJOINT_OPERATOR. */
336     NON_SELF_ADJOINT_OPERATOR("non self-adjoint linear operator"), /* keep */
337 
338     /** NON_SQUARE_OPERATOR. */
339     NON_SQUARE_OPERATOR("non square ({0}x{1}) linear operator"), /* keep */
340 
341     /** DEGREES_OF_FREEDOM. */
342     DEGREES_OF_FREEDOM("degrees of freedom ({0})"), /* keep */
343 
344     /** NOT_POSITIVE_EXPONENT. */
345     NOT_POSITIVE_EXPONENT("invalid exponent {0} (must be positive)"),
346 
347     /** NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE. */
348     NUMBER_OF_ELEMENTS_SHOULD_BE_POSITIVE("number of elements should be positive ({0})"),
349 
350     /** BASE. */
351     BASE("base ({0})"), /* keep */
352 
353     /** EXPONENT. */
354     EXPONENT("exponent ({0})"), /* keep */
355 
356     /** LENGTH. */
357     LENGTH("length ({0})"), /* keep */
358 
359     /** MEAN. */
360     MEAN("mean ({0})"), /* keep */
361 
362     /** NOT_POSITIVE_NUMBER_OF_SAMPLES. */
363     NOT_POSITIVE_NUMBER_OF_SAMPLES("number of sample is not positive: {0}"),
364 
365     /** NUMBER_OF_SAMPLES. */
366     NUMBER_OF_SAMPLES("number of samples ({0})"), /* keep */
367 
368     /** PERMUTATION_SIZE. */
369     PERMUTATION_SIZE("permutation size ({0}"), /* keep */
370 
371     /** POPULATION_SIZE. */
372     POPULATION_SIZE("population size ({0})"), /* keep */
373 
374     /** NOT_POSITIVE_SCALE. */
375     NOT_POSITIVE_SCALE("scale must be positive ({0})"),
376 
377     /** SCALE. */
378     SCALE("scale ({0})"), /* keep */
379 
380     /** SHAPE. */
381     SHAPE("shape ({0})"), /* keep */
382 
383     /** STANDARD_DEVIATION. */
384     STANDARD_DEVIATION("standard deviation ({0})"), /* keep */
385 
386     /** NOT_POSITIVE_WINDOW_SIZE. */
387     NOT_POSITIVE_WINDOW_SIZE("window size must be positive ({0})"),
388 
389     /** NOT_STRICTLY_DECREASING_SEQUENCE. */
390     NOT_STRICTLY_DECREASING_SEQUENCE("points {3} and {2} are not strictly decreasing ({1} <= {0})"), /* keep */
391 
392     /** NOT_STRICTLY_INCREASING_SEQUENCE. */
393     NOT_STRICTLY_INCREASING_SEQUENCE("points {3} and {2} are not strictly increasing ({1} >= {0})"), /* keep */
394 
395     /** NON_SYMMETRIC_MATRIX. */
396     NON_SYMMETRIC_MATRIX("non symmetric matrix: the difference between entries at ({0},{1}) and ({1},{0}) is larger than {2}"), /* keep */
397 
398     /** NO_CONVERGENCE_WITH_ANY_START_POINT. */
399     NO_CONVERGENCE_WITH_ANY_START_POINT("none of the {0} start points lead to convergence"), /* keep */
400 
401     /** NO_DATA. */
402     NO_DATA("no data"), /* keep */
403 
404     /** NO_OPTIMUM_COMPUTED_YET. */
405     NO_OPTIMUM_COMPUTED_YET("no optimum computed yet"), /* keep */
406 
407     /** NAN_NOT_ALLOWED. */
408     NAN_NOT_ALLOWED("NaN is not allowed"),
409 
410     /** NULL_NOT_ALLOWED. */
411     NULL_NOT_ALLOWED("null is not allowed"), /* keep */
412 
413     /** ARRAY_ZERO_LENGTH_OR_NULL_NOT_ALLOWED. */
414     ARRAY_ZERO_LENGTH_OR_NULL_NOT_ALLOWED("a null or zero length array not allowed"),
415 
416     /** DENOMINATOR. */
417     DENOMINATOR("denominator"), /* keep */
418 
419     /** DENOMINATOR_FORMAT. */
420     DENOMINATOR_FORMAT("denominator format"), /* keep */
421 
422     /** FRACTION. */
423     FRACTION("fraction"), /* keep */
424 
425     /** FUNCTION. */
426     FUNCTION("function"), /* keep */
427 
428     /** IMAGINARY_FORMAT. */
429     IMAGINARY_FORMAT("imaginary format"), /* keep */
430 
431     /** INPUT_ARRAY. */
432     INPUT_ARRAY("input array"), /* keep */
433 
434     /** NUMERATOR. */
435     NUMERATOR("numerator"), /* keep */
436 
437     /** NUMERATOR_FORMAT. */
438     NUMERATOR_FORMAT("numerator format"), /* keep */
439 
440     /** REAL_FORMAT. */
441     REAL_FORMAT("real format"), /* keep */
442 
443     /** WHOLE_FORMAT. */
444     WHOLE_FORMAT("whole format"), /* keep */
445 
446     /** NUMBER_TOO_LARGE. */
447     NUMBER_TOO_LARGE("{0} is larger than the maximum ({1})"), /* keep */
448 
449     /** NUMBER_TOO_SMALL. */
450     NUMBER_TOO_SMALL("{0} is smaller than the minimum ({1})"), /* keep */
451 
452     /** NUMBER_TOO_LARGE_BOUND_EXCLUDED. */
453     NUMBER_TOO_LARGE_BOUND_EXCLUDED("{0} is larger than, or equal to, the maximum ({1})"), /* keep */
454 
455     /** NUMBER_TOO_SMALL_BOUND_EXCLUDED. */
456     NUMBER_TOO_SMALL_BOUND_EXCLUDED("{0} is smaller than, or equal to, the minimum ({1})"), /* keep */
457 
458     /** NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE. */
459     NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE("number of successes ({0}) must be less than or equal to population size ({1})"),
460 
461     /** NUMERATOR_OVERFLOW_AFTER_MULTIPLY. */
462     NUMERATOR_OVERFLOW_AFTER_MULTIPLY("overflow, numerator too large after multiply: {0}"),
463 
464     /** OBSERVED_COUNTS_BOTTH_ZERO_FOR_ENTRY. */
465     OBSERVED_COUNTS_BOTTH_ZERO_FOR_ENTRY("observed counts are both zero for entry {0}"),
466 
467     /** OUT_OF_RANGE_ROOT_OF_UNITY_INDEX. */
468     OUT_OF_RANGE_ROOT_OF_UNITY_INDEX("out of range root of unity index {0} (must be in [{1};{2}])"),
469 
470     /** OUT_OF_RANGE. */
471     OUT_OF_RANGE("out of range"), /* keep */
472 
473     /** OUT_OF_RANGE_SIMPLE. */
474     OUT_OF_RANGE_SIMPLE("{0} out of [{1}, {2}] range"), /* keep */
475 
476     /** OUT_OF_RANGE_LEFT. */
477     OUT_OF_RANGE_LEFT("{0} out of ({1}, {2}] range"),
478 
479     /** OVERFLOW. */
480     OVERFLOW("overflow"), /* keep */
481 
482     /** OVERFLOW_IN_FRACTION. */
483     OVERFLOW_IN_FRACTION("overflow in fraction {0}/{1}, cannot negate"),
484 
485     /** OVERFLOW_IN_ADDITION. */
486     OVERFLOW_IN_ADDITION("overflow in addition: {0} + {1}"),
487 
488     /** OVERFLOW_IN_SUBTRACTION. */
489     OVERFLOW_IN_SUBTRACTION("overflow in subtraction: {0} - {1}"),
490 
491     /** OVERFLOW_IN_MULTIPLICATION. */
492     OVERFLOW_IN_MULTIPLICATION("overflow in multiplication: {0} * {1}"),
493 
494     /** PERMUTATION_EXCEEDS_N. */
495     PERMUTATION_EXCEEDS_N("permutation size ({0}) exceeds permuation domain ({1})"), /* keep */
496 
497     /** POLYNOMIAL. */
498     POLYNOMIAL("polynomial"), /* keep */
499 
500     /** ROOTS_OF_UNITY_NOT_COMPUTED_YET. */
501     ROOTS_OF_UNITY_NOT_COMPUTED_YET("roots of unity have not been computed yet"),
502 
503     /** ROW_INDEX. */
504     ROW_INDEX("row index ({0})"), /* keep */
505 
506     /** NOT_BRACKETING_INTERVAL. */
507     NOT_BRACKETING_INTERVAL("interval does not bracket a root: f({0,number,##0.################E0}) = {2,number,##0.################E0}, f({1,number,##0.################E0}) = {3,number,##0.################E0}"),
508 
509     /** START_POINT_NOT_IN_INTERVAL. */
510     START_POINT_NOT_IN_INTERVAL("The start point {0} is not in the interval [{1}, {2}]"),
511 
512     /** SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE. */
513     SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE("sample size ({0}) exceeds collection size ({1})"), /* keep */
514 
515     /** SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE. */
516     SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE("sample size ({0}) must be less than or equal to population size ({1})"),
517 
518     /** SIMPLE_MESSAGE. */
519     SIMPLE_MESSAGE("{0}"),
520 
521     /** SINGULAR_MATRIX. */
522     SINGULAR_MATRIX("matrix is singular"), /* keep */
523 
524     /** SINGULAR_OPERATOR. */
525     SINGULAR_OPERATOR("operator is singular"),
526 
527     /** SUBARRAY_ENDS_AFTER_ARRAY_END. */
528     SUBARRAY_ENDS_AFTER_ARRAY_END("subarray ends after array end"),
529 
530     /** TOO_LARGE_CUTOFF_SINGULAR_VALUE. */
531     TOO_LARGE_CUTOFF_SINGULAR_VALUE("cutoff singular value is {0}, should be at most {1}"),
532 
533     /** TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY. */
534     TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY("cannot discard {0} elements from a {1} elements array"),
535 
536     /** UNKNOWN_MODE. */
537     UNKNOWN_MODE("unknown mode {0}, known modes: {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) and {11} ({12})"),
538 
539     /** CANNOT_PARSE_AS_TYPE. */
540     CANNOT_PARSE_AS_TYPE("string \"{0}\" unparseable (from position {1}) as an object of type {2}"), /* keep */
541 
542     /** CANNOT_PARSE. */
543     CANNOT_PARSE("string \"{0}\" unparseable (from position {1})"), /* keep */
544 
545     /** UNSUPPORTED_OPERATION. */
546     UNSUPPORTED_OPERATION("unsupported operation"), /* keep */
547 
548     /** ARITHMETIC_EXCEPTION. */
549     ARITHMETIC_EXCEPTION("arithmetic exception"), /* keep */
550 
551     /** ILLEGAL_STATE. */
552     ILLEGAL_STATE("illegal state"), /* keep */
553 
554     /** USER_EXCEPTION. */
555     USER_EXCEPTION("exception generated in user code"), /* keep */
556 
557     /** URL_CONTAINS_NO_DATA. */
558     URL_CONTAINS_NO_DATA("URL {0} contains no data"),
559 
560     /** VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT. */
561     VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT("vector must have at least one element"),
562 
563     /** WEIGHT_AT_LEAST_ONE_NON_ZERO. */
564     WEIGHT_AT_LEAST_ONE_NON_ZERO("weight array must contain at least one non-zero value"),
565 
566     /** WRONG_NUMBER_OF_POINTS. */
567     WRONG_NUMBER_OF_POINTS("{0} points are required, got only {1}"),
568 
569     /** NUMBER_OF_POINTS. */
570     NUMBER_OF_POINTS("number of points ({0})"), /* keep */
571 
572     /** ZERO_DENOMINATOR. */
573     ZERO_DENOMINATOR("denominator must be different from 0"), /* keep */
574 
575     /** ZERO_DENOMINATOR_IN_FRACTION. */
576     ZERO_DENOMINATOR_IN_FRACTION("zero denominator in fraction {0}/{1}"),
577 
578     /** ZERO_FRACTION_TO_DIVIDE_BY. */
579     ZERO_FRACTION_TO_DIVIDE_BY("the fraction to divide by must not be zero: {0}/{1}"),
580 
581     /** ZERO_NORM. */
582     ZERO_NORM("zero norm"),
583 
584     /** ZERO_NOT_ALLOWED. */
585     ZERO_NOT_ALLOWED("zero not allowed here"),
586 
587     /** ZERO_STATE_SIZE. */
588     ZERO_STATE_SIZE("state dimension must be different from 0"),
589 
590     /** RIGHT_EDGE_GREATER_THAN_LEFT_EDGE. */
591     RIGHT_EDGE_GREATER_THAN_LEFT_EDGE("left edge {0} should be smaller than right edge {1}"),
592 
593     /** INPUT_EXPECTED_BETWEEN_ZERO_AND_ONE_INCLUDED. */
594     INPUT_EXPECTED_BETWEEN_ZERO_AND_ONE_INCLUDED("input {0} is expected to be between [0:1]");
595 
596     /** Source English format. */
597     private final String sourceFormat;
598 
599     /** Simple constructor.
600      * @param sourceFormat source English format to use when no
601      * localized version is available
602      */
603     LocalizedCoreFormats(final String sourceFormat) {
604         this.sourceFormat = sourceFormat;
605     }
606 
607     /** {@inheritDoc} */
608     @Override
609     public String getSourceString() {
610         return sourceFormat;
611     }
612 
613     /** {@inheritDoc} */
614     @Override
615     public String getLocalizedString(final Locale locale) {
616         try {
617             final String path = LocalizedCoreFormats.class.getName().replaceAll("\\.", "/");
618             ResourceBundle bundle =
619                     ResourceBundle.getBundle("assets/" + path, locale, new UTF8Control());
620             if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) {
621                 final String translated = bundle.getString(name());
622                 if ((translated != null) &&
623                     (translated.length() > 0) &&
624                     (!translated.toLowerCase(locale).contains("missing translation"))) {
625                     // the value of the resource is the translated format
626                     return translated;
627                 }
628             }
629 
630         } catch (MissingResourceException mre) { // NOPMD
631             // do nothing here
632         }
633 
634         // either the locale is not supported or the resource is unknown
635         // don't translate and fall back to using the source format
636         return sourceFormat;
637 
638     }
639 
640 }