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.util.Locale;
20 import javax.script.Bindings;
21 import com.healthmarketscience.jackcess.Database;
22
23 /**
24 * The EvalConfig allows for customization of the expression evaluation
25 * context for a given {@link Database} instance.
26 *
27 * @see com.healthmarketscience.jackcess.expr expression package docs
28 *
29 * @author James Ahlborn
30 */
31 public interface EvalConfig
32 {
33 /**
34 * @return the currently configured Locale
35 */
36 public Locale getLocale();
37
38 /**
39 * Sets the Locale for use when evaluating expressions. The default locale
40 * is {@link Locale#US}, so this may need to be modified when interacting
41 * with {@link Database} instances from other locales.
42 */
43 public void setLocale(Locale locale);
44
45 /**
46 * @return the currently configured TemporalConfig
47 */
48 public TemporalConfig getTemporalConfig();
49
50 /**
51 * Sets the TemporalConfig for use when evaluating expressions. The default
52 * date/time formatting is US based, so this may need to be modified when
53 * interacting with {@link Database} instances from other locales.
54 */
55 public void setTemporalConfig(TemporalConfig temporal);
56
57 /**
58 * @return the currently configured NumericConfig
59 */
60 public NumericConfig getNumericConfig();
61
62 /**
63 * Sets the NumericConfig for use when evaluating expressions. The default
64 * date/time formatting is US based, so this may need to be modified when
65 * interacting with {@link Database} instances from other locales.
66 */
67 public void setNumericConfig(NumericConfig numeric);
68
69 /**
70 * @return the currently configured FunctionLookup
71 */
72 public FunctionLookup getFunctionLookup();
73
74 /**
75 * Sets the {@link Function} provider to use during expression evaluation.
76 * The Functions supported by the default FunctionLookup are documented in
77 * {@link com.healthmarketscience.jackcess.expr}. Custom Functions can be
78 * implemented and provided to the expression evaluation engine by installing
79 * a custom FunctionLookup instance (which would presumably wrap and
80 * delegate to the default FunctionLookup instance for any default
81 * implementations).
82 */
83 public void setFunctionLookup(FunctionLookup lookup);
84
85 /**
86 * @return the currently configured Bindings
87 */
88 public Bindings getBindings();
89
90 /**
91 * Allows for passing custom information into expression evaluation.
92 * Currently, none of the default implementations make use of the Bindings.
93 * However, in the future, customization parameters could potentially be
94 * supported via custom Bindings. Additionally, custom Function instances
95 * could be passed external information via custom Bindings.
96 */
97 public void setBindings(Bindings bindings);
98 }