Class StringUtils

java.lang.Object
ubic.gemma.core.util.StringUtils

public class StringUtils extends Object
Various utilities for manipulating strings.

This is mean to extend missing functionality in StringUtils.

Author:
poirigui
  • Constructor Details

    • StringUtils

      public StringUtils()
  • Method Details

    • abbreviateInBytes

      @Nullable public static String abbreviateInBytes(@Nullable String value, String abbrevMarker, int maxLengthInBytes, Charset charset)
      Abbreviate the value of a field stored with the given charset if it exceeds a certain length in bytes.
      See Also:
      • StringUtils.abbreviate(String, int)
    • abbreviateInBytes

      @Nullable public static String abbreviateInBytes(@Nullable String value, String abbrevMarker, int maxLengthInBytes, boolean stripBeforeAddingMarker, Charset charset)
      Abbreviate the value of a field stored with the given charset if it exceeds a certain length in bytes.
      Parameters:
      stripBeforeAddingMarker - if true, the string will be stripped before adding the marker
      See Also:
      • StringUtils.abbreviate(String, int)
    • abbreviateWithSuffix

      public static String abbreviateWithSuffix(@Nullable String value, String suffix, String abbrevMarker, int maxLengthInBytes, boolean stripBeforeAddingMarker, Charset charset)
      Abbreviate a string with a suffix as per abbreviateInBytes(String, String, int, boolean, Charset).

      This produce strings of the form: some text{abbrevMarker}suffix such that the length of the string in bytes is at most the given maximum.

    • truncateInBytes

      public static String truncateInBytes(String s, int maxBytes, Charset charset)
      See Also:
      • StringUtils.truncate(String, int)
    • appendWithDelimiter

      public static String appendWithDelimiter(@Nullable String s, String suffix)
    • appendWithDelimiter

      public static String appendWithDelimiter(@Nullable String s, String suffix, String delimiter)
      Append a suffix to a string, with a delimiter if the string is not empty.

      If the string already ends with the delimiter, the suffix is appended directly.