View Javadoc
1   /*
2    * Licensed to the Hipparchus project 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 Hipparchus project 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  package org.hipparchus.stat;
18  
19  import java.util.Locale;
20  
21  import org.hipparchus.exception.Localizable;
22  
23  /**
24   * Enumeration for localized messages formats used in exceptions messages.
25   * <p>
26   * The constants in this enumeration represent the available formats as
27   * localized strings. These formats are intended to be localized using simple
28   * properties files, using the constant name as the key and the property value
29   * as the message format. The source English format is provided in the constants
30   * themselves to serve both as a reminder for developers to understand the
31   * parameters needed by each format, as a basis for translators to create
32   * localized properties files, and as a default format if some translation is
33   * missing.
34   * </p>
35   */
36  public enum LocalizedStatFormats implements Localizable {
37  
38      /** TIES_ARE_NOT_ALLOWED. */
39      TIES_ARE_NOT_ALLOWED("Ties are not allowed."),
40  
41      /** INSUFFICIENT_DATA_FOR_T_STATISTIC. */
42      INSUFFICIENT_DATA_FOR_T_STATISTIC("insufficient data for t statistic, needs at least 2, got {0}"),
43  
44      /** NOT_ENOUGH_DATA_REGRESSION. */
45      NOT_ENOUGH_DATA_REGRESSION("the number of observations is not sufficient to conduct regression"),
46  
47      /** INVALID_REGRESSION_OBSERVATION. */
48      INVALID_REGRESSION_OBSERVATION("length of regressor array = {0} does not match the number of variables = {1} in the model"),
49  
50      /** NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS. */
51      NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS("not enough data ({0} rows) for this many predictors ({1} predictors)"),
52  
53      /** NOT_SUPPORTED_NAN_STRATEGY. */
54      NOT_SUPPORTED_NAN_STRATEGY("NaN strategy {0} not supported"),
55  
56      /** NO_REGRESSORS. */
57      NO_REGRESSORS("Regression model must include at least one regressor"),
58  
59      /** COVARIANCE_MATRIX. */
60      COVARIANCE_MATRIX("covariance matrix"),
61  
62      /** OUT_OF_BOUNDS_QUANTILE_VALUE. */
63      OUT_OF_BOUNDS_QUANTILE_VALUE("out of bounds quantile value: {0}, must be in (0, 100]"),
64  
65      /** OUT_OF_BOUNDS_CONFIDENCE_LEVEL. */
66      OUT_OF_BOUNDS_CONFIDENCE_LEVEL("out of bounds confidence level {0}, must be between {1} and {2}"),
67  
68      /** OUT_OF_BOUND_SIGNIFICANCE_LEVEL. */
69      OUT_OF_BOUND_SIGNIFICANCE_LEVEL("out of bounds significance level {0}, must be between {1} and {2}"),
70  
71      /** SIGNIFICANCE_LEVEL. */
72      SIGNIFICANCE_LEVEL("significance level ({0})"),
73  
74      /** TOO_MANY_REGRESSORS. */
75      TOO_MANY_REGRESSORS("too many regressors ({0}) specified, only {1} in the model"),
76  
77      /** TWO_OR_MORE_CATEGORIES_REQUIRED. */
78      TWO_OR_MORE_CATEGORIES_REQUIRED("two or more categories required, got {0}"),
79  
80      /** TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED. */
81      TWO_OR_MORE_VALUES_IN_CATEGORY_REQUIRED("two or more values required in each category, one has {0}"),
82  
83      /** ILLEGAL_STATE_PCA. */
84      ILLEGAL_STATE_PCA("you must fit the PCA projection before calling {0}");
85  
86      /** Source English format. */
87      private final String sourceFormat;
88  
89      /**
90       * Simple constructor.
91       *
92       * @param sourceFormat source English format to use when no localized
93       *        version is available
94       */
95      LocalizedStatFormats(final String sourceFormat) {
96          this.sourceFormat = sourceFormat;
97      }
98  
99      /** {@inheritDoc} */
100     @Override
101     public String getSourceString() {
102         return sourceFormat;
103     }
104 
105     /** {@inheritDoc} */
106     @Override
107     public String getLocalizedString(final Locale locale) {
108         return getLocalizedString("assets/" + LocalizedStatFormats.class.getName().replaceAll("\\.", "/"),
109                                   name(), locale);
110     }
111 
112 }