public class SQUtils
extends java.lang.Object
Constructor and Description |
---|
SQUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addSeparator(javax.swing.JToolBar toolBar)
Adds the separator.
|
static java.lang.String |
changeFirstCharacterToUppercase(java.lang.String text)
Change first character to uppercase.
|
static boolean |
checkWorkDirectoryIsWritable(java.lang.String path)
Check work directory is writable.
|
static void |
clearDirectory(java.io.File dir)
Clear directory.
|
static java.lang.String |
d2(double value)
D2.
|
static java.lang.String |
d2(float value)
D2.
|
static java.lang.String |
d2WithPlType(java.lang.Double value,
java.lang.String plType)
D2 with pl type.
|
static SQOrder |
deepClone(SQOrder o)
Deep clone.
|
static SQOrderList |
deepClone(SQOrderList o)
Deep clone.
|
static <T> T |
deepClone(T o)
Deep clone.
|
static boolean |
deleteDirectory(java.lang.String path)
Delete directory.
|
static int |
factorial(int number)
Factorial.
|
static java.math.BigInteger |
factorialBig(int n)
Factorial big.
|
static byte[] |
fileToBytes(java.io.File file)
File to bytes.
|
static java.lang.String |
fileToString(java.io.File file)
File to string.
|
static void |
forceOpenUrlInDefaultWebBrowser(java.lang.String url,
java.awt.Component parentComponent)
Force open url in default web browser.
|
static boolean |
getBool(org.jdom2.Element elValues,
java.lang.String name,
boolean defaultValue)
Gets the bool.
|
static byte |
getByte(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the byte.
|
static byte |
getByteFromInt(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the byte from int.
|
static double |
getDouble(org.jdom2.Element elValues,
java.lang.String name,
float defaultValue)
Gets the double.
|
static java.lang.String |
getExtension(java.lang.String name)
Gets the extension.
|
static java.io.File |
getFirstFileFromDir(java.io.File dir)
Gets the first file from dir.
|
static float |
getFloat(org.jdom2.Element elValues,
java.lang.String name,
float defaultValue)
Gets the float.
|
static int |
getInt(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the int.
|
static long |
getLong(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the long.
|
static javax.swing.JMenu |
getMenuByName(javax.swing.JMenuBar menuBar,
java.lang.String menuName)
function returns top menu with given name or null if it doesn't exist.
|
static int |
getNumberOfLinesInFile(java.io.File file)
Gets the number of lines in file.
|
static short |
getShort(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the short.
|
static short |
getShortFromInt(org.jdom2.Element elValues,
java.lang.String name,
int defaultValue)
Gets the short from int.
|
static long[] |
getTimeRangeOfOrders(SQOrderList orders)
Gets the time range of orders.
|
static java.lang.String |
getUrlContent(java.lang.String url)
Gets the url content.
|
static byte[] |
inputStreamToBytes(java.io.InputStream is)
Input stream to bytes.
|
static void |
inputStreamToFile(java.io.InputStream inputStream,
java.io.File file)
Input stream to file.
|
static java.lang.String |
inputStreamToString(java.io.InputStream is)
Input stream to string.
|
static boolean |
isListContainsKey(java.lang.String list,
java.lang.String key)
Checks if is list contains key.
|
static java.lang.String |
joinStringList(java.util.List<java.lang.String> list,
java.lang.String separator)
Join string list.
|
static java.lang.String |
joinStrings(java.lang.String... constants)
Join strings.
|
static double[] |
listToDoubleArray(java.util.ArrayList<java.lang.Double> valueList)
List to double array.
|
static java.lang.String |
listToString(java.util.ArrayList<java.lang.String> valueList)
List to string.
|
static java.lang.String[] |
listToStringArray(java.util.ArrayList<java.lang.String> valueList)
List to string array.
|
static byte[] |
loadDataFromServer(java.lang.String url)
Load data from server.
|
static java.lang.String |
md5CheckSum(byte[] bytes)
Md5 check sum.
|
static void |
openUrlInDefaultWebBrowser(java.lang.String url,
java.awt.Component parentComponent)
Open url in default web browser.
|
static double |
parseDoubleValueWithK(java.lang.String value)
Parses the double value with k.
|
static double |
parsePrice(java.lang.String doubleStrIn)
Parses the price.
|
static java.lang.String |
printValueWithPlType(java.lang.String number,
java.lang.String plType)
Prints the value with pl type.
|
static java.lang.String |
randomString()
Random string.
|
static java.lang.String |
readFirstLine(java.io.File file)
Read first line.
|
static java.lang.String |
readLastLine(java.io.File file)
Read last line.
|
static java.lang.String |
replaceLast(java.lang.String string,
java.lang.String from,
java.lang.String to)
Replace last.
|
static double |
round(double value,
int decimals)
Round.
|
static double |
round2(double value)
Round2.
|
static double |
roundDown(double value,
int decimals)
Round down.
|
static double |
safeDivide(double f1,
double f2)
Safe divide.
|
static java.lang.String |
saveFileAs(byte[] data,
java.lang.String destDir,
java.lang.String fileName)
Save file as.
|
static void |
showExceptionDialog(java.lang.Exception ex)
Show exception dialog.
|
static void |
showExceptionDialog(java.lang.Exception ex,
java.lang.String title)
Show exception dialog.
|
static void |
showExceptionDialog(java.lang.Exception ex,
java.lang.String title,
java.awt.Component parentComponent)
Show exception dialog.
|
static void |
showExceptionDialog(java.lang.String msg)
Show exception dialog.
|
static void |
showExceptionDialog(java.lang.String msg,
java.lang.String title)
Show exception dialog.
|
static void |
stringToFile(java.io.File file,
java.lang.String str)
String to file.
|
static org.jdom2.Document |
stringToXml(java.lang.String xml)
String to xml.
|
static java.lang.String |
stripExtension(java.lang.String name)
Strip extension.
|
static java.lang.String |
timeToString(int s)
Time to string.
|
static java.lang.String |
toDoubleString(double value,
int decimals)
To double string.
|
static void |
xmlToFile(java.io.File file,
org.jdom2.Document doc)
Xml to file.
|
public static void openUrlInDefaultWebBrowser(java.lang.String url, java.awt.Component parentComponent)
url
- the urlparentComponent
- the parent componentpublic static void forceOpenUrlInDefaultWebBrowser(java.lang.String url, java.awt.Component parentComponent)
url
- the urlparentComponent
- the parent componentpublic static byte[] fileToBytes(java.io.File file) throws java.lang.Exception
file
- the filejava.lang.Exception
- the exceptionpublic static java.lang.String md5CheckSum(byte[] bytes) throws java.lang.Exception
bytes
- the bytesjava.lang.Exception
- the exceptionpublic static java.lang.String fileToString(java.io.File file) throws java.lang.Exception
file
- the filejava.lang.Exception
- the exceptionpublic static void xmlToFile(java.io.File file, org.jdom2.Document doc) throws java.lang.Exception
file
- the filedoc
- the docjava.lang.Exception
- the exceptionpublic static void stringToFile(java.io.File file, java.lang.String str) throws java.lang.Exception
file
- the filestr
- the strjava.lang.Exception
- the exceptionpublic static java.io.File getFirstFileFromDir(java.io.File dir) throws java.lang.Exception
dir
- the dirjava.lang.Exception
- the exceptionpublic static java.lang.String getExtension(java.lang.String name)
name
- the namepublic static java.lang.String stripExtension(java.lang.String name)
name
- the namepublic static short getShortFromInt(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static byte getByteFromInt(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static short getShort(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static byte getByte(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static int getInt(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static long getLong(org.jdom2.Element elValues, java.lang.String name, int defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static float getFloat(org.jdom2.Element elValues, java.lang.String name, float defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static double getDouble(org.jdom2.Element elValues, java.lang.String name, float defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static boolean getBool(org.jdom2.Element elValues, java.lang.String name, boolean defaultValue)
elValues
- the el valuesname
- the namedefaultValue
- the default valuepublic static java.lang.String changeFirstCharacterToUppercase(java.lang.String text)
text
- the textpublic static java.lang.String d2WithPlType(java.lang.Double value, java.lang.String plType)
value
- the valueplType
- the pl typepublic static java.lang.String printValueWithPlType(java.lang.String number, java.lang.String plType)
number
- the numberplType
- the pl typepublic static java.lang.String toDoubleString(double value, int decimals)
value
- the valuedecimals
- the decimalspublic static double round2(double value)
value
- the valuepublic static double roundDown(double value, int decimals)
value
- the valuedecimals
- the decimalspublic static double round(double value, int decimals)
value
- the valuedecimals
- the decimalspublic static javax.swing.JMenu getMenuByName(javax.swing.JMenuBar menuBar, java.lang.String menuName)
menuBar
- the menu barmenuName
- the menu namepublic static double parseDoubleValueWithK(java.lang.String value) throws java.lang.Exception
value
- the valuejava.lang.Exception
- the exceptionpublic static void showExceptionDialog(java.lang.Exception ex, java.lang.String title)
ex
- the extitle
- the titlepublic static void showExceptionDialog(java.lang.Exception ex, java.lang.String title, java.awt.Component parentComponent)
ex
- the extitle
- the titleparentComponent
- the parent componentpublic static void showExceptionDialog(java.lang.Exception ex)
ex
- the expublic static void showExceptionDialog(java.lang.String msg)
msg
- the msgpublic static void showExceptionDialog(java.lang.String msg, java.lang.String title)
msg
- the msgtitle
- the titlepublic static boolean isListContainsKey(java.lang.String list, java.lang.String key)
list
- the listkey
- the keypublic static java.lang.String replaceLast(java.lang.String string, java.lang.String from, java.lang.String to)
string
- the stringfrom
- the fromto
- the topublic static boolean deleteDirectory(java.lang.String path)
path
- the pathpublic static java.lang.String randomString()
public static java.lang.String timeToString(int s)
s
- the spublic static java.lang.String d2(float value)
value
- the valuepublic static java.lang.String d2(double value)
value
- the valuepublic static long[] getTimeRangeOfOrders(SQOrderList orders)
orders
- the orderspublic static double safeDivide(double f1, double f2)
f1
- the f1f2
- the f2public static java.lang.String joinStringList(java.util.List<java.lang.String> list, java.lang.String separator)
list
- the listseparator
- the separatorpublic static java.lang.String joinStrings(java.lang.String... constants)
constants
- the constantspublic static int factorial(int number)
number
- the numberpublic static java.math.BigInteger factorialBig(int n)
n
- the npublic static java.lang.String getUrlContent(java.lang.String url) throws java.lang.Exception
url
- the urljava.lang.Exception
- the exceptionpublic static java.lang.String inputStreamToString(java.io.InputStream is) throws java.lang.Exception
is
- the isjava.lang.Exception
- the exceptionpublic static byte[] loadDataFromServer(java.lang.String url) throws java.lang.Exception
url
- the urljava.lang.Exception
- the exceptionpublic static byte[] inputStreamToBytes(java.io.InputStream is) throws java.lang.Exception
is
- the isjava.lang.Exception
- the exceptionpublic static void inputStreamToFile(java.io.InputStream inputStream, java.io.File file) throws java.lang.Exception
inputStream
- the input streamfile
- the filejava.lang.Exception
- the exceptionpublic static java.lang.String saveFileAs(byte[] data, java.lang.String destDir, java.lang.String fileName) throws java.lang.Exception
data
- the datadestDir
- the dest dirfileName
- the file namejava.lang.Exception
- the exceptionpublic static void clearDirectory(java.io.File dir)
dir
- the dirpublic static SQOrder deepClone(SQOrder o)
o
- the opublic static SQOrderList deepClone(SQOrderList o)
o
- the opublic static <T> T deepClone(T o)
T
- the generic typeo
- the opublic static double parsePrice(java.lang.String doubleStrIn) throws java.lang.Exception
doubleStrIn
- the double str injava.lang.Exception
- the exceptionpublic static void addSeparator(javax.swing.JToolBar toolBar)
toolBar
- the tool barpublic static boolean checkWorkDirectoryIsWritable(java.lang.String path)
path
- the pathpublic static org.jdom2.Document stringToXml(java.lang.String xml) throws java.lang.Exception
xml
- the xmljava.lang.Exception
- the exceptionpublic static int getNumberOfLinesInFile(java.io.File file)
file
- the filepublic static java.lang.String readLastLine(java.io.File file) throws java.lang.Exception
file
- the filejava.lang.Exception
- the exceptionpublic static java.lang.String readFirstLine(java.io.File file) throws java.lang.Exception
file
- the filejava.lang.Exception
- the exceptionpublic static double[] listToDoubleArray(java.util.ArrayList<java.lang.Double> valueList)
valueList
- the value listpublic static java.lang.String[] listToStringArray(java.util.ArrayList<java.lang.String> valueList)
valueList
- the value listpublic static java.lang.String listToString(java.util.ArrayList<java.lang.String> valueList)
valueList
- the value list