Package org.apache.commons.cli.help
Class Util
java.lang.Object
org.apache.commons.cli.help.Util
Contains useful helper methods for classes within this package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intA special value for index not found. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static <T extends CharSequence>
TdefaultValue(T str, T defaultValue) Returns thedefaultValueifstris empty.(package private) static intindexOfNonWhitespace(CharSequence text, int startPos) Finds the index of the first non whitespace character.(package private) static booleanisEmpty(CharSequence str) Tests whether the given string is null or empty.(package private) static booleanisWhitespace(char c) Works around https://bugs.java.com/bugdatabase/view_bug?bug_id=8341522 Affected Version: 8, 11, 17, 21, 24.(package private) static StringRemoves the leading whitespace from the specified String.(package private) static Stringrepeat(int len, char fillChar) Constructs a string of specified length filled with the specified char.(package private) static StringrepeatSpace(int len) Creates a String of padding of lengthlen.(package private) static StringRemoves the trailing whitespace from the specified String.
-
Field Details
-
NOT_FOUND
private static final int NOT_FOUNDA special value for index not found.- See Also:
-
-
Constructor Details
-
Util
private Util()
-
-
Method Details
-
defaultValue
Returns thedefaultValueifstris empty.- Type Parameters:
T- The type of arguments.- Parameters:
str- The string to check.defaultValue- the default value if the string is empty.- Returns:
- the
defaultValueifstris empty,
-
indexOfNonWhitespace
Finds the index of the first non whitespace character.- Parameters:
text- the text to search in.startPos- the starting position to search from.- Returns:
- the index of the first non whitespace character or -1 if non found.
-
isEmpty
Tests whether the given string is null or empty.- Parameters:
str- The string to test.- Returns:
- Whether the given string is null or empty.
-
isWhitespace
static boolean isWhitespace(char c) Works around https://bugs.java.com/bugdatabase/view_bug?bug_id=8341522 Affected Version: 8, 11, 17, 21, 24. -
ltrim
Removes the leading whitespace from the specified String.- Parameters:
s- The String to remove the leading padding from.- Returns:
- The String of without the leading padding.
-
repeat
Constructs a string of specified length filled with the specified char.- Parameters:
len- the length of the final string.fillChar- the character to file it will.- Returns:
- A string of specified length filled with the specified char.
-
repeatSpace
Creates a String of padding of lengthlen.- Parameters:
len- The length of the String of padding to create.- Returns:
- The String of padding.
-
rtrim
Removes the trailing whitespace from the specified String.- Parameters:
s- The String to remove the trailing padding from.- Returns:
- The String of without the trailing padding.
-