- JavaDoc

# Jep Java

- Introduction
- Basic Usage
- Variables
- Data types
- Operators
- Functions
- Custom Functions
- BigDecimal
- FAQ
- Migration
- Version History

# Advanced Features

- Manipulating Expressions
- Components
- Configurable Parser
- Serialization
- Threads
- Localization
- Grammar
- Other advanced features

# Migrating to Jep 3

Jep 3 brings a number of significant changes with it. So if you are currently running version 2.x, you will need to make some changes to your code. We recommend using Jep 3 as described in this documentation, but we have also provided compatibility classes that ease the transition.

This page gives you tips on performing the migration with or without the compatibility classes.

## Changes that affect migration

The package structure has changed significantly. All classes that were previously in the org.nfunk.jep package are now located under com.singularsys.jep. The organization of the classes has changed significantly as well.

- The main Jep class is now located at com.singularsys.jep.Jep.
- The `parseExpression(String)` and `getValue()` methods are now replaced by `parse(String)` and `evaluateD()`. The `getValueAsObject()` method is now replaced by `evaluate()`.
- The `hasError()` and `getErrorInfo()` methods have been replaced by exceptions thrown by the`parse(String)` and `evaluate()` methods. The`parse(String)` method throws `ParseExceptions` and the`evaluate()` method throws `EvaluationExceptions`.
- The default constructor `Jep()` initializes the `StandardComponents` set which include all the standard functions and constants, no call to `addStandardFunctions()` or `addStandardConstants()` is necessary.
- The default settings of the allowUndeclared and allowAssignment options have changed from `false` to `true`.
- All function classes now throw `EvaluationException` instead of `ParseException`.
- The `addComplex()` method has been removed - the i constant and the complex related methods are now added in `StandardVariableTable` and `StandardFunctionTable` when Jep is constructed with the default options (using `StandardComponents`).
- The `SymbolTable` class has been renamed to VariableTable.
- The `addStandardFunctions()` method has been removed. Standard functions are included by default.

## Migrating without compatibility classes

You will need to make changes to your code according to the changes mentioned above. Take special note of the new defaults since they will not necessarily be apparent when compiling your code.

## Migrating with compatibility classes

The compatibility classes include the old org.nfunk.jep.JEP class as well as the old examples and tests. The org.nfunk.jep.JEP implementation uses a Jep 3 instance from com.singularsys.jep.Jep internally to perform the parsing and evaluation. Note that the Jep class has been deprecated and may not be included in future versions of the Jep package.

If you only use the JEP class in your code, your program might compile without making any changes. But if you rely on other classes that have been moved to the new package location, you will need to at least change import statements.

## Conversion script

The Apache Ant script `./bin/import.xml` contains a set of Ant tasks to perform most changes necessary to convert Jep 2.x code to run under Jep 3.x.

Open the file in a text editor and set the `fromdir` and `todir` directories to the directory where your code resides and the directory to which you would like the modified files to be output. The conversion is a two step process. First run the `import` task to copy the files from `fromdir` to `todir`, then run `replace` to perform a set of search/replace operations on the files in `todir`.

The `clean` target will remove all files from `todir`. Use with care.