public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COLUMN_SEPARATOR
Default column separator for text files.
|
static String |
ENCODING
Default encoding, cf the second rule.
|
static String[] |
FORBIDDEN_CHARACTERS
Forbidden characters in file names.
|
static String |
LINE_SEPARATOR
The line separator.
|
static double |
MASS_PER_AA
The mass added per amino acid as part of the reference mass when
converting a tolerance in Dalton to ppm.
|
Constructor and Description |
---|
Util()
Empty default constructor.
|
Modifier and Type | Method and Description |
---|---|
static String |
color2Hex(Color color)
Converts a color to hex format for use in HTML tags.
|
static String |
color2Hex(int colorRGB)
Converts a color to hex format for use in HTML tags.
|
static boolean |
containsForbiddenCharacter(String string)
Indicates whether a string contains characters forbidden in file names.
|
static int |
convertBooleanToInteger(Boolean booleanToConvert)
Converts a boolean value to the corresponding integer value, 0 for false
and 1 for true.
|
static double |
floorDouble(double d,
int places)
Floors a double value to the wanted number of decimal places.
|
static Color |
getColor(int colorRGB)
Returns the color object corresponding to the given rgb representation.
|
static ArrayList<Integer> |
getIndexes(String bigString,
String smallString)
Returns at which indexes a small string can be found in a big string.
|
static int |
getOccurrence(String input,
char character)
Returns the occurrence of a character in a string.
|
static double |
getPpmError(double theoreticalMzValue,
double massError)
Returns the ppm value of the given mass error relative to its theoretical
m/z value.
|
static String |
getVersion()
Retrieves the version number set in the pom file.
|
static String |
keyValueToString(String key,
String value)
Returns a string in the form key(value).
|
static double |
readDoubleAsString(String doubleAsString)
Method for reading a double value as a string which uses either "," or
"." as the decimal symbol.
|
static String |
removeCharacters(String string,
char forbiddenCharacter)
Removes characters from a string.
|
static String |
removeCharacters(String string,
String[] forbiddenCharacters)
Removes characters from a string.
|
static String |
removeForbiddenCharacters(String string)
Removes the forbidden characters from a string.
|
static String |
removeSubString(String string,
String subString)
Removes characters from a string.
|
static String |
replaceAll(String string,
char a,
char b)
Replaces all characters equals to a by b in the given string.
|
static double |
roundDouble(double d,
int places)
Rounds a double value to the wanted number of decimal places.
|
static boolean |
sameLists(ArrayList<?> list1,
ArrayList<?> list2)
Convenience methods indicating whether the content of two lists have the
same content.
|
static boolean |
sendGAUpdate(String ua,
String action,
String label)
Function for sending event requests to Google analytics.
|
static void |
tableToFile(JTable table,
String separator,
ProgressDialogX progressDialog,
boolean removeHtml,
BufferedWriter writer)
Writes the table to a file as separated text.
|
static String |
tableToText(JTable table,
String separator,
ProgressDialogX progressDialog,
boolean removeHtml)
Returns the table as a separated text file.
|
public static final String[] FORBIDDEN_CHARACTERS
public static final String ENCODING
public static final String DEFAULT_COLUMN_SEPARATOR
public static final String LINE_SEPARATOR
public static final double MASS_PER_AA
public static String removeSubString(String string, String subString)
string
- the string of interestsubString
- the sub-string to removepublic static boolean sendGAUpdate(String ua, String action, String label)
ua
- tracking IDaction
- the actionlabel
- the labelpublic static String getVersion()
public static String removeCharacters(String string, char forbiddenCharacter)
string
- the string of interestforbiddenCharacter
- the character to removepublic static String removeCharacters(String string, String[] forbiddenCharacters)
string
- the string of interestforbiddenCharacters
- the characters to removepublic static String removeForbiddenCharacters(String string)
string
- the string of interestpublic static boolean containsForbiddenCharacter(String string)
string
- the string of interestpublic static String replaceAll(String string, char a, char b)
string
- the stringa
- ab
- bpublic static double roundDouble(double d, int places)
d
- the double to round ofplaces
- number of decimal places wantedpublic static double floorDouble(double d, int places)
d
- the double to floor ofplaces
- number of decimal places wantedpublic static double getPpmError(double theoreticalMzValue, double massError)
theoreticalMzValue
- the theoretical massmassError
- the mass errorpublic static String color2Hex(int colorRGB)
colorRGB
- the color in rgb representationpublic static String color2Hex(Color color)
color
- the color to convertpublic static Color getColor(int colorRGB)
colorRGB
- the color in rgb representationpublic static String tableToText(JTable table, String separator, ProgressDialogX progressDialog, boolean removeHtml)
table
- the table to turn in to textseparator
- the text separatorprogressDialog
- the progress dialogremoveHtml
- if true, HTML is converted to textpublic static void tableToFile(JTable table, String separator, ProgressDialogX progressDialog, boolean removeHtml, BufferedWriter writer) throws IOException
table
- the table to write to fileseparator
- the text separatorprogressDialog
- the progress dialogremoveHtml
- if true, HTML is converted to textwriter
- the writer where the file is to be writtenIOException
- if a problem occurs when writing to the filepublic static boolean sameLists(ArrayList<?> list1, ArrayList<?> list2)
list1
- the first listlist2
- the second listpublic static int getOccurrence(String input, char character)
input
- the string of interestcharacter
- the character to look forpublic static ArrayList<Integer> getIndexes(String bigString, String smallString)
bigString
- the big stringsmallString
- the small stringpublic static double readDoubleAsString(String doubleAsString) throws NumberFormatException
doubleAsString
- the double value as a stringNumberFormatException
- thrown if the double cannot be read as a
doublepublic static int convertBooleanToInteger(Boolean booleanToConvert)
booleanToConvert
- the boolean value to convertCopyright © 2021. All rights reserved.