Class ExpressionUtils

java.lang.Object
org.mariuszgromada.math.mxparser.ExpressionUtils

final class ExpressionUtils extends Object
Utility methods used in Expression class
Version:
6.1.0
See Also:
  • Field Details

  • Constructor Details

    • ExpressionUtils

      ExpressionUtils()
  • Method Details

    • addUDFSpecificParserKeyWords

      static void addUDFSpecificParserKeyWords(List<KeyWord> keyWordsList)
    • addArgumentsKeyWords

      static void addArgumentsKeyWords(List<Argument> argumentsList, List<KeyWord> keyWordsList)
    • addFunctionsKeyWords

      static void addFunctionsKeyWords(List<Function> functionsList, List<KeyWord> keyWordsList)
    • addConstantsKeyWords

      static void addConstantsKeyWords(List<Constant> constantsList, List<KeyWord> keyWordsList)
    • addKeyWord

      static void addKeyWord(String wordString, String wordDescription, int wordId, String wordSyntax, String wordSince, int wordTypeId, List<KeyWord> keyWordsList)
    • addKeyWordUnicode

      static void addKeyWordUnicode(String wordString, String wordDescription, int wordId, String wordSyntax, String wordSince, int wordTypeId, boolean unicodeKeyWordsEnabled, List<KeyWord> keyWordsList)
    • addParserKeyWords

      static void addParserKeyWords(boolean parserKeyWordsOnly, boolean UDFExpression, boolean unicodeKeyWordsEnabled, List<KeyWord> keyWordsList)
    • getBaseKeyWordsList

      static List<KeyWord> getBaseKeyWordsList(boolean parserKeyWordsOnly, boolean UDFExpression, boolean unicodeKeyWordsEnabled)
    • makeAllParserKeyWords

      static void makeAllParserKeyWords()
    • makeParserKeyWords

      static List<KeyWord> makeParserKeyWords(boolean parserKeyWordsOnly, boolean UDFExpression, boolean unicodeKeyWordsEnabled)
    • makeParserKeyWords

      private static void makeParserKeyWords(boolean parserKeyWordsOnly, boolean UDFExpression, boolean unicodeKeyWordsEnabled, List<KeyWord> keyWordsList)
    • getFunctionParameters

      static List<FunctionParameter> getFunctionParameters(int pos, List<Token> tokensList)
      Returns list of the functions parameters.
      Parameters:
      pos - the function position
      tokensList - the tokens list
      Returns:
      the list of function parameters
      See Also:
    • cleanMinusMinus

      private static String cleanMinusMinus(String expressionString)
      Cleans "--" case considering defined parser keywords "-->", "invalid input: '<'--"
    • cleanExpressionString

      static String cleanExpressionString(String expressionString, boolean attemptToFixExpStrEnabled)
      Cleans blanks and other cases like "++', "+-", "-+", "--"
    • createExpressionDescription

      static String createExpressionDescription(String description, String expressionString)
    • getCopyOfInitialTokens

      static List<Token> getCopyOfInitialTokens(String expressionString, List<Token> initialTokens)
      Tokenizes expression string and returns tokens list, including: string, type, level.
      Returns:
      Copy of initial tokens.
      See Also:
    • getMissingUserDefinedArguments

      static String[] getMissingUserDefinedArguments(List<Token> tokens)
      Returns missing user defined arguments names, i.e. sin(x) + cos(y) where x and y are not defined function will return x and y.
      Returns:
      Array of missing user defined arguments names - distinct strings.
    • getMissingUserDefinedUnits

      static String[] getMissingUserDefinedUnits(List<Token> tokens)
      Returns missing user defined units names, i.e. 2*[w] + [q] where [w] and [q] are not defined function will return [w] and [q].
      Returns:
      Array of missing user defined units names - distinct strings.
    • getMissingUserDefinedFunctions

      static String[] getMissingUserDefinedFunctions(List<Token> tokens)
      Returns missing user defined functions names, i.e. sin(x) + fun(x,y) where fun is not defined function will return fun.
      Returns:
      Array of missing user defined functions names - distinct strings.
    • showKeyWords

      static void showKeyWords(List<KeyWord> keyWordsList)
    • getHelp

      static String getHelp(String query, List<KeyWord> keyWordsList, boolean addHeader, boolean addCaption, String caption)
    • getHelp

      static String getHelp(String query, List<KeyWord> keyWordsList)
    • getHelpAsCsv

      static String getHelpAsCsv(List<KeyWord> keyWordsList, String quote, String delimiter, boolean addHeader, String query)
    • buildHtmlTableRows

      private static void buildHtmlTableRows(List<KeyWord> keyWordsList, boolean addHeader, StringBuilder stringBuilder)
    • buildMarkdownTableRows

      private static void buildMarkdownTableRows(List<KeyWord> keyWordsList, boolean addHeader, StringBuilder stringBuilder)
    • makeJsonKeyValuePair

      private static String makeJsonKeyValuePair(String key, String value)
    • buildJsonRows

      private static void buildJsonRows(List<KeyWord> keyWordsList, StringBuilder stringBuilder)
    • buildHelpCaption

      private static String buildHelpCaption(String query)
    • selectCaption

      private static String selectCaption(String query, String caption)
    • makeCssClassDef

      private static String makeCssClassDef(String cssClass)
    • getHelpAsHtmlTable

      static String getHelpAsHtmlTable(List<KeyWord> keyWordsList, boolean addHeader, boolean addCaption, boolean addFigure, String query, String caption, String cssClass)
    • getHelpAsHtmlTable

      static String getHelpAsHtmlTable(List<KeyWord> keyWordsList, boolean addHeadline, String query)
    • getHelpAsMarkdownTable

      static String getHelpAsMarkdownTable(List<KeyWord> keyWordsList, String query)
    • getHelpAsMarkdownTable

      static String getHelpAsMarkdownTable(List<KeyWord> keyWordsList, boolean addHeader, boolean addCaption, String query, String caption)
    • getHelpAsJson

      static String getHelpAsJson(List<KeyWord> keyWordsList, boolean addCaption, String query, String caption)
    • buildHelpSearchLine

      private static String buildHelpSearchLine(KeyWord kw, boolean advancedSearch)
    • containsAdvancedSearchTag

      private static boolean containsAdvancedSearchTag(String query, String tag)
    • checkIfAdvancedSearch

      private static boolean checkIfAdvancedSearch(String query)
    • getKeyWords

      static List<KeyWord> getKeyWords(String query, List<KeyWord> keyWordsList)
      Returns list of keywords known to the parser
      Parameters:
      query - Give any string to filter list of keywords against this string. User more precise syntax: str=tokenString, desc=tokenDescription, syn=TokenSyntax, sin=tokenSince, wid=wordId, tid=wordTypeId to narrow the result.
      Returns:
      List of keywords known to the parser filter against query string.
      See Also:
    • showParsing

      static void showParsing(int lPos, int rPos, List<Token> tokensList)
      Shows parsing (verbose mode purposes).
    • showTokens

      static void showTokens(List<Token> tokensList)
    • tokenToString

      static String tokenToString(Token token)
    • tokensListToString

      static String tokensListToString(List<Token> tokensList)
    • evaluateTokensLevels

      static void evaluateTokensLevels(List<Token> initialTokens)
      Evaluates tokens levels
    • getNumeralSystemBaseFromBaseInd

      static int getNumeralSystemBaseFromBaseInd(String baseInd)
    • findNonNegativeMinimum

      static int findNonNegativeMinimum(int a, int b)
    • findNonNegativeMinimum

      static int findNonNegativeMinimum(int a, int b, int c)
    • cloneForThreadSafeArgumenstList

      static List<Argument> cloneForThreadSafeArgumenstList(Expression relatedExpressionThatInitiatedClone, List<Argument> argumentsListToClone, CloneCache cloneCache)
    • cloneForThreadSafeFunctionsList

      static List<Function> cloneForThreadSafeFunctionsList(Expression relatedExpressionThatInitiatedClone, List<Function> functionsListToClone, CloneCache cloneCache)
    • cloneForThreadSafeConstantsList

      static List<Constant> cloneForThreadSafeConstantsList(Expression relatedExpressionThatInitiatedClone, List<Constant> constantsListToClone, CloneCache cloneCache)