Package parser.methods.ext
Class Utils
java.lang.Object
parser.methods.ext.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkAtLeastArgs
(String name, int count, List tokens) helper method to unify argument check on standart functionsstatic boolean
checkOnlyNumbers
(List<String> tokens) static void
checkTokensCount
(String title, int expected, List tokens) static String
connectTokens
(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 int
getFirstBigDeciamalTokenAsInt
(List<BigDecimal> tokens) static int
getFirstStringTokenAsInt
(List<String> tokens) static BigDecimal
gsum
(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 BigDecimal
sum
(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
Will remove toRemove elements from BOTH sides of tokens, leaving at least minLength of elements in place. It always take from both sides, or nto at all -
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
-