Package randoop.util

Class Util


  • public final class Util
    extends Object
    Helpers for assertions, and stuff...
    • Constructor Detail

      • Util

        private Util()
    • Method Detail

      • iff

        public static boolean iff​(boolean a,
                                  boolean b)
        Return true if a and b are equal (both true or both false).
        Parameters:
        a - first boolean to test
        b - second bject to test
        Returns:
        true if a and b are equal
      • implies

        public static boolean implies​(boolean a,
                                      boolean b)
        Return true if a is false or b is true.
        Parameters:
        a - first boolean to test
        b - second bject to test
        Returns:
        true if a is false or b is true
      • isJavaIdentifier

        public static boolean isJavaIdentifier​(String s)
        Return true if the string is a legal Java identifier.
        Parameters:
        s - string to test
        Returns:
        true if the string is a legal Java identifier
      • convertToHexString

        public static String convertToHexString​(String unicodeString)
        Convert each character to the form "\\uHEXDIGITS".
        Parameters:
        unicodeString - string to convert
        Returns:
        converted string
      • occurCount

        public static int occurCount​(StringBuilder text,
                                     String pattern)
        Return the number of times that the pattern appears in the text.
        Parameters:
        text - string to search
        pattern - string pattern to search for
        Returns:
        the number of times the pattern appears in the text
      • hangingParagraph

        public static String hangingParagraph​(String string,
                                              int colWidth,
                                              int indentWidth)
        Format a hanging paragraph: The first line starts at the margin, and every subsequent line starts indented by indentWidth. Each line is no more than colWidth characters long.
        Parameters:
        string - the paragraph to format
        colWidth - the full column width
        indentWidth - the number of spaces before each line other than the first line
        Returns:
        a string representation of the formatted paragraph, include line separators
      • replaceWords

        public static String replaceWords​(String text,
                                          Map<String,​String> replacements)
        Replace occurrences of words from this map with corresponding replacements. Only performs replacements of full words (using regular expression word delimiters).
        Parameters:
        text - the text to search for occurrences of names in this map
        replacements - the map of replacements to perform
        Returns:
        the text modified by replacing original names with replacement names
      • pathAndAbsolute

        public static String pathAndAbsolute​(Path path)
        Returns the path if it is absolute, otherwise returns the path AND the absolute path.
        Parameters:
        path - a file path
        Returns:
        the path, and the absolute path if different
      • fileAndAbsolute

        public static String fileAndAbsolute​(File file)
        Returns the file if it is absolute, otherwise returns the file AND the absolute file.
        Parameters:
        file - a file
        Returns:
        the file, and the absolute file if different
      • filenameAndAbsolute

        public static String filenameAndAbsolute​(String filename)
        Returns the filename if it is absolute, otherwise returns the filename AND the absolute filename.
        Parameters:
        filename - a file name
        Returns:
        the filename, and the absolute filename if different