Package io.sentry.util
Class StringUtils
java.lang.Object
io.sentry.util.StringUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
byteCountToString
(long bytes) Converts the given number of bytes to a human-readable string.static @Nullable String
calculateStringHash
(@Nullable String str, @NotNull ILogger logger) Calculates the SHA-1 String hashstatic @Nullable String
Converts a String to CamelCase format.static @Nullable String
capitalize
(@Nullable String str) Returns a Capitalized String and all remaining chars to lower case.static int
Counts the occurrences of a character in a Stringstatic @Nullable String
getStringAfterDot
(@Nullable String str) static String
join
(@NotNull CharSequence delimiter, @NotNull Iterable<? extends CharSequence> elements) Returns a new String joining together given strings using the given delimiter.static String
normalizeUUID
(@NotNull String uuidString) Normalizes UUID string representation to adhere to the actual UUID standardstatic @NotNull String
removePrefix
(@Nullable String string, @NotNull String prefix) static @Nullable String
removeSurrounding
(@Nullable String str, @Nullable String delimiter) Removes character specified by the delimiter parameter from the beginning and the end of the string.static @NotNull String
substringBefore
(@Nullable String string, @NotNull String separator) static @Nullable String
-
Method Details
-
getStringAfterDot
-
capitalize
Returns a Capitalized String and all remaining chars to lower case. eg seSSioN = Session- Parameters:
str
- the String to capitalize- Returns:
- the capitalized String or itself if empty or null
-
camelCase
Converts a String to CamelCase format. E.g. metric_bucket => MetricBucket;- Parameters:
str
- the String to convert- Returns:
- the camel case converted String or itself if empty or null
-
removeSurrounding
@Nullable public static @Nullable String removeSurrounding(@Nullable @Nullable String str, @Nullable @Nullable String delimiter) Removes character specified by the delimiter parameter from the beginning and the end of the string.- Parameters:
str
- the String to remove surrounding string fromdelimiter
- the String that is meant to be removed- Returns:
- a string without delimiter character at the beginning and the end of the string
-
byteCountToString
Converts the given number of bytes to a human-readable string.- Parameters:
bytes
- the number of bytes- Returns:
- a string representing the human-readable byte count (e.g. 1kB, 20 MB, etc.)
-
calculateStringHash
@Nullable public static @Nullable String calculateStringHash(@Nullable @Nullable String str, @NotNull @NotNull ILogger logger) Calculates the SHA-1 String hash- Parameters:
str
- the Stringlogger
- the Logger- Returns:
- The hashed String or null otherwise
-
countOf
Counts the occurrences of a character in a String- Parameters:
str
- the Stringcharacter
- the character to count- Returns:
- The number of occurrences of the character in the String
-
normalizeUUID
Normalizes UUID string representation to adhere to the actual UUID standardBecause Motorola decided that nil UUIDs should look like this: "0000-0000" ;)
- Parameters:
uuidString
- the original UUID string representation- Returns:
- proper UUID string, in case it's a corrupted one
-
join
public static String join(@NotNull @NotNull CharSequence delimiter, @NotNull @NotNull Iterable<? extends CharSequence> elements) Returns a new String joining together given strings using the given delimiter.- Parameters:
delimiter
- the delimiter that separates elementselements
- the elements that should be joined together- Returns:
- a new String with elements joined using delimiter
-
toString
-
removePrefix
-
substringBefore
-