Class UtilFns
- java.lang.Object
-
- org.apache.poi.ss.formula.functions.UtilFns
-
public class UtilFns extends Object
- Author:
- ashish
-
-
Constructor Summary
Constructors Constructor Description UtilFns()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
basisToDouble(int basis, Date settle, Date maturi, int dsm)
static ComplexEx
cToComplex(org.apache.commons.math3.complex.Complex c, String suffix)
Convert the complex to complex.static Long
dateToDays(Date date)
Returns number of days since 1900-1-0; i.e.static Date
daysToDate(int arg)
Returns aDate
of a given number of days since 1900-1-1 (inclusive); i.e.static int
dsm(Date settle, Date maturi, int basis)
static String
format(ComplexEx c)
format Complex number to match Excel formatstatic org.apache.commons.math3.stat.regression.SimpleRegression
getRegre(double[] xs, double[] ys)
Return a commons math Regression classstatic org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
getStats(double[] d)
Return a commons math DescriptiveStatistics class which is contructed from double array dstatic String
padZero(String num, int places)
static String
replaceiToi1(String complex, String suffix)
Replace the String i to i1.static boolean
stringToBoolean(ValueEval arg)
static Date
stringToDate(ValueEval arg)
Convert a String to Datestatic Double
stringToDouble(String str, boolean nullable)
Convert a string to doublestatic double
toDouble15(double dbl, int roundingMode)
static double[]
toDoubleArray(Object[] objs)
Convert an object array to a double arraystatic double[]
toDoubleArray(List ls)
Convert a list to a double arraystatic double[][]
toDoubleMatrix(ValueEval arg, int srcRowIndex, int srcColumnIndex)
static int[]
toIntArray(Object[] objs)
Convert an object array to an int arraystatic List
toList(ValueEval[] args, int srcRowIndex, int srcColumnIndex)
static ComplexEx
validateComplex(String complex)
Validate given String value, return associated complex.
-
-
-
Method Detail
-
stringToDate
public static Date stringToDate(ValueEval arg) throws EvaluationException
Convert a String to Date- Parameters:
arg
- - input value- Returns:
- Date value
- Throws:
EvaluationException
-
stringToBoolean
public static boolean stringToBoolean(ValueEval arg) throws EvaluationException
- Throws:
EvaluationException
-
dsm
public static int dsm(Date settle, Date maturi, int basis) throws EvaluationException
- Throws:
EvaluationException
-
dateToDays
public static Long dateToDays(Date date)
Returns number of days since 1900-1-0; i.e. 1900-1-0 returns 0 and 1900-1-1 returns 1.- Parameters:
date
- the date to be calculated.- Returns:
- number of days since 1900-1-0; i.e. 1900-1-0 returns 0 and 1900-1-1 returns 1.
-
padZero
public static String padZero(String num, int places) throws EvaluationException
- Throws:
EvaluationException
-
replaceiToi1
public static String replaceiToi1(String complex, String suffix)
Replace the String i to i1.- Parameters:
complex
- String of complex.- Returns:
- String of a complex.
-
validateComplex
public static ComplexEx validateComplex(String complex) throws EvaluationException
Validate given String value, return associated complex. returnErrorEval.NUM_ERROR
if complex is not a format of complex.- Parameters:
complex
- String value to be validated.- Returns:
- complex value.
- Throws:
EvaluationException
-
cToComplex
public static ComplexEx cToComplex(org.apache.commons.math3.complex.Complex c, String suffix)
Convert the complex to complex.- Parameters:
c
- the complex.suffix
- the suffix.- Returns:
- the complex.
-
format
public static String format(ComplexEx c)
format Complex number to match Excel format- Parameters:
c
- the complex number- Returns:
- the formated Complex number that match Excel format
-
toIntArray
public static int[] toIntArray(Object[] objs) throws EvaluationException
Convert an object array to an int array- Parameters:
objs
- an object array- Returns:
- int array
- Throws:
EvaluationException
-
toDoubleMatrix
public static double[][] toDoubleMatrix(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException
- Throws:
EvaluationException
-
toDouble15
public static double toDouble15(double dbl, int roundingMode)
-
toList
public static List toList(ValueEval[] args, int srcRowIndex, int srcColumnIndex) throws EvaluationException
- Throws:
EvaluationException
-
stringToDouble
public static Double stringToDouble(String str, boolean nullable) throws EvaluationException
Convert a string to double- Parameters:
str
- - input valuenullable
- - flag to indicate the return could be null or not- Returns:
- double value
- Throws:
EvaluationException
-
toDoubleArray
public static double[] toDoubleArray(List ls) throws EvaluationException
Convert a list to a double array- Parameters:
ls
- a list- Returns:
- a double array
- Throws:
EvaluationException
-
toDoubleArray
public static double[] toDoubleArray(Object[] objs) throws EvaluationException
Convert an object array to a double array- Parameters:
objs
- an object array- Returns:
- double array
- Throws:
EvaluationException
-
getStats
public static org.apache.commons.math3.stat.descriptive.DescriptiveStatistics getStats(double[] d)
Return a commons math DescriptiveStatistics class which is contructed from double array d- Parameters:
d
- samples- Returns:
- a DescriptiveStatistics class which is contructed from double array d
-
getRegre
public static org.apache.commons.math3.stat.regression.SimpleRegression getRegre(double[] xs, double[] ys) throws EvaluationException
Return a commons math Regression class- Parameters:
xs
- x-coordinatesys
- y-coordinates- Returns:
- a commons math Regression class
- Throws:
EvaluationException
-
-