Package com.healthmarketscience.jackcess.expr

Jackcess has support for evaluating Access expressions. This functionality is enabled by default (as of the 3.5.0 release) but can be globally disabled via the system property "com.healthmarketscience.jackcess.enableExpressionEvaluation" or selectively disabled on a per database basis using 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 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

  • EvalConfig allows for customization of the expression evaluation context for a given Database instance.
  • TemporalConfig encapsulates date/time formatting options for expression evaluation.
  • NumericConfig encapsulates number formatting options for expression evaluation.
  • FunctionLookup provides a source for Function instances used during expression evaluation.
  • EvalException wrapper exception thrown for failures which occur during expression evaluation.
  • ParseException wrapper exception thrown for failures which occur during expression parsing.

Advanced Use Classes

  • EvalContext encapsulates all shared state for expression parsing and evaluation.
  • Expression provides an executable handle to an actual Access expression.
  • Function provides an invokable handle to external functionality to an expression.
  • Identifier identifies a database entity (e.g. the name of a database field).
  • 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

FunctionSupported
AscY
AscWY
ChrY
ChrWY
EuroConvert
FormatCurrencyY
FormatDateTimeY
FormatNumberY
FormatPercentY
GUIDFromString
Hex[$]Y
NzY
Oct[$]Y
Str[$]Y
StringFromGUID
ValY
CBoolY
CByteY
CCurY
CDateY
CVDateY
CDblY
CDecY
CIntY
CLngY
CSngY
CStrY
CVarY

Date/Time

FunctionSupported
DayY
Date Y
DateAddY
DateDiffY
DatePartY
DateSerialY
DateValueY
HourY
MinuteY
MonthY
MonthNameY
NowY
SecondY
TimeY
TimerY
TimeSerialY
TimeValueY
WeekdayY
WeekdayNameY
YearY

Financial

FunctionSupported
DDBY
FVY
IPmtY
NPerY
PmtY
PPmtY
PVY
RateY
SLNY
SYDY

Inspection

FunctionSupported
IsDatePartial
IsEmpty
IsError
IsMissing
IsNullY
IsNumericY
IsObject
TypeNameY
VarTypeY

Math

FunctionSupported
AbsY
AtnY
CosY
ExpY
IntY
FixY
LogY
RndY
RoundY
SgnY
SinY
SqrY
TanY

Program Flow

FunctionSupported
ChooseY
IIfY
SwitchY

Text

FunctionSupported
Format[$]Y
InStrY
InStrRevY
LCase[$]Y
Left[$]Y
LenY
LTrim[$]Y
RTrim[$]Y
Trim[$]Y
Mid[$]Y
ReplaceY
Right[$]Y
Space[$]Y
StrCompY
StrConv[$]Partial
String[$]Y
StrReverseY
UCase[$]Y