Class StringUtils

java.lang.Object
overit.geocallapp.utilities.datatype.StringUtils

public class StringUtils extends Object
Utility class providing string manipulation and conversion operations.
This class provides utilities for handling string operations that require specific encoding considerations or pattern matching.
Since:
1.0
  • Method Details

    • truncateStringUTF8

      public static String truncateStringUTF8(String s, int byteSize)
      Truncates a string to fit within the specified byte size using UTF-8 encoding. This method ensures that the resulting string, when encoded in UTF-8, does not exceed the specified byte limit.
      Parameters:
      s - the string to truncate (can be null)
      byteSize - the maximum number of bytes allowed in UTF-8 encoding
      Returns:
      the original string if it fits within the byte limit, a truncated version otherwise, or null if input is null
    • convertToSetLong

      public static Set<Long> convertToSetLong(String stringToFormat, String regex)
      Converts a comma-separated string into a Set of Long values. The input string is validated against the provided regex pattern before processing. Spaces are automatically removed from the input.
      Parameters:
      stringToFormat - the input string containing comma-separated numbers (spaces are ignored)
      regex - the regex pattern to validate the input format (e.g., "\\d+(,\\d+)*+")
      Returns:
      a Set of Long values parsed from the string, or an empty set if input is invalid or doesn't match the regex