View Javadoc
1   /*
2   Copyright (c) 2016 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.Collection;
20  
21  /**
22   * An Expression is an executable handle to an Access expression.  While the
23   * expression framework is implemented separately from the core database
24   * functionality, most usage of Expressions will happen indirectly within the
25   * context of normal database operations.  Thus, most users will not ever
26   * directly interact with an Expression instance.  That said, Expressions may
27   * be executed independently of a Database instance if desired.
28   *
29   * @author James Ahlborn
30   */
31  public interface Expression
32  {
33  
34    /**
35     * Evaluates the expression and returns the result.
36     *
37     * @param ctx the context within which to evaluate the expression
38     *
39     * @return the result of the expression evaluation
40     */
41    public Object eval(EvalContext ctx);
42  
43    /**
44     * @return a detailed string which indicates how the expression was
45     *         interpreted by the expression evaluation engine.
46     */
47    public String toDebugString(LocaleContext ctx);
48  
49    /**
50     * @return a parsed and re-formated version of the expression.  This may
51     *         look slightly different than the original, raw string, although
52     *         it should be an equivalent expression.
53     */
54    public String toCleanString(LocaleContext ctx);
55  
56    /**
57     * @return the original, unparsed expression string.  This is the same as
58     *         the value which will be returned by {@link Object#toString}.
59     */
60    public String toRawString();
61  
62    /**
63     * @return {@code true} if this is a constant expression.  A constant
64     *         expression will always return the same result when invoked and
65     *         has no side effect.
66     */
67    public boolean isConstant();
68  
69    /**
70     * Adds any Identifiers from this expression to the given collection.
71     */
72    public void collectIdentifiers(Collection<Identifier> identifiers);
73  }