Class StringUtils

java.lang.Object
io.sentry.util.StringUtils

@Internal public final class StringUtils extends Object
  • Method Details

    • getStringAfterDot

      @Nullable public static @Nullable String getStringAfterDot(@Nullable @Nullable String str)
    • capitalize

      @Nullable public static @Nullable String capitalize(@Nullable @Nullable String str)
      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
    • 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 from
      delimiter - the String that is meant to be removed
      Returns:
      a string without delimiter character at the beginning and the end of the string
    • byteCountToString

      @NotNull public static @NotNull String byteCountToString(long bytes)
      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 String
      logger - the Logger
      Returns:
      The hashed String or null otherwise
    • countOf

      public static int countOf(@NotNull @NotNull String str, char character)
      Counts the occurrences of a character in a String
      Parameters:
      str - the String
      character - the character to count
      Returns:
      The number of occurrences of the character in the String
    • normalizeUUID

      public static String normalizeUUID(@NotNull @NotNull String uuidString)
      Normalizes UUID string representation to adhere to the actual UUID standard

      Because 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 elements
      elements - the elements that should be joined together
      Returns:
      a new String with elements joined using delimiter
    • toString

      @Nullable public static @Nullable String toString(@Nullable @Nullable Object object)
    • removePrefix

      @NotNull public static @NotNull String removePrefix(@Nullable @Nullable String string, @NotNull @NotNull String prefix)
    • substringBefore

      @NotNull public static @NotNull String substringBefore(@Nullable @Nullable String string, @NotNull @NotNull String separator)