Trees are everywhere in computing, representing more complex than a list or sequence. The former is two dimensional, while the other is linear or one dimensional.
Examples of trees in computing:
- JSON
- XML documents
- Computer languages
Before expanding on their utility consider the following key classes/interfaces.
An agnostic AST that supports complex expressions, including computation, logical operands and invoking user defined functions.
- Immutable
- Functional
- Fully traversable
- May be evaluated - see below
An abstraction holding a number value within an Expression, which available choices including:
BigDecimalslower but more precision and variousRoundingoptions.doublefaster but limited 64-bit precisionfloatfastest but limited 32-bit precision TODO
A context accompanies the evaluation of an Expression and provides context aware values and behaviours.
- A powerful construct that supports many values and behaviours that modify evaluation of an expression.
- Provides the preferred
ExpressionNumberto use at evaluation time, during number / calculations.
Extends LocaleContext, which provides locale aware values such as decimal point, currency, day names and more.
A function provides an independent function which describes
- name The name, which is used within expressions.
- return type The return type
- parameters All the parameters including their name, cardinality and type.
- purity Useful to determine whether the computed value can be cached, Within a spreadsheet this can help improve speed by avoiding unnecessary recalculations, because component values have or will never change.
- basic
- currencyCode
- expression
- expressionNumberFunction
- eval
- fake
- lambda
- locale
- localeLanguageTag
- node
- nodeName
- nullFunction
- typeName
The accompanying ExpressionEvaluationContext when executing a function uses the function metadata to convert values to the target type as necessary, supporting a type-safe but dynamic conversions as necessary.
The following function projects hold many functions, and can be used in any Expression context including Spreadsheets.
- boolean
- datetime
- engineering
- net
- number
- number-trigonometry
- spreadsheet
- stat
- string
- walkingkooka-spreadsheet-expression-function Contains additional functions that can be executed within a spreadsheet expression context.
A Node is a unit within a tree, coming in two forms, leaves and parent nodes with the former never having children
while the later possibly containing zero or more children. Numerous Node implementations include:
- Expression
- File A file system abstraction, execute xpath over directories and files.
- Json Json objects.
- Patch JSON Patch
- Pojo Java POJOs with highlight support
- Xml Xml documents
A selector represents a query which may be used to match Node within a node graph, equivalent to
XPATH
- Almost identical in syntax and effective functionality to that of XPATH.
- May be executed using any of the many
Nodeimplementations.
A NodePointer supports path navigation/selection over a Node and is similar in syntax and features
to JSON POINTER. Like Select is can operate against any of the above
mentioned Node implementations.
A NodePatch is an equivalent technology similar to json-patch but supports all Node
technologies.