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 javax.script.Bindings; 20 21 /** 22 * EvalContext encapsulates all shared state for expression parsing and 23 * evaluation. It provides a bridge between the expression execution engine 24 * and the current Database. 25 * 26 * @author James Ahlborn 27 */ 28 public interface EvalContext extends LocaleContext 29 { 30 /** 31 * @param seed the seed for the random value, following the rules for the 32 * "Rnd" function 33 * @return a random value for the given seed following the statefulness 34 * rules for the "Rnd" function 35 */ 36 public float getRandom(Integer seed); 37 38 /** 39 * @return the expected type of the result value for the current expression 40 * evaluation (for "default value" and "calculated" expressions) 41 */ 42 public Value.Type getResultType(); 43 44 /** 45 * @return the value of the "current" column (for "field validator" 46 * expressions) 47 */ 48 public Value getThisColumnValue(); 49 50 /** 51 * @return the value of the entity identified by the given identifier (for 52 * "calculated" and "row validator" expressions) 53 */ 54 public Value getIdentifierValue(Identifier identifier); 55 56 /** 57 * @return the currently configured Bindings (from the {@link EvalConfig}) 58 */ 59 public Bindings getBindings(); 60 61 /** 62 * @return the value of the current key from the currently configured 63 * {@link Bindings} 64 */ 65 public Object get(String key); 66 67 /** 68 * Sets the value of the given key to the given value in the currently 69 * configured {@link Bindings}. 70 */ 71 public void put(String key, Object value); 72 }