|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compomics.util.Util
public class Util
Includes general help methods that are used by the other classes.
Field Summary | |
---|---|
static java.lang.String[] |
forbiddenCharacters
Forbidden characters in file names. |
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static java.lang.String |
color2Hex(java.awt.Color color)
Converts a color to hex format for use in HTML tags. |
static boolean |
containsForbiddenCharacter(java.lang.String string)
Indicates whether a string contains characters forbidden in file names. |
static void |
copyFile(java.io.File in,
java.io.File out)
Copy the content of one file to another. |
static boolean |
deleteDir(java.io.File dir)
Deletes all files and subdirectories under dir. |
static java.lang.String |
getExtension(java.io.File file)
Returns the extensions of a file. |
static java.lang.String |
getFileName(java.io.File file)
An OS independent getName alternative. |
static java.lang.String |
getFileName(java.lang.String filePath)
An OS independent getName alternative. |
static int |
getNumberOfLines(java.io.File file)
Returns the number of lines in the given file. |
static double |
getPpmError(double theoreticalMzValue,
double massError)
Returns the ppm value of the given mass error relative to its theoretical m/z value. |
static java.io.File |
getUserSelectedFile(java.awt.Component parent,
java.lang.String aFileEnding,
java.lang.String aFileFormatDescription,
java.lang.String aDialogTitle,
java.lang.String lastSelectedFolder,
boolean openDialog)
Returns the file selected by the user, or null if no file was selected. |
static java.lang.String |
removeExtension(java.lang.String fileName)
Removes the extension from a file name or path. |
static java.lang.String |
removeForbiddenCharacters(java.lang.String string)
Removes the forbidden characters from a string |
static double |
roundDouble(double d,
int places)
Rounds a double value to the wanted number of decimal places. |
static boolean |
sameLists(java.util.ArrayList<java.lang.Integer> list1,
java.util.ArrayList<java.lang.Integer> list2)
Convenience methods indicating whether the content of two lists have the same content. |
static void |
tableToFile(javax.swing.JTable table,
java.lang.String separator,
ProgressDialogX progressDialog,
boolean removeHtml,
java.io.BufferedWriter writer)
Writes the table to a file as separated text. |
static java.lang.String |
tableToText(javax.swing.JTable table,
java.lang.String separator,
ProgressDialogX progressDialog,
boolean removeHtml)
Returns the table as a separated text file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] forbiddenCharacters
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static java.lang.String removeForbiddenCharacters(java.lang.String string)
string
- the string of interest
public static boolean containsForbiddenCharacter(java.lang.String string)
string
- the string of interest
public static double roundDouble(double d, int places)
d
- the double to round ofplaces
- number of decimal places wanted
public static boolean deleteDir(java.io.File dir)
dir
-
public static double getPpmError(double theoreticalMzValue, double massError)
theoreticalMzValue
- the theoretical massmassError
- the mass error
public static java.lang.String color2Hex(java.awt.Color color)
color
- the color to convert
public static java.lang.String getFileName(java.lang.String filePath)
filePath
- the file path as a string
public static java.lang.String getFileName(java.io.File file)
file
- the file
public static java.lang.String getExtension(java.io.File file)
file
- the file
public static java.lang.String removeExtension(java.lang.String fileName)
fileName
- the file name
public static java.io.File getUserSelectedFile(java.awt.Component parent, java.lang.String aFileEnding, java.lang.String aFileFormatDescription, java.lang.String aDialogTitle, java.lang.String lastSelectedFolder, boolean openDialog)
parent
- the parent dialog or frameaFileEnding
- the file type, e.g., .txtaFileFormatDescription
- the file format description, e.g., (Mascot
Generic Format) *.mgfaDialogTitle
- the title for the dialoglastSelectedFolder
- the last selected folderopenDialog
- if true an open dialog is shown, false results in a
save dialog
public static java.lang.String tableToText(javax.swing.JTable table, java.lang.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 text
public static void tableToFile(javax.swing.JTable table, java.lang.String separator, ProgressDialogX progressDialog, boolean removeHtml, java.io.BufferedWriter writer) throws java.io.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 written
java.io.IOException
public static void copyFile(java.io.File in, java.io.File out) throws java.io.IOException
in
- the file to copy fromout
- the file to copy to
java.io.IOException
public static int getNumberOfLines(java.io.File file) throws java.io.IOException
file
- the file to find the number of lines in
java.io.IOException
public static boolean sameLists(java.util.ArrayList<java.lang.Integer> list1, java.util.ArrayList<java.lang.Integer> list2)
list1
- the first listlist2
- the second list
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |