Class PepperUtil


  • public abstract class PepperUtil
    extends Object
    • Field Detail

      • FILE_ENDING_PEPPER

        public static final String FILE_ENDING_PEPPER
        This is the default ending of a Pepper workflow description file.
        See Also:
        Constant Field Values
      • CONSOLE_WIDTH

        public static final int CONSOLE_WIDTH
        The standard width of the output console of Pepper.
        See Also:
        Constant Field Values
      • CONSOLE_WIDTH_120

        public static final int CONSOLE_WIDTH_120
        The width of the output console of Pepper.
        See Also:
        Constant Field Values
      • CONSOLE_WIDTH_80

        public static final int CONSOLE_WIDTH_80
        The width of the output console of Pepper, when os is windows.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PepperUtil

        public PepperUtil()
    • Method Detail

      • getHello

        public static String getHello()
        Returns a formatted String, a kind of a welcome screen of Pepper.
        Returns:
        welcome screen
      • getHello

        public static String getHello​(int width,
                                      String eMail,
                                      String hp)
        Returns a formatted String, a kind of a welcome screen of Pepper.
        Returns:
        welcome screen
      • breakString

        public static String breakString​(String theString)
        Breaks the String theString at position CONSOLE_WIDTH and adds a linebreak. The manipulated String is returned.
        Parameters:
        theString - String to be break
        Returns:
        the breaked String
      • breakString

        public static String breakString​(String theString,
                                         int length)
        Breaks the String theString at position length and adds a linebreak. The manipulated String is returned.
        Parameters:
        theString - String to be break
        length - position where to break String
        Returns:
        the breaked String
      • breakString

        public static String breakString​(String linePrefix,
                                         String theString)
        Breaks the String theString at position CONSOLE_WIDTH and adds a linebreak. The next line than is prefixed bylinePrefix. The manipulated String is returned.
        Parameters:
        theString - String to be break
        length - position where to break String
        linePrefix - a prefix for all lines
        Returns:
        the breaked String
      • breakString

        public static String breakString​(String linePrefix,
                                         String theString,
                                         int length)
        Breaks the String theString at position length and adds a linebreak. The next line than is prefixed by linePrefix. The manipulated String is returned.
        Parameters:
        theString - String to be break
        length - position where to break String
        linePrefix - a prefix for all lines
        Returns:
        the breaked String
      • createTable

        public static String createTable​(Integer[] length,
                                         String[][] map,
                                         boolean hasHeader,
                                         boolean hasBlanks,
                                         boolean drawInnerVerticalLine)
        Returns a table created from the passed Strings.
        Parameters:
        length - an array of lengths for the columns
        map - a map containing the Strings to be printed out sorted as [line, column]
        hasHeader - determines, if the first line of map contains a header for the table
        hasBlanks - determines if vertical lines has to be followed by a blank e.g. with blanks "| cell1 |" or without blanks "|cell1|"
        drawInnerVerticalLine - determines whether an inner vertical line between two cells has to be drawn e.g. "|cell1 | cell2|" or "|cell1 cell2|"
        Returns:
      • getTempTestFile

        public static File getTempTestFile​(String segments)
        Returns a temporary folder, where all tests can store temporary files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.
        Parameters:
        segments - segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'
        Returns:
        path, where to store temporary files
      • getTempTestFile

        public static File getTempTestFile()
        Returns a temporary folder, where all tests can store temporary files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.
        Returns:
        path, where to store temporary files
      • getTempFile

        public static File getTempFile()
        Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper' and the users name or a randomized unique sequence of characters, if the user name is not available.
        Returns:
        path, where to store temporary files
      • getTempFile

        public static File getTempFile​(String segments)
        Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.
        Parameters:
        segments - segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'
        Returns:
        path, where to store temporary files
      • getTempFile

        public static File getTempFile​(String segments,
                                       String prefix)
        Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.
        Parameters:
        segments - segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'
        prefix - the prefix to be used like 'pepper' or pepper-test etc.
        Returns:
        path, where to store temporary files
      • reportConfiguration

        public static String reportConfiguration​(PepperConfiguration conf)
        Returns a report as String containing the configuration for Pepper.
        Returns:
      • reportModuleList

        public static String reportModuleList​(int width,
                                              Collection<PepperModuleDesc> moduleDescs,
                                              Map<Integer,​PepperModuleDesc> number2module)
        Creates a table containing all passed Pepper modules corresponding to their description and their fingerprint
        Parameters:
        maximal - width of the returned string
        moduleDescs - all modules to be listed
        number2module - a map containing a module description and a corresponding number for identification
        Returns:
        a table displaying all passed modules and a corresponding description
      • reportModuleList

        public static String reportModuleList​(int width,
                                              Collection<PepperModuleDesc> moduleDescs)
        Creates a table containing all passed Pepper modules corresponding to their description and their fingerprint
        Parameters:
        maximal - width of the returned string
        moduleDescs - all modules to be listed
        number2module - a map containing a module description and a corresponding number for identification
        Returns:
        a table displaying all passed modules and a corresponding description
      • readXMLResource

        public static void readXMLResource​(DefaultHandler2 contentHandler,
                                           org.eclipse.emf.common.util.URI documentLocation)
        Helper method to read an xml file with a DefaultHandler2 implementation given as contentHandler. It is assumed, that the file encoding is set to UTF-8.
        Parameters:
        contentHandler - DefaultHandler2 implementation
        documentLocation - location of the xml-file
      • isNullOrEmpty

        public static <T> boolean isNullOrEmpty​(Collection<T> collection)
        Checks whether a collection is null or empty
        Parameters:
        list -
        Returns:
      • isNotNullOrEmpty

        public static <T> boolean isNotNullOrEmpty​(Collection<T> collection)
        Checks whether a collection is not null nor empty
        Parameters:
        list -
        Returns: