Class StringUtil


  • @Deprecated
    public final class StringUtil
    extends Object
    Deprecated.
    Since 2.0.0, use StringUtil
    String-related utility methods not found in popular libraries.
    Since:
    1.14.0
    Author:
    Pascal Essiembre
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int TRUNCATE_HASH_LENGTH
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static byte[] truncateBytesWithHash​(byte[] bytes, Charset charset, int maxByteLength)
      Deprecated.
      Truncates character byte array text larger than the given max byte length and appends a hash value from the truncated text.
      static byte[] truncateBytesWithHash​(byte[] bytes, Charset charset, int maxByteLength, String separator)
      Deprecated.
      Truncates character byte array text larger than the given max byte length and appends a hash value from the truncated text, with an optional separator in-between.
      static String truncateBytesWithHash​(String text, Charset charset, int maxByteLength)
      Deprecated.
      Truncates text with size in bytes larger than the given max byte length and appends a hash value from the truncated text.
      static String truncateBytesWithHash​(String text, Charset charset, int maxByteLength, String separator)
      Deprecated.
      Truncates text with size in bytes larger than the given max byte length and appends a hash value from the truncated text, with an optional separator in-between.
      static String truncateWithHash​(String text, int maxLength)
      Deprecated.
      Truncate text larger than the given max length and appends a hash value from the truncated text.
      static String truncateWithHash​(String text, int maxLength, String separator)
      Deprecated.
      Truncate text larger than the given max length and appends a hash value from the truncated text, with an optional separator in-between.
    • Field Detail

      • TRUNCATE_HASH_LENGTH

        public static final int TRUNCATE_HASH_LENGTH
        Deprecated.
        See Also:
        Constant Field Values
    • Method Detail

      • truncateWithHash

        public static String truncateWithHash​(String text,
                                              int maxLength)
        Deprecated.
        Truncate text larger than the given max length and appends a hash value from the truncated text. The hash size has 10 digits. The hash is added to fit within the maximum length supplied. For this reason, the maxLength argument must be be minimum 10 for any truncation to occur. The hash is added without a separator. To insert a separator between the truncated text and the hash code, use truncateWithHash(String, int, String)
        Parameters:
        text - text to truncate
        maxLength - maximum length the truncated text must have
        Returns:
        truncated text, or original text if no truncation required
      • truncateWithHash

        public static String truncateWithHash​(String text,
                                              int maxLength,
                                              String separator)
        Deprecated.
        Truncate text larger than the given max length and appends a hash value from the truncated text, with an optional separator in-between. The hash size has 10 digits. The hash and separator are added to fit within the maximum length supplied. For this reason, the maxLength argument must be be minimum 10 + separator length for any truncation to occur.
        Parameters:
        text - text to truncate
        maxLength - maximum length the truncated text must have
        separator - string separating truncated text from hash code
        Returns:
        truncated text, or original text if no truncation required
      • truncateBytesWithHash

        public static String truncateBytesWithHash​(String text,
                                                   Charset charset,
                                                   int maxByteLength)
                                            throws CharacterCodingException
        Deprecated.
        Truncates text with size in bytes larger than the given max byte length and appends a hash value from the truncated text. The hash size is equal to the byte length of 10 digits using the given charset. The hash and separator are added to fit within the maximum byte length supplied. For this reason, the maxByteLength argument must be be large enough for any truncation to occur.
        Parameters:
        text - text to truncate
        charset - character encoding
        maxByteLength - maximum byte length the truncated text must have
        Returns:
        truncated character byte array, or original text if no truncation required
        Throws:
        CharacterCodingException - character coding problem
      • truncateBytesWithHash

        public static String truncateBytesWithHash​(String text,
                                                   Charset charset,
                                                   int maxByteLength,
                                                   String separator)
                                            throws CharacterCodingException
        Deprecated.
        Truncates text with size in bytes larger than the given max byte length and appends a hash value from the truncated text, with an optional separator in-between. The hash size is equal to the byte length of 10 digits using the given charset. The hash and separator are added to fit within the maximum byte length supplied. For this reason, the maxByteLength argument must be be large enough for any truncation to occur.
        Parameters:
        text - text to truncate
        charset - character encoding
        maxByteLength - maximum byte length the truncated text must have
        separator - string separating truncated text from hash code
        Returns:
        truncated character byte array, or original text if no truncation required
        Throws:
        CharacterCodingException - character coding problem
      • truncateBytesWithHash

        public static byte[] truncateBytesWithHash​(byte[] bytes,
                                                   Charset charset,
                                                   int maxByteLength)
                                            throws CharacterCodingException
        Deprecated.
        Truncates character byte array text larger than the given max byte length and appends a hash value from the truncated text. The hash size is equal to the byte length of 10 digits using the given charset. The hash and separator are added to fit within the maximum byte length supplied. For this reason, the maxByteLength argument must be be large enough for any truncation to occur.
        Parameters:
        bytes - byte array of text to truncate
        charset - character encoding
        maxByteLength - maximum byte length the truncated text must have
        Returns:
        truncated character byte array, or original text if no truncation required
        Throws:
        CharacterCodingException - character coding problem
      • truncateBytesWithHash

        public static byte[] truncateBytesWithHash​(byte[] bytes,
                                                   Charset charset,
                                                   int maxByteLength,
                                                   String separator)
                                            throws CharacterCodingException
        Deprecated.
        Truncates character byte array text larger than the given max byte length and appends a hash value from the truncated text, with an optional separator in-between. The hash size is equal to the byte length of 10 digits using the given charset. The hash and separator are added to fit within the maximum byte length supplied. For this reason, the maxByteLength argument must be be large enough for any truncation to occur.
        Parameters:
        bytes - byte array of text to truncate
        charset - character encoding
        maxByteLength - maximum byte length the truncated text must have
        separator - string separating truncated text from hash code
        Returns:
        truncated character byte array, or original text if no truncation required
        Throws:
        CharacterCodingException - character coding problem