public class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static char[] |
INVALID_FILESYSTEM_CHARACTERS |
static char[] |
INVALID_JSONIFY_CHARACTERS |
Modifier and Type | Method and Description |
---|---|
static int |
compareVersions(String version1,
String version2)
Compares two version strings.
|
static String |
convertGlobToRegex(String pattern)
Converts a standard POSIX Shell globbing pattern into a regular expression
pattern.
|
static String |
createIconTextHTMLTable(String text,
URL iconURL)
Creates an HTML table with an icon and text.
|
static String |
createIconTextHTMLTableElement(String text,
URL iconURL)
Creates an HTML table with an icon and text.
|
static String |
createRightIconTextHTMLTable(String text,
URL iconURL)
Same as createIconTextHTMLTable but the icon is on the right side
|
static String |
createRightIconTextHTMLTableElement(String text,
URL iconURL)
Same as createIconTextHTMLTableElement but the icon is on the right side
|
static String |
formatDateTime(LocalDateTime dateTime)
A nice human-readable format
|
static String |
formatDuration(long durationMilliseconds)
Formats a duration in milliseconds to something readable
|
static String |
getCleanedMenuPath(String menuPath)
Cleans a menu path string
|
static boolean |
isFilesystemCompatible(String string)
Returns if the string does not contain invalid characters.
|
static boolean |
isNullOrEmpty(Object string)
Returns true if the string is null or empty
|
static String |
jsonify(String input)
Removes all spaces, and filesystem-unsafe characters from the string and replaces them with dashes
Duplicate dashes are removed
|
static String |
makeFilesystemCompatible(String input)
Replaces all characters invalid for filesystems with spaces
Assumes that the string is a filename, so path operators are not allowed.
|
static String |
makeUniqueString(String input,
String spaceCharacter,
Collection<String> existing)
Makes an unique string by adding a counting variable to its end if it already exists
|
static String |
makeUniqueString(String input,
String spaceCharacter,
Predicate<String> existing)
Makes an unique string by adding a counting variable to its end if it already exists
|
static String |
nullTerminate(String input)
Applies a \0 termination to a string.
|
static String |
nullToEmpty(Object s)
Returns an empty string if s is null otherwise returns s
|
static String |
orElse(Object string,
String ifNullOrEmpty)
Returns the string if its not null or empty or the alternative
|
static double |
parseDouble(String str) |
static float |
parseFloat(String str) |
static String |
removeDuplicateDelimiters(String string,
String delimiter) |
static String |
removeHTMLRoot(String html)
Removes the HTML root from HTML
|
static String |
safeJsonify(String input)
Removes all spaces, and filesystem-unsafe characters from the string and replaces them with dashes
Duplicate dashes are removed
|
static String |
wordWrappedHTML(String text,
int wrapColumn)
Create word wrapping in HTML.
|
static String |
wordWrappedHTMLElement(String text,
int wrapColumn)
Create word wrapping in HTML.
|
public static final char[] INVALID_FILESYSTEM_CHARACTERS
public static final char[] INVALID_JSONIFY_CHARACTERS
public static String removeDuplicateDelimiters(String string, String delimiter)
public static String formatDuration(long durationMilliseconds)
durationMilliseconds
- the durationpublic static String formatDateTime(LocalDateTime dateTime)
dateTime
- the time pointpublic static String createIconTextHTMLTable(String text, URL iconURL)
text
- the text. Is automatically escapediconURL
- the iconpublic static String createIconTextHTMLTableElement(String text, URL iconURL)
text
- the text. Is automatically escapediconURL
- the iconpublic static String createRightIconTextHTMLTable(String text, URL iconURL)
text
- the text. Is automatically escapediconURL
- the iconpublic static String createRightIconTextHTMLTableElement(String text, URL iconURL)
text
- the text. Is automatically escapediconURL
- the iconpublic static String nullTerminate(String input)
input
- the input stringpublic static String removeHTMLRoot(String html)
html
- the HTMLpublic static String wordWrappedHTML(String text, int wrapColumn)
text
- the wrapped text. It is automatically escapedwrapColumn
- after how many columns to break wordspublic static String wordWrappedHTMLElement(String text, int wrapColumn)
text
- the wrapped text. It is automatically escapedwrapColumn
- after how many columns to break wordspublic static boolean isNullOrEmpty(Object string)
string
- the stringpublic static String orElse(Object string, String ifNullOrEmpty)
string
- the stringifNullOrEmpty
- returned if string is null or emptypublic static String safeJsonify(String input)
input
- the input stringpublic static String jsonify(String input)
input
- the input stringpublic static String makeFilesystemCompatible(String input)
input
- filenamepublic static String makeUniqueString(String input, String spaceCharacter, Collection<String> existing)
input
- initial stringspaceCharacter
- character to add between the string and counting variableexisting
- collection of existing stringspublic static String makeUniqueString(String input, String spaceCharacter, Predicate<String> existing)
input
- initial stringspaceCharacter
- character to add between the string and counting variableexisting
- function that returns true if the string already existspublic static String getCleanedMenuPath(String menuPath)
menuPath
- a menu pathpublic static boolean isFilesystemCompatible(String string)
string
- the filenamepublic static String nullToEmpty(Object s)
s
- the stringpublic static String convertGlobToRegex(String pattern)
java.util.regex
API to
recognize strings which match the glob pattern.
See also, the POSIX Shell language: ...
See ...
pattern
- A glob pattern.public static int compareVersions(String version1, String version2)
version1
- the first versionversion2
- the second versionpublic static double parseDouble(String str)
public static float parseFloat(String str)
Copyright © 2020–2022 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.