Package org.apache.commons.cli.help
Class Util
- java.lang.Object
-
- org.apache.commons.cli.help.Util
-
final class Util extends java.lang.ObjectContains useful helper methods for classes within this package.
-
-
Field Summary
Fields Modifier and Type Field Description private static intNOT_FOUNDA special value for index not found.
-
Constructor Summary
Constructors Modifier Constructor Description privateUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static <T extends java.lang.CharSequence>
TdefaultValue(T str, T defaultValue)Returns thedefaultValueifstris empty.(package private) static intindexOfNonWhitespace(java.lang.CharSequence text, int startPos)Finds the index of the first non whitespace character.(package private) static booleanisEmpty(java.lang.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 java.lang.Stringltrim(java.lang.String s)Removes the leading whitespace from the specified String.(package private) static java.lang.Stringrepeat(int len, char fillChar)Constructs a string of specified length filled with the specified char.(package private) static java.lang.StringrepeatSpace(int len)Creates a String of padding of lengthlen.(package private) static java.lang.Stringrtrim(java.lang.String s)Removes the trailing whitespace from the specified String.
-
-
-
Field Detail
-
NOT_FOUND
private static final int NOT_FOUND
A special value for index not found.- See Also:
- Constant Field Values
-
-
Method Detail
-
defaultValue
static <T extends java.lang.CharSequence> T defaultValue(T str, T 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
static int indexOfNonWhitespace(java.lang.CharSequence text, int startPos)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
static boolean isEmpty(java.lang.CharSequence str)
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
static java.lang.String ltrim(java.lang.String s)
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
static java.lang.String repeat(int len, char fillChar)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
static java.lang.String repeatSpace(int len)
Creates a String of padding of lengthlen.- Parameters:
len- The length of the String of padding to create.- Returns:
- The String of padding.
-
rtrim
static java.lang.String rtrim(java.lang.String s)
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.
-
-