@OpenApiAll public class Utilities extends CameoUtilities
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addHttpParameter(java.lang.String parameters,
java.lang.String parameter,
java.lang.String value)
Adds http parameter to given parameters string
|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
java.util.Collection<? extends T> v,
boolean allowDublication)
|
static <T> java.util.Collection<T> |
append(java.util.Collection<T> source,
java.util.Iterator<? extends T> it,
boolean allowDublication)
|
static boolean |
areChildrenDisabled(javax.swing.JMenu menu)
Are all children disabled?
|
static int |
arrayHash(byte[] array)
Calculate hash code for array of bytes
|
static int |
calculateTextWidth(java.lang.String text,
java.awt.FontMetrics metrics,
int numberOfLines)
Calculates possible text longest text width of the given text splitted into lines.
|
static java.lang.String |
checkIsInstallRootWritable(com.nomagic.runtime.RuntimeEnvironment runtime)
Get message for install root read only error.
|
static java.lang.String |
checkIsInstallRootWritable(com.nomagic.runtime.RuntimeEnvironment runtime,
boolean skipWinUAC)
Get message for install root read only error.
|
static boolean |
checkProperty(java.util.Properties properties,
java.lang.String property,
boolean defaultValue) |
static boolean |
checkResolvableException(boolean rule)
if rule is false and it's DEVELOPER mode throws
IllegalStateException |
static boolean |
checkSystemProperty(java.lang.String property,
boolean defaultValue)
Checks given system (boolean) property value
|
static java.lang.String |
clearAllLine(java.lang.String src,
java.lang.String trash)
Removes all trash from string
|
static java.lang.String |
clearFromEveryLine(java.lang.String text,
java.lang.String mask)
Divides given string into lines and from every line beginning
and end removes all chars from given string mask.
|
static java.lang.String |
clearLine(java.lang.String line,
java.lang.String trash)
removes from line ends wanted characters
|
static int |
collectInteger(byte[] bytes)
Makes int value from array of bytes
|
static boolean |
compareFiles(java.io.File f1,
java.io.File f2)
Compares two files
|
static boolean |
compareStreams(java.io.InputStream oldStr,
java.io.InputStream newStr)
Compares two input streams.
|
static byte[] |
compressData(byte[] data)
Compresses specified data using gzip output stream and returns the result as bytes array.
|
static byte[] |
compressData(byte[] data,
java.lang.String zipEntryName)
Compresses specified data using zip output stream and returns the result as bytes array.
|
static java.lang.String |
concatHttpParameter(java.lang.String parameters1,
java.lang.String parameters2)
Concatenate given http parameters
|
static java.lang.String |
constructHttpParameter(java.lang.String parameter,
java.lang.String value)
Constructs http parameter
|
static boolean |
contains(java.util.Iterator it,
java.lang.Object o)
Deprecated.
|
static boolean |
containSameElements(java.util.Collection<?> collection1,
java.util.Collection<?> collection2) |
static boolean |
containsAny(java.util.Collection location,
java.util.Collection what)
|
static boolean |
containsNonDirectory(java.util.List<java.io.File> fileList) |
static boolean |
containsOnlyFiles(java.util.List list)
Indicates if given list contains only file objects.
|
static boolean |
contentEquals(java.io.InputStream input1,
java.io.InputStream input2)
Compare content of two streams.
|
static void |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copies all bytes from InputStream into OutputStream.
|
static void |
copy(java.io.InputStream input,
java.io.OutputStream output,
java.util.zip.Checksum checksum)
Copies all bytes from InputStream into OutputStream
|
static void |
copy(java.io.InputStream input,
java.io.OutputStream output,
long crc,
boolean closeInput)
Copies all bytes from InputStream into OutputStream.
|
static boolean |
copyDirectory(java.io.File source,
java.io.File destination)
Copy all directory recursively
|
static boolean |
copyFile(java.io.File source,
java.io.File destination)
Copy source file to destination file.
|
static boolean |
copyFile(java.lang.String sourceName,
java.lang.String dstName)
Copy source file to destination file.
|
static int |
countOccurrences(java.lang.String string,
char c)
Returns the number of times the character c appears in a string.
|
static java.awt.Rectangle |
coverRectangle(java.awt.Rectangle inner,
java.awt.Rectangle outer)
Moves outer rectangle in such way that it must cover inner one (if outer is smaller than inner resizes outer).
|
static <E extends java.util.Collection> |
createCollection(java.lang.Class<E> collection,
java.util.Iterator it)
Deprecated.
|
static java.awt.Cursor |
createCursor(javax.swing.Icon icon,
java.awt.Point pt,
java.lang.String cursorName)
Creates the cursor for given icon.
|
static java.awt.Cursor |
createCursor(java.awt.Image image,
java.awt.Point pt,
java.lang.String cursorName)
Creates the cursor for given image.
|
static java.awt.Rectangle |
createRectFromList(java.util.List<java.awt.Point> v)
Creates rectangle from vector of points.
|
static java.lang.String |
createStringRepresentation(java.util.Collection value) |
static byte[] |
decodeBase64(java.lang.String s)
Decode string using Base64 encoding.
|
static java.util.List<java.awt.Point> |
deepPointsClone(java.util.List<java.awt.Point> v)
Makes a deep clone of vector that contains points.
|
static java.util.List<java.awt.Point> |
deepPointsClone(java.util.List<java.awt.Point> v,
boolean cloneList)
Makes a deep clone of vector that contains points.
|
static void |
deleteDirContent(java.io.File f)
Removes given directory contents.
|
static void |
deleteTree(java.io.File f)
Removes given directory and all its contents.
|
static void |
deleteTreeOnExit(java.io.File f)
Removes given file (directory and all its contents) on exit.
|
static byte[] |
distributeInteger(int intValue,
int size)
Distributes integer intValue into array of bytes.
|
static void |
dumpThreads()
Dumps all threads to system out.
|
static void |
dumpThreads(java.io.PrintStream out)
Dumps all threads to given stream.
|
static java.lang.String |
encodeBase64(byte[] abyte0)
Encodes data using base64 encoding.
|
static <T> void |
ensureObjectIsInCollection(java.util.Collection<T> collection,
T object)
Ensures an object is in given collection.
|
static <T> java.util.Set<T> |
excludeCommonElements(java.util.Collection<T> first,
java.util.Collection<T> second)
Creates result collection which contains not common elements from two arguments
|
static java.util.Collection<java.lang.String> |
extractZip(java.io.InputStream is,
java.lang.String dstDir,
java.util.Collection<java.lang.String> onlyTheseEntries,
java.util.Collection<java.lang.String> skipTheseEntries)
Extracts files from Zip archive
|
static void |
extractZip(java.util.zip.ZipFile zipFile,
java.lang.String dstDir)
Extracts files from Zip archive
|
static java.awt.Rectangle |
fitInRectangle(java.awt.Rectangle small,
java.awt.Rectangle big)
recalculate bounds to fit in rectangle
|
static java.lang.String |
getAsString(javax.swing.KeyStroke e)
Constructs the string representation of the given key stroke.
|
static java.lang.String |
getAsStringKeyStrokes(java.util.List shortcuts,
java.lang.String bracketFirst,
java.lang.String bracketSecond)
Constructs the string representation of the given key strokes.
|
static byte[] |
getBytes(java.lang.String str)
Returns bytes of string.
|
static java.lang.String |
getClassName(java.lang.Class clazz)
Get class name.
|
static java.lang.String |
getCurrentDateFormatted() |
static <E> int |
getDistance(E from,
E to,
java.util.function.Function<E,java.util.Collection<E>> connectedNodes)
Calculate minimal distance in graph.
|
static java.lang.String |
getFileExtension(java.io.File file)
Get The given file extension.
|
static java.lang.String |
getFileExtension(java.lang.String fileName)
Get the given file extension.
|
static java.lang.String |
getFileName(java.lang.String text) |
static java.lang.String |
getFileWithoutExtension(java.lang.String filename)
Returns file name without extension (removes chars from last "." to end of string)
|
static java.lang.String |
getFileWitoutExtention(java.lang.String filename)
Deprecated.
type error in name
|
static ResizableIcon |
getGrayIcon(javax.swing.Icon icon)
Deprecated.
|
static ResizableIcon |
getGrayIcon(javax.swing.Icon icon,
java.awt.Component component)
Deprecated.
|
static java.lang.String |
getHtmlPage(java.lang.String pageHttpAddress,
java.lang.String parameters,
ProxyServerData proxy)
Deprecated.
use
HttpUtilities.getHtmlPage(String, String, com.nomagic.utils.http.HttpProxyServerData, int) |
static javax.swing.JMenuItem |
getItemWithText(javax.swing.JPopupMenu menu,
java.lang.String text)
Returns inner component (not recursively) with given text.
|
static java.lang.String |
getSHA1(byte[] buffer) |
static java.text.DateFormat |
getSystemDateFormat(int style)
Returns system date format.
|
static java.lang.String |
getTempDir()
Returns System temp directory.
|
static java.lang.String |
getThreadsInfo() |
static java.lang.String |
getVersionFromInternal(int internal)
Convert internal MagicDraw style version to human version in 17.0.2 format.
|
static java.lang.String |
getVersionFromInternal(java.lang.String internal)
Convert internal MagicDraw style version to human version in 17.0.2 format.
|
static boolean |
hasExtension(java.lang.String name,
java.util.List extensions)
Checks if given file name has one of given file extensions.
|
static boolean |
hasExtension(java.lang.String name,
java.lang.String extension)
Checks if given file name has given file extension.
|
static boolean |
hasModalDialogs(java.awt.Window window)
Checks recursively if given window has modal dialog as child (or window itself is a modal dialog)
|
static java.lang.String |
implode(java.util.Collection collection,
java.lang.String delimiter)
Returns a new String composed of copies of the collection elements joined together with a copy of the specified delimiter.
|
static java.lang.String |
implode(java.lang.String[] values,
java.lang.String delimiter)
Deprecated.
Use
String.join(CharSequence, CharSequence...) |
static java.lang.String |
insertPeriodically(java.lang.String text,
java.lang.String insert,
int period) |
static java.lang.String |
insertSeparators(char[] chars,
java.lang.String separator,
int groupSize)
Constructs string from arrays of chars.
|
static void |
invokeAndWaitOnDispatcher(java.lang.Runnable r)
Executes given runnable on event dispatcher.
|
static void |
invokeAndWaitOnDispatcherEvenInterrupted(java.lang.Runnable r)
Executes given runnable on event dispatcher.
|
static void |
invokeLaterAfterCondition(java.lang.Runnable runnable,
java.util.function.Supplier<java.lang.Boolean> condition)
Invokes runnable latter after condition is satisfied.
|
static void |
invokeLaterAfterCondition(java.lang.Runnable runnable,
java.util.function.Supplier<java.lang.Boolean> condition,
int conditionCheckAttemptCount)
Invokes runnable latter after condition is satisfied.
|
static void |
invokeOnDispatcherOrLater(java.lang.Runnable r)
If this thread is event dispatcher, than direct calls "run", else invoke on invoke later
|
static boolean |
isAlphaNumeric(java.lang.String str) |
static boolean |
isFileNameValid(java.lang.String fileName)
Returns if given file name is valid to be created.
|
static boolean |
isHTMLText(java.lang.String s)
Check the given string to see if it should trigger the
html rendering logic.
|
static boolean |
isNameValid(java.lang.String name) |
static boolean |
isPrintableChar(char c)
Checks if char is printable or not.
|
static boolean |
isStreamEmpty(java.net.URL url)
Check if it is possible to open a stream from a given URL and that stream is not empty
|
static boolean |
isUseProxy(ProxyServerData proxy)
Checks if use proxy server according given proxy server data
|
static boolean |
isValidKeyCode(int keyCode)
Checks if given code is correct one or not.
|
static void |
main(java.lang.String[] args) |
static void |
makeEqual(java.util.List destination,
java.util.List source)
Make destination the same as source with minimum changes to destination
|
static boolean |
match(java.lang.String pattern,
java.lang.String string)
algorithm for searching with wildcards.
|
static boolean |
matchEmpty(java.lang.String patter,
java.lang.String string)
Matches empty string also
|
static <T> void |
merge(java.util.List<T> source,
java.util.List<T> v)
Merges two vector.
|
static <T> java.util.List<T> |
mergeLists(java.util.List<T> l1,
java.util.List<T> l2)
Merges two lists into newly created one.
|
static void |
normalize(java.awt.Rectangle rect)
normalizes rectangle mRectToDraw;
|
static void |
normalize(java.awt.Rectangle rectangle,
java.awt.Point firstCorner,
java.awt.Point secondCorner)
Normalizes rectangle; Calculates rectangle size and location using firstCorner and secondCorner.
|
static java.util.Collection |
notDublicatedList(java.util.Collection col)
Deprecated.
|
static java.net.HttpURLConnection |
openHttpURLConnection(java.lang.String pageHttpAddress,
ProxyServerData proxyServerData)
Deprecated.
use
HttpJavaUtilities.openHttpURLConnection(String, String, com.nomagic.utils.http.HttpProxyServerData, int, long) |
static java.lang.String[] |
parseExceptQuotes(java.lang.String cmd)
parses string by standard tokens, except parts wrapped in quotes
|
static void |
printSpace(int number)
Prints a number of spaces to the system out without new line.
|
static java.lang.String |
readFileSkipFirstLines(java.io.File file,
int n)
Reads a file to string and skips a specified number of lines from the beginning.
|
static java.lang.String |
removeComments(java.lang.String body)
Removes / * * / comments from body.
|
static java.lang.String |
removeExtension(java.lang.String name,
java.util.Collection<java.lang.String> extensions)
Removes file extension form given file name.
|
static java.lang.String |
removeFromLine(java.lang.String line,
java.lang.String trash)
Removes from line trash line
|
static java.lang.String |
removeNewLines(java.lang.String string)
Removes new lines from the string.
|
static java.lang.String |
removeNonUtf8CompliantCharacters(java.lang.String inString) |
static java.lang.String |
removeSeparators(java.lang.String str,
java.lang.String separator)
Removes separators from specified str
|
static java.lang.String |
replace(java.lang.String src,
java.lang.String pattern,
java.lang.String replaceWith)
Replaces string fragment with another string
|
static java.lang.String |
replaceEpsString(java.lang.String aStr)
Replace special char for Eps format string
|
static java.lang.String |
reverseString(java.lang.String source)
Given a string, returns a string with reversed characters.
|
static void |
sendHttpParameters(java.net.HttpURLConnection connection,
java.lang.String parameters)
Deprecated.
use
HttpJavaUtilities.sendHttpParameters(java.net.HttpURLConnection, String) |
static void |
sortStrings(java.util.Vector elem)
Sorts elements in strings' vector
|
static java.lang.String[] |
splitString(java.lang.String str,
java.lang.String delimiter,
boolean returnDelimiter)
Splits string
|
static void |
swapVector(java.util.List v)
Deprecated.
use
Collections.reverse(java.util.List<?>) |
static void |
synchronizeDirectories(java.io.File source,
java.io.File destination)
Synchronize two directories.
|
static byte[] |
toByteArray(java.io.InputStream stream)
Copies the given file into the array of bytes.
|
static byte[] |
toByteArray(java.lang.String bytes)
Returns byte array from string formatted in toString(byte[]) method.
|
static java.lang.String |
toString(byte[] data)
Returns string representation of the given byte array.
|
static java.lang.String |
toString(java.util.Collection<java.lang.String> strings)
Get String representation of given strings collection
|
static java.lang.String |
toString(java.io.InputStream inputStream)
Get String representation of inputStream
|
static java.lang.String |
trim(java.lang.String src,
java.lang.String trashBegin,
java.lang.String trashEnd)
Removes from begin and end given Strings.
|
static byte[] |
uncompressData(byte[] data)
Uncompresses specified data using gzip input stream and returns the result as bytes array.
|
static void |
zipDir(java.lang.String dir2zip,
java.util.zip.ZipOutputStream zos)
Compress specified directory recursively to the specified stream.
|
copy, isEqual, isEqual, replaceNewLine, toString
public static boolean hasExtension(java.lang.String name, java.util.List extensions)
public static boolean hasExtension(java.lang.String name, java.lang.String extension)
public static java.lang.String removeExtension(java.lang.String name, java.util.Collection<java.lang.String> extensions)
public static java.lang.String createStringRepresentation(java.util.Collection value)
public static java.util.List<java.awt.Point> deepPointsClone(java.util.List<java.awt.Point> v)
v
- List of point.public static java.util.List<java.awt.Point> deepPointsClone(java.util.List<java.awt.Point> v, boolean cloneList)
v
- List of point.cloneList
- True if clone to new list.public static java.lang.String replace(java.lang.String src, java.lang.String pattern, java.lang.String replaceWith)
src
- Source string.pattern
- String pattern.replaceWith
- The another string.public static boolean match(java.lang.String pattern, java.lang.String string)
pattern
- The given pattern.string
- String.public static boolean matchEmpty(java.lang.String patter, java.lang.String string)
patter
- The given pattern.string
- The given string.public static void sortStrings(java.util.Vector elem)
elem
- The given vector.public static java.lang.String clearLine(java.lang.String line, java.lang.String trash)
line
- The given line.trash
- characters as string.public static java.lang.String clearAllLine(java.lang.String src, java.lang.String trash)
src
- String that be removed trashtrash
- Trash string.public static java.lang.String removeFromLine(java.lang.String line, java.lang.String trash)
line
- the given line.trash
- characters as string.public static <T> void merge(java.util.List<T> source, java.util.List<T> v)
source
- source list.v
- The given vector.@Deprecated public static <T> java.util.Collection<T> append(java.util.Collection<T> source, java.util.Collection<? extends T> v, boolean allowDublication)
@Deprecated public static <T> java.util.Collection<T> append(java.util.Collection<T> source, java.util.Iterator<? extends T> it, boolean allowDublication)
@Deprecated public static boolean contains(java.util.Iterator it, java.lang.Object o)
CollectionUtils.contains(java.util.Iterator, Object)
@Deprecated public static boolean containsAny(java.util.Collection location, java.util.Collection what)
public static java.lang.String clearFromEveryLine(java.lang.String text, java.lang.String mask)
text
- The given string.mask
- The given string mark.public static int countOccurrences(java.lang.String string, char c)
string
- The given stringc
- characterpublic static java.lang.String removeNonUtf8CompliantCharacters(java.lang.String inString)
public static java.awt.Rectangle fitInRectangle(java.awt.Rectangle small, java.awt.Rectangle big)
small
- Small rectanglebig
- Big rectanglepublic static boolean containsOnlyFiles(java.util.List list)
list
- list to check.public static boolean containsNonDirectory(java.util.List<java.io.File> fileList)
fileList
- list of File objectspublic static java.awt.Rectangle coverRectangle(java.awt.Rectangle inner, java.awt.Rectangle outer)
inner
- Inner rectangle.outer
- Outer rectangle.@CheckForNull public static java.awt.Rectangle createRectFromList(java.util.List<java.awt.Point> v)
v
- List of point@Deprecated public static void swapVector(java.util.List v)
Collections.reverse(java.util.List<?>)
v
- List that be swapped.public static java.lang.String getFileWithoutExtension(java.lang.String filename)
filename
- The given file name@Deprecated public static java.lang.String getFileWitoutExtention(java.lang.String filename)
filename
- The given file namegetFileWithoutExtension(String)
@CheckForNull public static java.lang.String getFileExtension(java.io.File file)
file
- The given file@CheckForNull public static java.lang.String getFileExtension(java.lang.String fileName)
fileName
- file namepublic static java.lang.String getFileName(java.lang.String text)
public static java.lang.String getCurrentDateFormatted()
public static java.lang.String removeComments(java.lang.String body)
body
- String body.@Deprecated public static <E extends java.util.Collection> E createCollection(java.lang.Class<E> collection, java.util.Iterator it)
CollectionUtils.createCollection(Class, java.util.Iterator)
@Deprecated public static java.util.Collection notDublicatedList(java.util.Collection col)
CollectionUtils.notDublicatedList(java.util.Collection)
public static java.lang.String trim(java.lang.String src, java.lang.String trashBegin, java.lang.String trashEnd)
src
- The given string.trashBegin
- Trash string that is a beginning.trashEnd
- Trash string that is a ending.public static java.lang.String replaceEpsString(java.lang.String aStr)
aStr
- The given string.public static void copy(java.io.InputStream input, java.io.OutputStream output, long crc, boolean closeInput) throws java.io.IOException
input
- the input stream.output
- the output stream.crc
- crc to check. -1 if do not check crc.java.io.IOException
public static void copy(java.io.InputStream input, java.io.OutputStream output, @CheckForNull java.util.zip.Checksum checksum) throws java.io.IOException
input
- the input stream.output
- the output stream.checksum
- checksum.java.io.IOException
- exceptionpublic static void copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
input
- the input stream.output
- the output stream.java.io.IOException
public static boolean copyFile(java.lang.String sourceName, java.lang.String dstName)
sourceName
- Source file name.dstName
- destination file name.public static boolean copyFile(java.io.File source, java.io.File destination)
source
- Source file.destination
- destination file.public static boolean copyDirectory(java.io.File source, java.io.File destination)
public static void extractZip(java.util.zip.ZipFile zipFile, java.lang.String dstDir) throws java.io.IOException
zipFile
- Zip archive filedstDir
- name of the destination directoryjava.io.IOException
public static java.util.Collection<java.lang.String> extractZip(java.io.InputStream is, java.lang.String dstDir, java.util.Collection<java.lang.String> onlyTheseEntries, java.util.Collection<java.lang.String> skipTheseEntries) throws java.io.IOException
is
- Input Stream - must be valid zip filedstDir
- destination directoryonlyTheseEntries
- if not null specifies which entries must be extracted.skipTheseEntries
- if not null specifies which entries should be skiped.java.io.IOException
public static byte[] toByteArray(java.io.InputStream stream)
stream
- the given file.public static javax.swing.JMenuItem getItemWithText(javax.swing.JPopupMenu menu, java.lang.String text)
menu
- The given JPopupMenu.text
- The given text.public static java.awt.Cursor createCursor(java.awt.Image image, java.awt.Point pt, java.lang.String cursorName)
image
- the given image.pt
- the hot point.cursorName
- the cursor name.public static java.awt.Cursor createCursor(javax.swing.Icon icon, java.awt.Point pt, java.lang.String cursorName)
icon
- the given icon.pt
- the hot point.cursorName
- the cursor name.public static java.lang.String getAsStringKeyStrokes(java.util.List shortcuts, java.lang.String bracketFirst, java.lang.String bracketSecond)
shortcuts
- The given key strokes.bracketFirst
- Open bracket.bracketSecond
- Close bracket.public static java.lang.String getAsString(@CheckForNull javax.swing.KeyStroke e)
e
- the given key stroke.public static boolean isValidKeyCode(int keyCode)
keyCode
- The given key code.public static boolean isPrintableChar(char c)
c
- char which ic checked.public static java.lang.String toString(byte[] data)
data
- the given bytes array.public static byte[] toByteArray(java.lang.String bytes)
bytes
- the given string.public static boolean areChildrenDisabled(javax.swing.JMenu menu)
menu
- the menupublic static void normalize(java.awt.Rectangle rectangle, java.awt.Point firstCorner, java.awt.Point secondCorner)
rectangle
- rectangle to normalizefirstCorner
- first cornersecondCorner
- second cornerpublic static void normalize(java.awt.Rectangle rect)
rect
- rectangle to normalizepublic static java.lang.String getTempDir()
@Deprecated public static java.net.HttpURLConnection openHttpURLConnection(java.lang.String pageHttpAddress, ProxyServerData proxyServerData) throws java.io.IOException
HttpJavaUtilities.openHttpURLConnection(String, String, com.nomagic.utils.http.HttpProxyServerData, int, long)
pageHttpAddress
- page address with protocol e.g "http://www.nomagic.com"
proxyServerData
- proxy server datajava.io.IOException
public static boolean isUseProxy(ProxyServerData proxy)
proxy
- proxy data.@Deprecated public static java.lang.String getHtmlPage(java.lang.String pageHttpAddress, java.lang.String parameters, ProxyServerData proxy) throws java.io.IOException
HttpUtilities.getHtmlPage(String, String, com.nomagic.utils.http.HttpProxyServerData, int)
pageHttpAddress
- page address with protocol e.g "http://www.nomagic.com"
parameters
- parameters for POST method (null if no data to POST)proxy
- proxy server datajava.io.IOException
public static java.lang.String toString(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- The given inputStreamjava.io.IOException
public static java.lang.String toString(java.util.Collection<java.lang.String> strings)
strings
- many strings@Deprecated public static void sendHttpParameters(java.net.HttpURLConnection connection, java.lang.String parameters) throws java.io.IOException
HttpJavaUtilities.sendHttpParameters(java.net.HttpURLConnection, String)
connection
- HttpURLConnectionparameters
- Http Parameters.java.io.IOException
public static java.lang.String constructHttpParameter(java.lang.String parameter, java.lang.String value)
parameter
- parameter namevalue
- parameter valuepublic static java.lang.String addHttpParameter(java.lang.String parameters, java.lang.String parameter, java.lang.String value)
parameters
- parametersparameter
- parameter name to addvalue
- parameter value to addpublic static java.lang.String concatHttpParameter(java.lang.String parameters1, java.lang.String parameters2)
parameters1
- parameters2
- public static java.lang.String insertSeparators(char[] chars, java.lang.String separator, int groupSize)
chars
- array of characters to divideseparator
- group separatorgroupSize
- size if the grouppublic static java.lang.String removeSeparators(java.lang.String str, java.lang.String separator)
str
- string to uniteseparator
- public static byte[] getBytes(java.lang.String str)
public static byte[] distributeInteger(int intValue, int size)
intValue
- int intValue to distributesize
- size of result arraypublic static int collectInteger(byte[] bytes)
bytes
- array of bytespublic static void invokeAndWaitOnDispatcher(java.lang.Runnable r) throws java.lang.RuntimeException
r
- the given runnablejava.lang.RuntimeException
public static void invokeAndWaitOnDispatcherEvenInterrupted(java.lang.Runnable r) throws java.lang.RuntimeException
r
- the given runnablejava.lang.RuntimeException
public static void invokeOnDispatcherOrLater(java.lang.Runnable r)
r
- public static void invokeLaterAfterCondition(java.lang.Runnable runnable, java.util.function.Supplier<java.lang.Boolean> condition)
runnable
- runnable which will be executed.condition
- condition condition after which satisfaction runnable will be executed.public static void invokeLaterAfterCondition(java.lang.Runnable runnable, java.util.function.Supplier<java.lang.Boolean> condition, int conditionCheckAttemptCount)
runnable
- runnable which will be executed.condition
- condition condition after which satisfaction runnable will be executed.conditionCheckAttemptCount
- attempts count of the condition check; if count is reached before the condition is satisfied, runnable will not be executed.public static boolean compareStreams(java.io.InputStream oldStr, java.io.InputStream newStr) throws java.io.IOException
oldStr
- First input stream.newStr
- Second input stream.java.io.IOException
public static boolean compareFiles(java.io.File f1, java.io.File f2) throws java.io.IOException
f1
- First file.f2
- Second file.java.io.IOException
public static void deleteTree(@Nonnull java.io.File f)
f
- file to deletepublic static void deleteTreeOnExit(java.io.File f)
f
- file to deletepublic static void deleteDirContent(java.io.File f)
f
- file to delete@Deprecated @CheckForNull public static ResizableIcon getGrayIcon(@CheckForNull javax.swing.Icon icon)
IconUtilities.getGrayIcon(javax.swing.Icon, java.awt.Component)
icon
- the given icon.@Deprecated @CheckForNull public static ResizableIcon getGrayIcon(@CheckForNull javax.swing.Icon icon, java.awt.Component component)
IconUtilities.getGrayIcon(javax.swing.Icon, java.awt.Component)
icon
- the given icon.component
- component.public static void makeEqual(java.util.List destination, java.util.List source)
destination
- Listsource
- Listpublic static java.lang.String getClassName(java.lang.Class clazz)
clazz
- The given class.public static boolean isAlphaNumeric(java.lang.String str)
public static <T> java.util.List<T> mergeLists(java.util.List<T> l1, java.util.List<T> l2)
l1
- first list.l2
- second list.public static void synchronizeDirectories(java.io.File source, java.io.File destination) throws java.io.IOException
source
- source directory.destination
- destination directory.java.io.IOException
public static java.lang.String[] splitString(java.lang.String str, java.lang.String delimiter, boolean returnDelimiter)
str
- a string to be parsed.delimiter
- the delimiter.returnDelimiter
- flag indicating whether to include the delimiter in result.public static java.lang.String implode(java.util.Collection collection, java.lang.String delimiter)
String.join(CharSequence, Iterable)
.collection
- collection of elements.delimiter
- delimiter.String.join(CharSequence, Iterable)
@Deprecated public static java.lang.String implode(java.lang.String[] values, java.lang.String delimiter)
String.join(CharSequence, CharSequence...)
public static java.lang.String[] parseExceptQuotes(java.lang.String cmd)
public static java.lang.String readFileSkipFirstLines(java.io.File file, int n)
file
- - file to read.n
- - number of lines to skip from the beginning.public static void zipDir(java.lang.String dir2zip, java.util.zip.ZipOutputStream zos) throws java.io.IOException
dir2zip
- directory to zip.zos
- ZipOutputStream
object.java.io.IOException
- if any occurs duringpublic static byte[] compressData(byte[] data, java.lang.String zipEntryName) throws java.io.IOException
data
- a data.zipEntryName
- name of how the data will be named in the archive.java.io.IOException
- if any occurs during compressing the data.public static byte[] compressData(byte[] data) throws java.io.IOException
data
- a data.java.io.IOException
- if any occurs during compressing the data.public static byte[] uncompressData(byte[] data) throws java.io.IOException
data
- a data.java.io.IOException
- if any occurs during compressing the data.public static boolean checkSystemProperty(java.lang.String property, boolean defaultValue)
property
- defaultValue
- public static boolean checkProperty(java.util.Properties properties, java.lang.String property, boolean defaultValue)
public static boolean checkResolvableException(boolean rule)
IllegalStateException
public static void dumpThreads()
public static void dumpThreads(java.io.PrintStream out)
public static java.lang.String reverseString(java.lang.String source)
source
- string which has to be reversed.public static int calculateTextWidth(java.lang.String text, java.awt.FontMetrics metrics, int numberOfLines)
text
- text for which to calculate width.metrics
- font metrics according which to calculate.numberOfLines
- number of lines into which to split the text.public static boolean isHTMLText(java.lang.String s)
s
- the given string.public static <T> void ensureObjectIsInCollection(java.util.Collection<T> collection, T object)
collection
- collection in which to check object existence.object
- object to check.public static java.lang.String encodeBase64(byte[] abyte0)
abyte0
- data for encodingpublic static byte[] decodeBase64(java.lang.String s)
s
- string for decodingpublic static boolean hasModalDialogs(java.awt.Window window)
window
- windowpublic static java.lang.String removeNewLines(java.lang.String string)
string
- string for which to remove new lines.@CheckForNull public static java.lang.String checkIsInstallRootWritable(com.nomagic.runtime.RuntimeEnvironment runtime)
runtime
- Application runtime.@CheckForNull public static java.lang.String checkIsInstallRootWritable(com.nomagic.runtime.RuntimeEnvironment runtime, boolean skipWinUAC)
runtime
- runtime environment.skipWinUAC
- skip checking writable install root if Windows is supporting UAC.public static void printSpace(int number)
number
- number of spaces to print.public static void main(java.lang.String[] args)
public static java.lang.String getVersionFromInternal(java.lang.String internal) throws java.lang.NumberFormatException, java.lang.IndexOutOfBoundsException
internal
- Internal version.java.lang.NumberFormatException
- parse exception.java.lang.IndexOutOfBoundsException
- if internal version is negative.public static java.lang.String getVersionFromInternal(int internal) throws java.lang.IndexOutOfBoundsException
internal
- Internal version.java.lang.IndexOutOfBoundsException
- if internal version is negative.public static boolean containSameElements(java.util.Collection<?> collection1, java.util.Collection<?> collection2)
public static int arrayHash(byte[] array)
array
- bytespublic static boolean isStreamEmpty(java.net.URL url)
url
- url to checkpublic static java.lang.String insertPeriodically(java.lang.String text, java.lang.String insert, int period)
public static java.lang.String getSHA1(byte[] buffer)
public static <E> int getDistance(E from, E to, java.util.function.Function<E,java.util.Collection<E>> connectedNodes)
E
- type of node.from
- starting point in graph.to
- destination point in graph.connectedNodes
- function to get connected edges.public static boolean contentEquals(java.io.InputStream input1, java.io.InputStream input2)
input1
- first stream.input2
- another stream.public static java.text.DateFormat getSystemDateFormat(int style)
style
- Format style (e.g. DateFormat.SHORT
, DateFormat.LONG
).public static boolean isFileNameValid(java.lang.String fileName)
fileName
- file namepublic static <T> java.util.Set<T> excludeCommonElements(java.util.Collection<T> first, java.util.Collection<T> second)
T
- type of collectionfirst
- first collectionsecond
- second collectionpublic static boolean isNameValid(@CheckForNull java.lang.String name)
public static java.lang.String getThreadsInfo()