Class ChemicalTermsExpressionUtils


  • public class ChemicalTermsExpressionUtils
    extends Object
    Validates chemical terms expressions.
    Author:
    Tim Dudgeon
    • Constructor Detail

      • ChemicalTermsExpressionUtils

        public ChemicalTermsExpressionUtils​(int jchemTableType)
        Creates a new instance of ChemicalTermsExpressionUtils.
        Parameters:
        jchemTableType - the type of table for which this validator is constructed
    • Method Detail

      • isLogSExpression

        public static boolean isLogSExpression​(String formula)
        Parameters:
        formula - chemical terms field formula
        Returns:
        true if given formula contains logS() 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 validate
        returnType - expected type to which the expression will evaluate
        allowEmpty - whether the empty expression string is also valid
        entity - 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)