Package com.im.df.util
Class ChemicalTermsExpressionUtils
- java.lang.Object
-
- com.im.df.util.ChemicalTermsExpressionUtils
-
public class ChemicalTermsExpressionUtils extends Object
Validates chemical terms expressions.- Author:
- Tim Dudgeon
-
-
Constructor Summary
Constructors Constructor Description ChemicalTermsExpressionUtils(int jchemTableType)
Creates a new instance of ChemicalTermsExpressionUtils.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
containsExpressionValue(String expr, Map<String,String> map)
static int
getJchemTableTypeForCT(com.im.df.api.ddl.DFEntity entity)
static int
getJchemTableTypeForCT(com.im.df.api.ddl.DFField field)
Determines the JChem table type which should be used for validation of CT expression.static boolean
isLogSExpression(String formula)
String
validateExpression(String expr, Class<?> returnType, boolean allowEmpty, com.im.df.api.capabilities.StructureEntityCapability entity)
Validate the chemical terms expression.
-
-
-
Method Detail
-
isLogSExpression
public static boolean isLogSExpression(String formula)
- Parameters:
formula
- chemical terms field formula- Returns:
true
if given formula containslogS()
chemical terms expression- Since:
- 18.21.0
-
validateExpression
public String validateExpression(String expr, Class<?> returnType, boolean allowEmpty, com.im.df.api.capabilities.StructureEntityCapability entity)
Validate the chemical terms expression. Tries to evaluate the expression twice for methane. If the expression has a bad syntax or evaluating the expression generates an exception resulting from use of an unlicensed plugin then an error message is returned.- Parameters:
expr
- expression to validatereturnType
- expected type to which the expression will evaluateallowEmpty
- whether the empty expression string is also validentity
- parent entity capability of the field where expression belongs to- Returns:
- Null for a valid expression or an error message that explains why the expression is invalid.
-
containsExpressionValue
public static boolean containsExpressionValue(String expr, Map<String,String> map)
-
getJchemTableTypeForCT
public static int getJchemTableTypeForCT(com.im.df.api.ddl.DFField field)
Determines the JChem table type which should be used for validation of CT expression. If the field doesn't belong to a JChem entity, a warning is logged and the default table type is returned.- Parameters:
field
- field to examine- Returns:
- the field's JChem table type or default
-
getJchemTableTypeForCT
public static int getJchemTableTypeForCT(com.im.df.api.ddl.DFEntity entity)
-
-