Class Utils
java.lang.Object
parser.methods.ext.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckAtLeastArgs(String name, int count, List tokens) helper method to unify argument check on standart functionsstatic booleancheckOnlyNumbers(List<String> tokens) static voidcheckTokensCount(String title, int expected, List tokens) static StringconnectTokens(List<String> tokens) static int[]static int[]static List<BigDecimal> evaluateSingleToken(List<String> tokens) This is method, which allows the client functions to workaround the https://github.com/gbenroscience/ParserNG/issues/25 Once the issue is fixed, this method will simply change to convert list of strings to list of big decimals withot any evaluationsstatic intgetFirstBigDeciamalTokenAsInt(List<BigDecimal> tokens) static intgetFirstStringTokenAsInt(List<String> tokens) static BigDecimalgsum(List<BigDecimal> l) static List<BigDecimal> stringsToBigDecimals(List<String> tokens) Converts list of strings to list of big decimalsstatic List<BigDecimal> stringsToBigDecimals(List<String> tokens, int headCut) Converts list of strings to list of big decimals, and custs firststatic BigDecimalsum(List<BigDecimal> l) static List<BigDecimal> tokensToNumbers(List<String> tokens) static List<?> Will remove toRemove elements from BOTH sides of tokens, leaving at least minLength of elements in place.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
stringsToBigDecimals
Converts list of strings to list of big decimals -
stringsToBigDecimals
Converts list of strings to list of big decimals, and custs first- Parameters:
headCut- members to cut of frombthebegining
-
trimList
-
sum
- Returns:
- the sum of all elements in the data set with BigDecimal precission
-
gsum
- Returns:
- the geomethrical (multiplied) sum of all elements in the data set
-
getFirstBigDeciamalTokenAsInt
-
getFirstStringTokenAsInt
-
checkOnlyNumbers
-
evaluateSingleToken
This is method, which allows the client functions to workaround the https://github.com/gbenroscience/ParserNG/issues/25 Once the issue is fixed, this method will simply change to convert list of strings to list of big decimals withot any evaluations- Parameters:
tokens- list of numbers or parts of mathematical expresion- Returns:
- the converted numbers or evaluated expression as number.
-
tokensToNumbers
-
connectTokens
-
checkAtLeastArgs
helper method to unify argument check on standart functions- Parameters:
name-count-tokens-- Throws:
RuntimeException
-
decimalAndFractionalParts
-
decimalAndFractionalParts
-
checkTokensCount
-