Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldobapvicjr committed Jun 26, 2024
1 parent 9b2bd22 commit 4c4a8b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
15 changes: 15 additions & 0 deletions docs/concepts/datatypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ EvalEx supports the following data types:
| ARRAY | java.util.List |
| STRUCTURE | java.util.Map |
| EXPRESSION_NODE | com.ezylang.evalex.parser.ASTNode |
| BINARY[^1] | java.lang.Object |
| NULL | null |

[^1]: Since 3.3.0

Data is stored in an _EvaluationValue_, which holds the value and the data type.

### NUMBER
Expand Down Expand Up @@ -214,6 +217,18 @@ Note that the above expression is not evaluated as "2 * 4 + 3", which would resu
Instead, the sub-expression "4 + 3" is calculated first, when it comes to finding the value of the
variable _b_. Resulting in calculation of "2 * 7", which is 14.


### BINARY

A representation for an undefined (raw), non-null object that could not fit in any of the previous
data types.

This allows for special functions to handle any object type.

The binary data type is **disabled** by default and can be enabled by setting a dedicated property
in the [Configuration](../configuration/configuration.html).


### NULL

A representation for _null_ objects.
Expand Down
3 changes: 3 additions & 0 deletions docs/concepts/parsing_evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ _EvaluationValue_ will be of one of the types:
- NUMBER - If the expression resulted in a number.
- STRING - If the expression resulted in a string.
- BOOLEAN - If the expression resulted in a boolean value.
- DATE_TIME - If the expression resulted in a date/time value.
- DURATION - If the expression resulted in a duration value.
- ARRAY - If the expression resulted in an array.
- STRUCTURE - If the expression resulted in a structure.
- BINARY - If the expression could not be converted to any of the previous types.

The _EvaluationValue_ has methods to check and retrieve/convert the evaluation value.

Expand Down
10 changes: 10 additions & 0 deletions docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ExpressionConfiguration configuration=ExpressionConfiguration.builder()
.powerOfPrecedence(OperatorIfc.OPERATOR_PRECEDENCE_POWER)
.stripTrailingZeros(true)
.structuresAllowed(true)
.binaryAllowed(false)
.singleQuoteStringLiteralsAllowed(false)
.zoneId(ZoneId.systemDefault())
.build();
Expand All @@ -45,6 +46,15 @@ Specifies if the array index function is allowed (default is true). If set to fa
will throw a _ParseException_, if there is a '[' is encountered in the expression and also no
operator or function is defined for this character.

### Binary allowed

Specifies if the binary[^1] (raw) data type is allowed for expressions that can not be converted to any
known data type.

See chapter [Data Types](../concepts/datatypes.html) for details.

[^1]: Since 3.3.0

### Data Accessor

The Data Accessor is responsible for storing and retrieving variable values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public class ExpressionConfiguration {
@Builder.Default private final boolean structuresAllowed = true;

/**
* Support for the BINARY (undefined) data type is allowed or not.
* Support for the binary (undefined) data type is allowed or not.
*
* @since 3.3.0
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ezylang/evalex/data/EvaluationValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public enum DataType {
EXPRESSION_NODE,
/** A null value */
NULL,
/** Undefined type, stored as an {@link Object}. */
/** Raw (undefined) type, stored as an {@link Object}. */
BINARY
}

Expand Down Expand Up @@ -222,7 +222,7 @@ public static EvaluationValue structureValue(Map<?, ?> value) {
}

/**
* Creates a new binary value.
* Creates a new binary (raw) value.
*
* @param value The Object to use.
* @return the new binary value.
Expand Down

0 comments on commit 4c4a8b6

Please sign in to comment.