Class Common


  • public final class Common
    extends Object
    This class define common constants.
    Since:
    1.0
    Author:
    Laurent Jourdren
    • Method Detail

      • writeLog

        public static void writeLog​(OutputStream os,
                                    long startTime,
                                    String data)
                             throws IOException
        Write log data.
        Parameters:
        os - OutputStream of the log file
        data - data to write
        Throws:
        IOException - if an error occurs while writing log file
      • writeLog

        public static void writeLog​(File file,
                                    long startTime,
                                    String data)
                             throws IOException
        Write log data.
        Parameters:
        file - the log file
        data - data to write
        Throws:
        IOException - if an error occurs while writing log file
      • showMessageAndExit

        public static void showMessageAndExit​(String message)
        Show a message and then exit.
        Parameters:
        message - the message to show
      • showAndLogErrorMessage

        public static void showAndLogErrorMessage​(String message)
        Show and log an error message.
        Parameters:
        message - message to show and log
      • showErrorMessageAndExit

        public static void showErrorMessageAndExit​(String message)
        Show a message and then exit.
        Parameters:
        message - the message to show
      • errorExit

        public static void errorExit​(Throwable e,
                                     String message)
        Print error message to the user and exits the application.
        Parameters:
        e - Exception
        message - message to show to the use
      • errorExit

        public static void errorExit​(Throwable e,
                                     String message,
                                     boolean logMessage)
        Print error message to the user and exits the application.
        Parameters:
        e - Exception
        message - message to show to the use
        logMessage - true if message must be logged
      • errorHalt

        public static void errorHalt​(Throwable e,
                                     String message)
        Print error message to the user and halts the application.
        Parameters:
        e - Exception
        message - message to show to the use
      • errorHalt

        public static void errorHalt​(Throwable e,
                                     String message,
                                     boolean logMessage)
        Print error message to the user and halts the application.
        Parameters:
        e - Exception
        message - message to show to the use
        logMessage - true if message must be logged
      • exit

        public static void exit​(int exitCode)
        Exit the application.
        Parameters:
        exitCode - exit code
      • halt

        public static void halt​(int exitCode)
        Exit the application.
        Parameters:
        exitCode - exit code
      • sendMail

        public static void sendMail​(String subject,
                                    String message)
      • getThreadsNumber

        public static int getThreadsNumber​(int localThreads,
                                           int maxLocalThreads)
        Get the number of threads to use from localThreads, maxLocalThreads and global threads number.
        Parameters:
        localThreads - number of threads
        maxLocalThreads - maximum number of threads
        Returns:
        the number of threads to use
      • printWarning

        public static void printWarning​(String message)
        Print warning.
        Parameters:
        message - message to print