Package com.glitchybyte.glib
Class GStrings
java.lang.Object
com.glitchybyte.glib.GStrings
String utilities.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbase64Decode(String encoded) Convenience base64 decoder.static Stringbase64Encode(String message) Convenience base64 encoder.static StringbytesToGroupUnit(long bytes) Converts a number of bytes to its most reasonable grouping representation.static StringConvenience replacement forString.formatthat already includes US locale.static <T> StringfromCollection(Collection<T> collection) Convenience Collection to String representation with default comma delimiter.static <T> StringfromCollection(Collection<T> collection, String delimiter) Convenience Collection to String representation.static StringfromDouble(double value) Convenience double to String formatter with human minimal representation.static StringfromFloat(float value) Convenience float to String formatter with human minimal representation.static StringfromInt(int value) Convenience int to String formatter with human minimal representation.static StringfromLong(long value) Convenience long to String formatter with human minimal representation.static StringIndents the string.static intindexOfAny(String str, Set<Character> characterSet) Returns the index of the 1st character in the set found in the string.static intindexOfAny(String str, Set<Character> characterSet, int offset) Returns the index of the 1st character in the set found in the string.static booleanisNullOrEmpty(String str) Convenience for common test of a null or empty string.static StringtoLowerCase(String str) Convenience replacement forString.toLowerCasethat already includes US locale.static StringtoUpperCase(String str) Convenience replacement forString.toUpperCasethat already includes US locale.
-
Field Details
-
NEW_LINE
System new line separator. -
SPACE_TAB
Spaces for indentation.- See Also:
-
-
Method Details
-
isNullOrEmpty
Convenience for common test of a null or empty string.- Parameters:
str- String to test.- Returns:
- True, if the string is null or empty.
-
indent
Indents the string. It will correctly indent multiple lines as long as they have system line separators.Unlike
String.indent, this function does not add a new line if it doesn't exist.- Parameters:
str- String to indent.- Returns:
- Indented string.
-
format
Convenience replacement forString.formatthat already includes US locale.- Parameters:
format- A format string.args- Arguments for format.- Returns:
- Formatted string.
-
toLowerCase
Convenience replacement forString.toLowerCasethat already includes US locale.- Parameters:
str- String to convert.- Returns:
- Converted string.
-
toUpperCase
Convenience replacement forString.toUpperCasethat already includes US locale.- Parameters:
str- String to convert.- Returns:
- Converted string.
-
fromDouble
Convenience double to String formatter with human minimal representation.- Parameters:
value- Double to format into a String.- Returns:
- Minimal String representation of the value.
-
fromFloat
Convenience float to String formatter with human minimal representation.- Parameters:
value- Float to format into a String.- Returns:
- Minimal String representation of the value.
-
fromInt
Convenience int to String formatter with human minimal representation.- Parameters:
value- Int to format into a String.- Returns:
- Minimal String representation of the value.
-
fromLong
Convenience long to String formatter with human minimal representation.- Parameters:
value- Long to format into a String.- Returns:
- Minimal String representation of the value.
-
fromCollection
Convenience Collection to String representation.- Type Parameters:
T- Type of elements in the collection.- Parameters:
collection- Collection to represent as String.delimiter- Delimiter to use between elements.- Returns:
- A String representing the collection.
-
fromCollection
Convenience Collection to String representation with default comma delimiter.- Type Parameters:
T- Type of elements in the collection.- Parameters:
collection- Collection to represent as String.- Returns:
- A String representing the collection.
-
base64Encode
Convenience base64 encoder. Assumes UTF-8 charset.- Parameters:
message- Message to encode.- Returns:
- Encoded message.
-
base64Decode
Convenience base64 decoder. Assumes UTF-8 charset.- Parameters:
encoded- Encoded message.- Returns:
- Decoded message.
-
bytesToGroupUnit
Converts a number of bytes to its most reasonable grouping representation.- Parameters:
bytes- Quantity of bytes.- Returns:
- A string representing those bytes in human-readable form.
-
indexOfAny
Returns the index of the 1st character in the set found in the string.- Parameters:
str- Input string.characterSet- Characters to find.offset- Offset from the beginning of the string.- Returns:
- The index of the 1st character in the set found in the string, or -1 of not found.
-
indexOfAny
Returns the index of the 1st character in the set found in the string.- Parameters:
str- Input string.characterSet- Characters to find.- Returns:
- The index of the 1st character in the set found in the string, or -1 of not found.
-