Class SetupUtils

    • Method Detail

      • loadProperties

        public static Properties loadProperties​(String fileName)
                                         throws IOException
        Loads properties from file.
        Parameters:
        fileName - The path to the properties file.
        Returns:
        The Properties object of the specified propertoes file.
        Throws:
        IOException
      • getUserInput

        public static String getUserInput​(String message)
                                   throws IOException
        Prompts user for input from system in.
        Parameters:
        message - The text message to prompt the user.
        Returns:
        The user input.
        Throws:
        IOException
      • getTokens

        public static Properties getTokens​(ResourceBundle bundle,
                                           Properties confProp)
        Gets the map for text replacement.
        Parameters:
        bundle - The ResourceBundle which contains the tokens' name.
        confProp - The properties which may contain the tokens value.
        Returns:
        The properties object as a map for text replacement.
      • evaluatePropertiesValue

        public static String evaluatePropertiesValue​(String value,
                                                     Properties lookupProp)
        Lookups and replaces the variables in the string
        Parameters:
        value - The string may contain variables which need to be replaced.
        lookupProp - The properties may contain the real values.
        Returns:
        The String with variables replaced by correct value.
      • getFiles

        public static void getFiles​(File fromDir,
                                    File toDir,
                                    String fromFilePattern,
                                    String toFilePattern,
                                    LinkedList fromFilesList,
                                    LinkedList toFilesList)
        Get the from files list and the to file list.
        Parameters:
        fromDir - The directory of the source files located
        toDir - The directory of the destinated files located
        fromFilePattern - The pattern of the name of source files.
        toFilePattern - The pattern of the name of destinated files.
        fromFilesList - (as return) List of files from the source directory.
        toFilesList - (as return) List of files of the destinated directory.
      • determineOS

        public static String determineOS()
        Determines the current operating system.
        Returns:
        The string to represent the current operating system.
      • transformFileName

        public static String transformFileName​(String from,
                                               String to,
                                               File file)
        Transform the file name by using string patterns.
        Parameters:
        from - The pattern of the source file.
        to - The pattern of the destinated file.
        file - The file to be transform.
        Returns:
        The transformed name of the file.
      • transformFileName

        public static String transformFileName​(String from,
                                               String to,
                                               File file,
                                               char wildCard)
        Transform the file name by using string patterns.
        Parameters:
        from - The pattern of the source file.
        to - The pattern of the destinated file.
        file - The file to be transform.
        wildCard - The wildcard character is used in the string pattern.
        Returns:
        The transformed name of the file.
      • ungzip

        public static void ungzip​(String srcFile,
                                  String destDir)
                           throws IOException
        Ungzip the gzip archive from source file to destinated directory.
        Parameters:
        srcFile - The path to the source gzip archive.
        destDir - The destinated directory for the decompression.
        Throws:
        IOException
      • printUsage

        public static void printUsage​(ResourceBundle bundle)
        Prints the usage through system out.
        Parameters:
        bundle - The ResourceBundle which contains the message.
      • evaluateBundleValues

        public static void evaluateBundleValues​(ResourceBundle bundle,
                                                Properties lookupProp)
        Lookups and set the resource bundle variables to the Properties
        Parameters:
        bundle - The ResourceBundle is going to be evaluated.
        lookupProp - The properties may contain the real values and the storage of the results.
      • copyAndFilterScripts

        public static void copyAndFilterScripts​(ResourceBundle bundle,
                                                Properties lookupProp)
                                         throws IOException
        Copy and replace the variables in the scripts.
        Parameters:
        bundle - The ResourceBundle which contains the prompt messages.
        lookupProp - The properties which contains the variables map, file patterns, source directory, and destinated directory.
        Throws:
        IOException