public final class StringUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
TRUNCATE_HASH_LENGTH |
Modifier and Type | Method and Description |
---|---|
static byte[] |
truncateBytesWithHash(byte[] bytes,
Charset charset,
int maxByteLength)
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)
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)
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)
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)
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)
Truncate text larger than the given max length and appends a hash
value from the truncated text, with an optional separator in-between.
|
public static final int TRUNCATE_HASH_LENGTH
public static String truncateWithHash(String text, int maxLength)
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)
text
- text to truncatemaxLength
- maximum length the truncated text must havepublic static String truncateWithHash(String text, int maxLength, String separator)
maxLength
argument must be
be minimum 10 + separator length for any truncation to occur.text
- text to truncatemaxLength
- maximum length the truncated text must haveseparator
- string separating truncated text from hash codepublic static String truncateBytesWithHash(String text, Charset charset, int maxByteLength) throws CharacterCodingException
maxByteLength
argument must be
be large enough for any truncation to occur.text
- text to truncatecharset
- character encodingmaxByteLength
- maximum byte length the truncated text must haveCharacterCodingException
- character coding problempublic static String truncateBytesWithHash(String text, Charset charset, int maxByteLength, String separator) throws CharacterCodingException
maxByteLength
argument must be
be large enough for any truncation to occur.text
- text to truncatecharset
- character encodingmaxByteLength
- maximum byte length the truncated text must haveseparator
- string separating truncated text from hash codeCharacterCodingException
- character coding problempublic static byte[] truncateBytesWithHash(byte[] bytes, Charset charset, int maxByteLength) throws CharacterCodingException
maxByteLength
argument must be
be large enough for any truncation to occur.bytes
- byte array of text to truncatecharset
- character encodingmaxByteLength
- maximum byte length the truncated text must haveCharacterCodingException
- character coding problempublic static byte[] truncateBytesWithHash(byte[] bytes, Charset charset, int maxByteLength, String separator) throws CharacterCodingException
maxByteLength
argument must be
be large enough for any truncation to occur.bytes
- byte array of text to truncatecharset
- character encodingmaxByteLength
- maximum byte length the truncated text must haveseparator
- string separating truncated text from hash codeCharacterCodingException
- character coding problemCopyright © 2008–2021 Norconex Inc.. All rights reserved.