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