With Jep 3.0, a new component architecture was introduced. It allows pluggable components, giving tremendous flexibility for customizing Jep. A total of 9 components are employed, as shown below.
For each of the components you can either use a built-in implementation, or you can create your own implementation.
The roles of these components are:
A set of components can be bundled together in a ComponentSet and the Jep(ComponentSet cs) constructor used to create a Jep instance with a given set. Individual components can be set using jep.setComponent(JepComponent comp).
Jep comes with many components built-in. When creating a
Jep instance using the default constructor, the
StandardComponents set is loaded. The standard components include the StandardParser and the FastEvaluator. In addition to those, the ConfigurableParser and the RealEvaluator are also available. The following listing gives an overview of the components available in Jep 3.
StandardComponents (the default component set)
BigDecimalComponents (see Big Decimals)
doublearithmetic and functions)
The architecture also allows for new custom components can be loaded. These should implement the appropriate interface or extend the appropriate class. Two methods are common to all components (see JepComponent):
void init(Jep jep)this is called after the Jep instance is constructed or when a component is changed and is used to inform all active components about the configuration. A do nothing method is typical.
public JepComponent getLightWeightInstance()in multi-threaded environments with multiple Jep instances some components can be shared, but other need a separate instance per thread. This method returns an appropriate instance, which can be
nullor a new instance. See Serialization for details.