/*
Copyright (c) 2018 James Ahlborn
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Jackcess has support for evaluating Access expressions (beta support as of
* the 2.2.0 release). This functionality is currently disabled by default
* but can be globally enabled via the system property
* "com.healthmarketscience.jackcess.enableExpressionEvaluation" or
* selectively enabled on a per database basis using {@link com.healthmarketscience.jackcess.Database#setEvaluateExpressions(Boolean)}.
*
* The expression evaluation engine implementation does its best to follow all
* the warts and idiosyncracies of Access expression evaluation (both those
* that are documented as well as those discovered through experimentation).
* These include such things as value conversions, "Null" handling, rounding
* rules, and implicit interpretations of expression in certain contexts.
*
* Expressions can be used in a number of different places within an Access
* database. When enabled, Jackcess supports the following usage:
*
* - Default Values: When a row is added which has a
* {@code null} value for a field which has a default value
* expression defined, that expression will be evaluated and the
* result will be inserted for that field. Like an auto-generated
* id, the generated default value will be returned in the input
* row array.
* - Calculated Fields: In databases which support calculated
* fields, any input value for a calculated field will be ignored.
* Instead, the result of evaluating the calculated field
* expression will be inserted. Like an auto-generated id, the
* calculated value will be returned in the input row array.
* - Field Validation: Field validation rules will be
* evaluated whenever a field value is updated. If the rule fails,
* the update operation will fail. The failure message will
* specify which field's validation rule failed and include the
* custom validation rule message if defined.
* - Record Validation: Similar to field validation rules,
* record validation rules will be run for the entire record before
* update. Failures are handled in a similar manner.
*
*
* Supporting Classes
*
* The classes in this package make up the public api for expression handling
* in Jackcess. They generally fall into two categories:
*
* General Use Classes
*
*
* - {@link com.healthmarketscience.jackcess.expr.EvalConfig} allows for customization of the expression
* evaluation context for a given {@link com.healthmarketscience.jackcess.Database} instance.
* - {@link com.healthmarketscience.jackcess.expr.TemporalConfig} encapsulates date/time formatting options for
* expression evaluation.
* - {@link com.healthmarketscience.jackcess.expr.NumericConfig} encapsulates number formatting options for
* expression evaluation.
* - {@link com.healthmarketscience.jackcess.expr.FunctionLookup} provides a source for {@link com.healthmarketscience.jackcess.expr.Function} instances
* used during expression evaluation.
* - {@link com.healthmarketscience.jackcess.expr.EvalException} wrapper exception thrown for failures which occur
* during expression evaluation.
* - {@link com.healthmarketscience.jackcess.expr.ParseException} wrapper exception thrown for failures which
* occur during expression parsing.
*
*
* Advanced Use Classes
*
*
* - {@link com.healthmarketscience.jackcess.expr.EvalContext} encapsulates all shared state for expression
* parsing and evaluation.
* - {@link com.healthmarketscience.jackcess.expr.Expression} provides an executable handle to an actual
* Access expression.
* - {@link com.healthmarketscience.jackcess.expr.Function} provides an invokable handle to external functionality
* to an expression.
* - {@link com.healthmarketscience.jackcess.expr.Identifier} identifies a database entity (e.g. the name of a
* database field).
* - {@link com.healthmarketscience.jackcess.expr.Value} represents a typed primitive value.
*
*
* Function Support
*
* Jackcess supports many of the standard Access functions. The following
* tables list the (hopefully) current status of support built into Jackcess.
*
* Conversion
*
*
* Function | Supported |
* Asc | Y |
* AscW | Y |
* Chr | Y |
* ChrW | Y |
* EuroConvert | |
* FormatCurrency | |
* FormatDateTime | |
* FormatNumber | |
* FormatPercent | |
* GUIDFromString | |
* Hex[$] | Y |
* Nz | Y |
* Oct[$] | Y |
* Str[$] | Y |
* StringFromGUID | |
* Val | Y |
* CBool | Y |
* CByte | Y |
* CCur | Y |
* CDate | Y |
* CVDate | Y |
* CDbl | Y |
* CDec | Y |
* CInt | Y |
* CLng | Y |
* CSng | Y |
* CStr | Y |
* CVar | Y |
*
*
* Date/Time
*
*
* Function | Supported |
* Day | Y |
* Date | Y |
* DateAdd | Y |
* DateDiff | |
* DatePart | Y |
* DateSerial | Y |
* DateValue | Y |
* Hour | Y |
* Minute | Y |
* Month | Y |
* MonthName | Y |
* Now | Y |
* Second | Y |
* Time | Y |
* Timer | Y |
* TimeSerial | Y |
* TimeValue | Y |
* Weekday | Y |
* WeekdayName | Y |
* Year | Y |
*
*
* Financial
*
*
* Function | Supported |
* DDB | Y |
* FV | Y |
* IPmt | Y |
* NPer | Y |
* Pmt | Y |
* PPmt | Y |
* PV | Y |
* Rate | Y |
* SLN | Y |
* SYD | Y |
*
*
* Inspection
*
*
* Function | Supported |
* IsDate | Partial |
* IsEmpty | |
* IsError | |
* IsMissing | |
* IsNull | Y |
* IsNumeric | Y |
* IsObject | |
* TypeName | Y |
* VarType | Y |
*
*
* Math
*
*
* Function | Supported |
* Abs | Y |
* Atn | Y |
* Cos | Y |
* Exp | Y |
* Int | Y |
* Fix | Y |
* Log | Y |
* Rnd | Y |
* Round | Y |
* Sgn | Y |
* Sin | Y |
* Sqr | Y |
* Tan | Y |
*
*
* Program Flow
*
*
* Function | Supported |
* Choose | Y |
* IIf | Y |
* Switch | Y |
*
*
* Text
*
*
* Function | Supported |
* Format[$] | |
* InStr | Y |
* InStrRev | Y |
* LCase[$] | Y |
* Left[$] | Y |
* Len | Y |
* LTrim[$] | Y |
* RTrim[$] | Y |
* Trim[$] | Y |
* Mid[$] | Y |
* Replace | Y |
* Right[$] | Y |
* Space[$] | Y |
* StrComp | Y |
* StrConv[$] | Partial |
* String[$] | Y |
* StrReverse | Y |
* UCase[$] | Y |
*
*
*
*
*/
package com.healthmarketscience.jackcess.expr;