View Javadoc
1   /*
2   Copyright (c) 2018 James Ahlborn
3   
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7   
8       http://www.apache.org/licenses/LICENSE-2.0
9   
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16  
17  package com.healthmarketscience.jackcess.expr;
18  
19  import java.text.DecimalFormat;
20  import java.time.ZoneId;
21  import java.time.format.DateTimeFormatter;
22  import java.util.Locale;
23  
24  /**
25   * LocaleContext encapsulates all shared localization state for expression
26   * parsing and evaluation.
27   *
28   * @author James Ahlborn
29   */
30  public interface LocaleContext
31  {
32    /**
33     * @return the currently configured Locale
34     */
35    public default Locale getLocale() {
36      return getTemporalConfig().getLocale();
37    }
38  
39    /**
40     * @return the currently configured TemporalConfig (from the
41     *         {@link EvalConfig})
42     */
43    public TemporalConfig getTemporalConfig();
44  
45    /**
46     * @return an appropriately configured (i.e. locale) DateTimeFormatter for
47     *         the given format.
48     */
49    public DateTimeFormatter createDateFormatter(String formatStr);
50  
51    /**
52     * @return the currently configured ZoneId
53     */
54    public ZoneId getZoneId();
55  
56    /**
57     * @return the currently configured NumericConfig (from the
58     *         {@link EvalConfig})
59     */
60    public NumericConfig getNumericConfig();
61  
62    /**
63     * @return an appropriately configured (i.e. DecimalFormatSymbols)
64     *         DecimalFormat for the given format.
65     */
66    public DecimalFormat createDecimalFormat(String formatStr);
67  }