public class CommonTools
extends java.lang.Object
This Class is used to provide helper methods which don't fit into any other SAS Common Utils Category.
Modifier and Type | Method and Description |
---|---|
static int |
calculateDistance(java.lang.String source,
java.lang.String target)
Calculates the string distance between source and target strings using
the Damerau-Levenshtein algorithm.
|
static int |
calculateDistanceIgnoreCase(java.lang.String source,
java.lang.String target)
Calculates the string distance between source and target strings using
the Damerau-Levenshtein algorithm.
|
static float |
cvt(float inputValue,
float inMin,
float inMax,
float outMin,
float outMax)
Converts an input value range to output value range lineary as depicted on the image below,
where the x axis shows the input value and the y axis the corresponding output value, with
each min and max values for input and output lasting from 0 to 1:
|
static boolean |
equals(double d1,
double d2)
Compares two double values for equality with a given precision.
|
static boolean |
equals(double d1,
double d2,
int precision)
Compares two double values for equality with a given precision.
|
static boolean |
equals(float f1,
float f2)
Compares two float values for equality with a given precision.
|
static boolean |
equals(float f1,
float f2,
int precision)
Compares two float values for equality with a given precision.
|
static float |
getTimeZoneBiasHours()
Gets the current offset between local time and UTC time, in hours.
|
static int |
getTimeZoneBiasMinutes()
Gets the current offset between local time and UTC time, in minutes.
|
static float |
smoothCvt(float inputValue,
float inMin,
float inMax,
float outMin,
float outMax)
Converts an input value range to output value range "smoothly", meaning that upper and lower
bound values will be reached progressively like shown in this image, where the x axis shows
the input value and the y axis the corresponding output value, with each min and max values
for input and output lasting from 0 to 1:
Note that the blue line shows the output of "smoothCvt", the black line is the corresponding output of " cvt(float, float, float, float, float) " for comparison. |
static float |
smoothCvt(float inputValue,
float inMin,
float inMax,
float outMin,
float outMax,
int smoothingFactor)
Converts an input value range to output value range "smoothly", meaning that upper and lower
bound values will be reached progressively like shown in this image, where the x axis shows
the input value and the y axis the corresponding output value, with each min and max values
for input and output lasting from 0 to 1:
The output of "smoothCvt" with the factors 0, 1, 2, 3, 4, 5, 6 and 7 is depicted by the black, blue, yellow, green, cyan, grey, brown and violet lines respectively. |
public static final float cvt(float inputValue, float inMin, float inMax, float outMin, float outMax)
inputValue
- the current input value (x axis) to be converted to output value (y axis)inMin
- the minimum input value (x axis) for conversion.
Any "inputValue" of or below "inMin" will cause the method to return "outMin".inMax
- the maximum input value (x axis) for conversion.
Any "inputValue" of or above "inMax" will cause the method to return "outMax".outMin
- the minimum output value (y axis) for conversion, corresponding to the
minimum input value (x axis) for conversion.outMax
- the maximum output value (y axis) for conversion, corresponding to the
maximum input value (x axis) for conversion.public static final float smoothCvt(float inputValue, float inMin, float inMax, float outMin, float outMax)
cvt(float, float, float, float, float)
" for comparison.
This method essentially is an alias of the method "smoothCvt(float, float, float, float, float, int)
"
with the "smoothingFactor" parameter set to 1.inputValue
- the current input value (x axis) to be converted to output value (y axis)inMin
- the minimum input value (x axis) for conversion.
Any "inputValue" of or below "inMin" will cause the method to return "outMin".inMax
- the maximum input value (x axis) for conversion.
Any "inputValue" of or above "inMax" will cause the method to return "outMax".outMin
- the minimum output value (y axis) for conversion, corresponding to the
minimum input value (x axis) for conversion.outMax
- the maximum output value (y axis) for conversion, corresponding to the
maximum input value (x axis) for conversion.public static final float smoothCvt(float inputValue, float inMin, float inMax, float outMin, float outMax, int smoothingFactor)
inputValue
- the current input value (x axis) to be converted to output value (y axis)inMin
- the minimum input value (x axis) for conversion.
Any "inputValue" of or below "inMin" will cause the method to return "outMin".inMax
- the maximum input value (x axis) for conversion.
Any "inputValue" of or above "inMax" will cause the method to return "outMax".outMin
- the minimum output value (y axis) for conversion, corresponding to the
minimum input value (x axis) for conversion.outMax
- the maximum output value (y axis) for conversion, corresponding to the
maximum input value (x axis) for conversion.smoothingFactor
- the factor setting how many times the smoothing gets applied.
This factor must not be negative.
A factor of "0" corresponds to the "cvt(float, float, float, float, float)
" method.
A factor of "1" corresponds to the "smoothCvt(float, float, float, float, float)
" method.public static int calculateDistance(java.lang.String source, java.lang.String target)
source
- The source String.target
- The target String.java.lang.IllegalArgumentException
- If either source or target is null.public static int calculateDistanceIgnoreCase(java.lang.String source, java.lang.String target)
source
- The source String.target
- The target String.java.lang.IllegalArgumentException
- If either source or target is null.public static final boolean equals(float f1, float f2)
equals(float, float, int)
" method with a precision of 7.f1
- First float to compare.f2
- Second float to compare.public static final boolean equals(float f1, float f2, int precision)
f1
- First float to compare.f2
- Second float to compare.precision
- Precision used for comparison. If both floats fall within 10-precision
of each other, they are considered equal.public static final boolean equals(double d1, double d2)
equals(double, double, int)
" method with a precision of 7.d1
- First double to compare.d2
- Second double to compare.public static final boolean equals(double d1, double d2, int precision)
d1
- First double to compare.d2
- Second double to compare.precision
- Precision used for comparison. If both doubles fall within 10-precision
of each other, they are considered equal.public static final int getTimeZoneBiasMinutes()
public static final float getTimeZoneBiasHours()