public class Utilities
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.Integer> |
asList(int[] align) |
static java.lang.String |
doubleToScientificString(double number,
int fractionDigits)
Returns the string representation of the given double value in normalized scientific notation.
|
static void |
dump(java.io.PrintWriter pw,
int padding,
java.lang.String string)
Dumps padded text.
|
static void |
dumpMemoryInfo(java.lang.String msg)
Dumps out memory information
|
static void |
floorData(float[] data,
float floor)
If a data point is below 'floor' make it equal to floor.
|
static boolean |
isCepstraFileBigEndian(java.lang.String filename)
Returns true if the given binary cepstra file is in big-endian format.
|
static java.lang.String |
join(java.util.List<java.lang.String> tokens) |
static void |
nonZeroFloor(float[] data,
float floor)
If a data point is non-zero and below 'floor' make it equal to floor
(don't floor zero values though).
|
static void |
normalize(float[] data)
Normalize the given data.
|
static void |
objectTracker(java.lang.String name,
int count)
utility method for tracking object counts
|
static java.lang.String |
pad(double val,
int minLength)
Pads with spaces or truncates the given double to guarantee that it is exactly the desired length.
|
static java.lang.String |
pad(int padding)
Returns a string with the given number of spaces.
|
static java.lang.String |
pad(int val,
int minLength)
Pads with spaces or truncates the given int to guarantee that it is exactly the desired length.
|
static java.lang.String |
pad(java.lang.String string,
int minLength)
Pads with spaces or truncates the given string to guarantee that it is exactly the desired length.
|
static java.lang.String |
pathJoin(java.lang.String path1,
java.lang.String path2)
Combines two paths without too much logic only cares about avoiding
double backslashes since they hurt some resource searches.
|
static float |
readLittleEndianFloat(java.io.DataInputStream dataStream)
Reads the next float from the given DataInputStream, where the data is in little endian.
|
static int |
readLittleEndianInt(java.io.DataInputStream dataStream)
Reads the next little-endian integer from the given DataInputStream.
|
static float |
swapFloat(float floatValue)
Byte-swaps the given float to the other endian.
|
static int |
swapInteger(int integer)
Byte-swaps the given integer to the other endian.
|
public static java.lang.String pad(int padding)
padding
- the number of spaces in the stringpublic static java.lang.String pad(java.lang.String string, int minLength)
string
- the string to be paddedminLength
- the desired length of the stringpublic static java.lang.String pad(int val, int minLength)
val
- the value to be paddedminLength
- the desired length of the stringpublic static java.lang.String pad(double val, int minLength)
val
- the value to be paddedminLength
- the desired length of the stringpublic static void dump(java.io.PrintWriter pw, int padding, java.lang.String string)
pw
- the stream to send the outputpadding
- the number of spaces in the stringstring
- the string to outputpublic static void objectTracker(java.lang.String name, int count)
name
- the name of the objectcount
- the count of objectspublic static void dumpMemoryInfo(java.lang.String msg)
msg
- addditional text for the dumppublic static java.lang.String doubleToScientificString(double number, int fractionDigits)
fractionDigits
argument gives the number of decimal digits in the fraction portion. For example, if
fractionDigits
is 4, then the 123450 will be "1.2345e+05". There will always be two digits in the
exponent portion, and a plus or minus sign before the exponent.number
- the double to convertfractionDigits
- the number of digits in the fraction part, e.g., 4 in "1.2345e+05".public static boolean isCepstraFileBigEndian(java.lang.String filename) throws java.io.IOException
filename
- the cepstra file namejava.io.IOException
- if something went wrongpublic static float readLittleEndianFloat(java.io.DataInputStream dataStream) throws java.io.IOException
dataStream
- the DataInputStream to read fromjava.io.IOException
- if something went wrongpublic static int readLittleEndianInt(java.io.DataInputStream dataStream) throws java.io.IOException
dataStream
- the DataInputStream to read fromjava.io.IOException
- if something went wrongpublic static int swapInteger(int integer)
integer
- the integer to swappublic static float swapFloat(float floatValue)
floatValue
- the float to swappublic static void floorData(float[] data, float floor)
data
- the data to floorfloor
- the floored valuepublic static void nonZeroFloor(float[] data, float floor)
data
- the data to floorfloor
- the floored valuepublic static void normalize(float[] data)
data
- the data to normalizepublic static java.lang.String join(java.util.List<java.lang.String> tokens)
public static java.util.List<java.lang.Integer> asList(int[] align)
public static java.lang.String pathJoin(java.lang.String path1, java.lang.String path2)
path1
- First path to joinpath2
- Second path to join