Class Utilities


  • @OpenApiAll
    public class Utilities
    extends CameoUtilities
    General purpose utilities.
    • Constructor Summary

      Constructors 
      Constructor Description
      Utilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean areChildrenDisabled​(javax.swing.JMenu menu)
      Are all children disabled?
      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 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 boolean containsOnlyFiles​(java.util.List list)
      Indicates if given list contains only file objects.
      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, long crc)
      Copies all bytes from InputStream into OutputStream.
      static boolean copyDirectory​(java.io.File source, java.io.File destination)
      copy all directory recursivelly
      static boolean copyFile​(java.io.File source, java.io.File dst)
      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 rectengle in such way that it must cover inner one (if outer is smaller than inner resizes outer).
      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 v)
      Creates rectangle from vector of points.
      static java.lang.String createStringRepresentation​(java.util.Collection value)  
      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 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 getFileExtension​(java.io.File file)
      Get The given file extension.
      static java.lang.String getFileName​(java.lang.String text)  
      static java.lang.String getFileWitoutExtention​(java.lang.String filename)
      Returns file name without extention (removes chars from last "." to end of string)
      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 getTempDir()
      Returns directory can be used for writing temporary files.
      private static java.lang.String getThreadsInfo​(java.lang.Thread thread, java.lang.StackTraceElement[] stackTrace)
      Thread information convert to string.
      private static byte getValueFromHex​(char charAt)  
      static boolean hasExtension​(java.lang.String name, java.lang.String extension)
      Checks if given file name has given file extension.
      static boolean hasExtension​(java.lang.String name, java.util.List extensions)
      Checks if given file name has one of given file extensions.
      static java.lang.String implode​(java.lang.String[] values, java.lang.String delimiter)  
      static java.lang.String implode​(java.util.Collection collection, java.lang.String delimiter)  
      static java.lang.String insertSeparators​(char[] chars, java.lang.String separator, int groupSize)
      Constructs string from arrays of chars.
      static java.util.List internString​(java.util.List strings)
      Replace all strings in given collection with String.intern().
      static boolean isAlphaNumeric​(java.lang.String str)  
      static boolean isValidKeyCode​(int keyCode)
      Checks if given code is correct one or not.
      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> 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 mRectToDraw, java.awt.Point mFirstCorner, java.awt.Point mSecondCorner)
      normalizes rectangle mRectToDraw; Calculates rectangle size and location using mFirstCorner and mSecondCorner.
      static java.lang.String[] parseExceptQuotes​(java.lang.String cmd)
      parses string by standard tokens, except parts wrapped in quotes
      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 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 sortStrings​(java.util.Vector elem)
      Sorts elements in strings' vector
      static java.lang.String[] splitString​(java.lang.String str, java.lang.String delim, boolean returnDelims)
      Splits string
      static void swapVector​(java.util.List v)
      Swaps vector ( first element will be last, same with others elements)
      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 formated 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.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 recursivelly to the specified stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • Utilities

        public Utilities()
    • Method Detail

      • hasExtension

        public static boolean hasExtension​(java.lang.String name,
                                           java.util.List extensions)
        Checks if given file name has one of given file extensions.
        Parameters:
        name -
        extensions -
        Returns:
      • hasExtension

        public static boolean hasExtension​(java.lang.String name,
                                           java.lang.String extension)
        Checks if given file name has given file extension.
        Parameters:
        name -
        extension -
        Returns:
      • removeExtension

        public static java.lang.String removeExtension​(java.lang.String name,
                                                       java.util.Collection<java.lang.String> extensions)
        Removes file extension form given file name.
        Parameters:
        name -
        extensions - extensions
        Returns:
      • createStringRepresentation

        public static java.lang.String createStringRepresentation​(java.util.Collection value)
      • deepPointsClone

        public static java.util.List<java.awt.Point> deepPointsClone​(java.util.List<java.awt.Point> v)
        Makes a deep clone of vector that contains points.
        Parameters:
        v - List of point.
        Returns:
        vector
      • deepPointsClone

        public 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.
        Parameters:
        v - List of point.
        cloneList - True if clone to new list.
        Returns:
        vector
      • replace

        public static java.lang.String replace​(java.lang.String src,
                                               java.lang.String pattern,
                                               java.lang.String replaceWith)
        Replaces string fragment with another string
        Parameters:
        src - Source string.
        pattern - String pattern.
        replaceWith - The another string.
        Returns:
        string.
      • match

        public static boolean match​(java.lang.String pattern,
                                    java.lang.String string)
        algorithm for searching with wildcards.
        Parameters:
        pattern - The given pattern.
        string - String.
        Returns:
        boolean expression.
      • matchEmpty

        public static boolean matchEmpty​(java.lang.String patter,
                                         java.lang.String string)
        Matches empty string also
        Parameters:
        patter - The given pattern.
        string - The given string.
        Returns:
        boolean
      • sortStrings

        public static void sortStrings​(java.util.Vector elem)
        Sorts elements in strings' vector
        Parameters:
        elem - The given vector.
      • clearLine

        public static java.lang.String clearLine​(java.lang.String line,
                                                 java.lang.String trash)
        removes from line ends wanted characters
        Parameters:
        line - The given line.
        trash - characters as string.
        Returns:
        String.
      • clearAllLine

        public static java.lang.String clearAllLine​(java.lang.String src,
                                                    java.lang.String trash)
        Removes all trash from string
        Parameters:
        src - String that be removed trash
        trash - Trash string.
        Returns:
        String.
      • removeFromLine

        public static java.lang.String removeFromLine​(java.lang.String line,
                                                      java.lang.String trash)
        Removes from line trash line
        Parameters:
        line - the given line.
        trash - characters as string.
        Returns:
        The given string without From Line.
      • countOccurrences

        public static int countOccurrences​(java.lang.String string,
                                           char c)
        Returns the number of times the character c appears in a string.
        Parameters:
        string - The given string.
        c - character.
        Returns:
        number of time.
      • removeNonUtf8CompliantCharacters

        public static java.lang.String removeNonUtf8CompliantCharacters​(java.lang.String inString)
      • fitInRectangle

        public static java.awt.Rectangle fitInRectangle​(java.awt.Rectangle small,
                                                        java.awt.Rectangle big)
        recalculate bounds to fit in rectangle
        Parameters:
        small - Small rectangle.
        big - Big rectangle.
        Returns:
        New rectangle.
      • containsOnlyFiles

        public static boolean containsOnlyFiles​(java.util.List list)
        Indicates if given list contains only file objects.
        Parameters:
        list - list to check.
        Returns:
        true if given list contains only file objects, false otherwise.
      • coverRectangle

        public static java.awt.Rectangle coverRectangle​(java.awt.Rectangle inner,
                                                        java.awt.Rectangle outer)
        Moves outer rectengle in such way that it must cover inner one (if outer is smaller than inner resizes outer). Modifies outer and returns it.
        Parameters:
        inner - Inner rectangle.
        outer - Outer rectangle.
        Returns:
        Moved rectangle.
      • createRectFromList

        public static java.awt.Rectangle createRectFromList​(java.util.List v)
        Creates rectangle from vector of points.
        Parameters:
        v - List of point.
        Returns:
        null if vector was empty.
      • swapVector

        public static void swapVector​(java.util.List v)
        Swaps vector ( first element will be last, same with others elements)
        Parameters:
        v - List that be swaped.
      • getFileWitoutExtention

        public static java.lang.String getFileWitoutExtention​(java.lang.String filename)
        Returns file name without extention (removes chars from last "." to end of string)
        Parameters:
        filename - The given file name.
      • getFileExtension

        public static java.lang.String getFileExtension​(java.io.File file)
        Get The given file extension.
        Parameters:
        file - The given file.
        Returns:
        File extension.
      • getFileName

        public static java.lang.String getFileName​(java.lang.String text)
      • removeComments

        public static java.lang.String removeComments​(java.lang.String body)
        Removes / * * / comments from body.
        Parameters:
        body - String body.
        Returns:
        body without comment.
      • trim

        public static java.lang.String trim​(java.lang.String src,
                                            java.lang.String trashBegin,
                                            java.lang.String trashEnd)
        Removes from begin and end given Strings.
        Parameters:
        src - The given string.
        trashBegin - Trash string that is a beginning.
        trashEnd - Trash string that is a ending.
        Returns:
        String
      • replaceEpsString

        public static java.lang.String replaceEpsString​(java.lang.String aStr)
        Replace special char for Eps format string
        Parameters:
        aStr - The given string.
        Returns:
        String
      • copy

        public static void copy​(java.io.InputStream input,
                                java.io.OutputStream output,
                                long crc)
                         throws java.io.IOException
        Copies all bytes from InputStream into OutputStream. Closes the streams.
        Parameters:
        input - the inputstream.
        output - the output stream.
        crc - crc to check. -1 if do not check crc.
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.io.InputStream input,
                                java.io.OutputStream output)
                         throws java.io.IOException
        Copies all bytes from InputStream into OutputStream. Closes the streams.
        Parameters:
        input - the inputstream.
        output - the output stream.
        Throws:
        java.io.IOException
      • copyFile

        public static boolean copyFile​(java.lang.String sourceName,
                                       java.lang.String dstName)
        Copy source file to destination file.
        Parameters:
        sourceName - Source file name.
        dstName - destination file name.
        Returns:
        True if work successful.
      • copyFile

        public static boolean copyFile​(java.io.File source,
                                       java.io.File dst)
        Copy source file to destination file.
        Parameters:
        source - Source file.
        dst - destination file.
        Returns:
        True if work successful.
      • copyDirectory

        public static boolean copyDirectory​(java.io.File source,
                                            java.io.File destination)
        copy all directory recursivelly
        Parameters:
        source -
        destination -
      • extractZip

        public static void extractZip​(java.util.zip.ZipFile zipFile,
                                      java.lang.String dstDir)
                               throws java.io.IOException
        Extracts files from Zip archive
        Parameters:
        zipFile - Zip archive file
        dstDir - name of the destination directory
        Throws:
        java.io.IOException
      • toByteArray

        public static byte[] toByteArray​(java.io.InputStream stream)
        Copies the given file into the array of bytes.
        Parameters:
        stream - the given file.
        Returns:
        the byte array with the context of the file;null if some errors occurs
      • getItemWithText

        public static javax.swing.JMenuItem getItemWithText​(javax.swing.JPopupMenu menu,
                                                            java.lang.String text)
        Returns inner component (not recursively) with given text.
        Parameters:
        menu - The given JPopupMenu.
        text - The given text.
        Returns:
        JMenuItem.
      • createCursor

        public static java.awt.Cursor createCursor​(java.awt.Image image,
                                                   java.awt.Point pt,
                                                   java.lang.String cursorName)
        Creates the cursor for given image.
        Parameters:
        image - the given image.
        pt - the hot point.
        cursorName - the cursor name.
        Returns:
        Curser.
      • getAsStringKeyStrokes

        public 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.
        Parameters:
        shortcuts - The given key strokes.
        bracketFirst - Open bracket.
        bracketSecond - Close bracket.
        Returns:
        String.
      • getAsString

        public static java.lang.String getAsString​(javax.swing.KeyStroke e)
        Constructs the string representation of the given key stroke.
        Parameters:
        e - the given key stroke.
        Returns:
        String representation.
      • isValidKeyCode

        public static boolean isValidKeyCode​(int keyCode)
        Checks if given code is correct one or not.
        Parameters:
        keyCode - The given key code.
        Returns:
        true if given code is not CTRL, SHIFT, META or ALT.
      • toString

        public static java.lang.String toString​(byte[] data)
        Returns string representation of the given byte array.
        Parameters:
        data - the given bytes array.
        Returns:
        the string representation (every byte is represented as hex string separated by space)
      • toByteArray

        public static byte[] toByteArray​(java.lang.String bytes)
        Returns byte array from string formated in toString(byte[]) method.
        Parameters:
        bytes - the given string.
        Returns:
        the byte array.
      • getValueFromHex

        private static byte getValueFromHex​(char charAt)
      • areChildrenDisabled

        public static boolean areChildrenDisabled​(javax.swing.JMenu menu)
        Are all children disabled?
        Parameters:
        menu - the menu
        Returns:
        true, if all menu children are disabled
      • normalize

        public static void normalize​(java.awt.Rectangle mRectToDraw,
                                     java.awt.Point mFirstCorner,
                                     java.awt.Point mSecondCorner)
        normalizes rectangle mRectToDraw; Calculates rectangle size and location using mFirstCorner and mSecondCorner. This method is useful when resizing a shape and only opposite corners are known.
        Parameters:
        mRectToDraw - rectangle to normalize
        mFirstCorner - first corner
        mSecondCorner - second corner
      • normalize

        public static void normalize​(java.awt.Rectangle rect)
        normalizes rectangle mRectToDraw;
        Parameters:
        rect - rectangle to normalize
      • getTempDir

        public static java.lang.String getTempDir()
        Returns directory can be used for writing temporary files.
        Returns:
        string.
      • toString

        public static java.lang.String toString​(java.io.InputStream inputStream)
                                         throws java.io.IOException
        Get String representation of inputStream
        Parameters:
        inputStream - The given inputStream
        Returns:
        String representation.
        Throws:
        java.io.IOException
      • insertSeparators

        public static java.lang.String insertSeparators​(char[] chars,
                                                        java.lang.String separator,
                                                        int groupSize)
        Constructs string from arrays of chars. String characters are grouped into groups. Groups are separated by separator.
        Parameters:
        chars - array of characters to divide
        separator - group separator
        groupSize - size if the group
        Returns:
        result string
      • removeSeparators

        public static java.lang.String removeSeparators​(java.lang.String str,
                                                        java.lang.String separator)
        Removes separators from specified str
        Parameters:
        str - string to unite
        separator -
        Returns:
        str without separators
      • getBytes

        public static byte[] getBytes​(java.lang.String str)
        Returns bytes of string. 2 bytes for every char.
        Parameters:
        str -
      • distributeInteger

        public static byte[] distributeInteger​(int intValue,
                                               int size)
        Distributes integer intValue into array of bytes. int is 4 bytes, so max array size is 4
        Parameters:
        intValue - int intValue to distribute
        size - size of result array
        Returns:
        array of bytes
      • collectInteger

        public static int collectInteger​(byte[] bytes)
        Makes int value from array of bytes
        Parameters:
        bytes - array of bytes
        Returns:
        int value
      • compareStreams

        public static boolean compareStreams​(java.io.InputStream oldStr,
                                             java.io.InputStream newStr)
                                      throws java.io.IOException
        Compares two input streams.
        Parameters:
        oldStr - First input stream.
        newStr - Second input stream.
        Returns:
        true if streams contains identical data.
        Throws:
        java.io.IOException
      • compareFiles

        public static boolean compareFiles​(java.io.File f1,
                                           java.io.File f2)
                                    throws java.io.IOException
        Compares two files
        Parameters:
        f1 - First file.
        f2 - Second file.
        Returns:
        true if files contains identical data.
        Throws:
        java.io.IOException
      • deleteTree

        public static void deleteTree​(java.io.File f)
        Removes given directory and all its contents. File.delete fails if directory is not empty
        Parameters:
        f - file to delete
      • deleteTreeOnExit

        public static void deleteTreeOnExit​(java.io.File f)
        Removes given file (directory and all its contents) on exit. File.delete fails if directory is not empty
        Parameters:
        f - file to delete
      • deleteDirContent

        public static void deleteDirContent​(java.io.File f)
        Removes given directory contents. File.delete fails if directory is not empty
        Parameters:
        f - file to delete
      • getClassName

        public static java.lang.String getClassName​(java.lang.Class clazz)
        Get class name.
        Parameters:
        clazz - The given class.
        Returns:
        Class name.
      • isAlphaNumeric

        public static boolean isAlphaNumeric​(java.lang.String str)
      • mergeLists

        public static <T> java.util.List<T> mergeLists​(java.util.List<T> l1,
                                                       java.util.List<T> l2)
        Merges two lists into newly created one.
        Parameters:
        l1 - first list.
        l2 - second list.
        Returns:
        newly created list with added elements from l1 and l2.
      • splitString

        public static java.lang.String[] splitString​(java.lang.String str,
                                                     java.lang.String delim,
                                                     boolean returnDelims)
        Splits string
        Parameters:
        str - string to split
        delim - delimiter
        returnDelims - flag indicating whether to return the delimiters with string
        Returns:
        array of strings
      • implode

        public static java.lang.String implode​(java.util.Collection collection,
                                               java.lang.String delimiter)
      • implode

        public static java.lang.String implode​(java.lang.String[] values,
                                               java.lang.String delimiter)
      • parseExceptQuotes

        public static java.lang.String[] parseExceptQuotes​(java.lang.String cmd)
        parses string by standard tokens, except parts wrapped in quotes
        Parameters:
        cmd -
        Returns:
      • readFileSkipFirstLines

        public 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.
        Parameters:
        file - - file to read.
        n - - number of lines to skip from the beginning.
        Returns:
        file contents as string with skipped lines.
      • zipDir

        public static void zipDir​(java.lang.String dir2zip,
                                  java.util.zip.ZipOutputStream zos)
                           throws java.io.IOException
        Compress specified directory recursivelly to the specified stream.
        Parameters:
        dir2zip - directory to zip.
        zos - ZipOutputStream object.
        Throws:
        java.io.IOException - if any occurs during
      • compressData

        public static byte[] compressData​(byte[] data,
                                          java.lang.String zipEntryName)
                                   throws java.io.IOException
        Compresses specified data using zip output stream and returns the result as bytes array.
        Parameters:
        data - a data.
        zipEntryName - name of how the data will be named in the archive.
        Returns:
        compressed data.
        Throws:
        java.io.IOException - if any occurs during compressing the data.
      • compressData

        public static byte[] compressData​(byte[] data)
                                   throws java.io.IOException
        Compresses specified data using gzip output stream and returns the result as bytes array.
        Parameters:
        data - a data.
        Returns:
        compressed data.
        Throws:
        java.io.IOException - if any occurs during compressing the data.
      • uncompressData

        public static byte[] uncompressData​(byte[] data)
                                     throws java.io.IOException
        Uncompresses specified data using gzip input stream and returns the result as bytes array.
        Parameters:
        data - a data.
        Returns:
        compressed data.
        Throws:
        java.io.IOException - if any occurs during compressing the data.
      • checkSystemProperty

        public static boolean checkSystemProperty​(java.lang.String property,
                                                  boolean defaultValue)
        Checks given system (boolean) property value
        Parameters:
        property -
        defaultValue -
        Returns:
        value of the system property, or defaultValue if system property is not set
      • checkProperty

        public static boolean checkProperty​(java.util.Properties properties,
                                            java.lang.String property,
                                            boolean defaultValue)
      • checkResolvableException

        public static boolean checkResolvableException​(boolean rule)
        if rule is false and it's DEVELOPER mode throws IllegalStateException
        Parameters:
        rule -
        Returns:
        rule
      • internString

        public static java.util.List internString​(java.util.List strings)
        Replace all strings in given collection with String.intern().
        Parameters:
        strings - collection of object. Strings among these objects will be interned, other objects will remain.
        Returns:
        the same collection as given
      • dumpThreads

        public static void dumpThreads()
        Dumps all threads to system out.
      • getThreadsInfo

        private static java.lang.String getThreadsInfo​(java.lang.Thread thread,
                                                       java.lang.StackTraceElement[] stackTrace)
        Thread information convert to string.
        Parameters:
        thread - given thread.
        stackTrace - threads stack trace.
        Returns:
        threads stack trace as string.
      • reverseString

        public static java.lang.String reverseString​(java.lang.String source)
        Given a string, returns a string with reversed characters.
        Parameters:
        source - string which has to be reversed.
        Returns:
        a string with reversed characters.