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