Package randoop.util
Class Util
- java.lang.Object
-
- randoop.util.Util
-
public final class Util extends Object
Helpers for assertions, and stuff...
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
convertToHexString(String unicodeString)
Convert each character to the form "\\uHEXDIGITS".static String
fileAndAbsolute(File file)
Returns the file if it is absolute, otherwise returns the file AND the absolute file.static String
filenameAndAbsolute(String filename)
Returns the filename if it is absolute, otherwise returns the filename AND the absolute filename.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 byindentWidth
.static boolean
iff(boolean a, boolean b)
Return true if a and b are equal (both true or both false).static boolean
implies(boolean a, boolean b)
Return true if a is false or b is true.static boolean
isJavaIdentifier(String s)
Return true if the string is a legal Java identifier.static int
occurCount(StringBuilder text, String pattern)
Return the number of times that the pattern appears in the text.static String
pathAndAbsolute(Path path)
Returns the path if it is absolute, otherwise returns the path AND the absolute path.static String
replaceWords(String text, Map<String,String> replacements)
Replace occurrences of words from this map with corresponding replacements.
-
-
-
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 testb
- 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 testb
- 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 searchpattern
- 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 byindentWidth
. Each line is no more thancolWidth
characters long.- Parameters:
string
- the paragraph to formatcolWidth
- the full column widthindentWidth
- 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 mapreplacements
- 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
-
-