|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jpkgmk.util.StringUtil
public class StringUtil
Nested Class Summary | |
---|---|
static class |
StringUtil.KeyValuePair
Simple object associating a key with a value |
static class |
StringUtil.RemoveResult
|
static class |
StringUtil.TruncationMode
Enumeration of supported truncation modes. |
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_SYSTEM_CHARSET
Default encoding/charset |
static java.lang.String |
UTF8_ENCODING
The string literal for the UTF-8 character set |
Method Summary | |
---|---|
static int |
compare(java.lang.String first,
java.lang.String second)
|
static java.lang.String |
createRandomStringWithBytes(int byteSize)
Creates a random string with the given length |
static java.lang.String |
createString(java.lang.String[] array,
char delimiter)
Converts the given array of strings into a single string using the given delimiter as separator. |
static java.lang.String |
createString(java.lang.String[] array,
int startIndex,
char delimiter)
Converts the given array of strings into a single string using the given delimiter as separator. |
static java.lang.String |
getHexString(byte[] raw)
|
static int |
getLengthInBytes(java.lang.String text,
java.lang.String charset)
Returns the length of the byte array for the specified text . |
static boolean |
isAlphaNumeric(java.lang.String stringToCheck)
Checks if the given string is alphanumeric or not |
static boolean |
isInteger(java.lang.String value)
|
static boolean |
isNullOrEmpty(java.lang.String string)
|
static StringUtil.RemoveResult |
removePrefix(java.lang.String string,
java.lang.String prefix)
|
static java.lang.String |
replace(java.lang.String path,
java.lang.String search,
java.lang.String replacement)
Replaces the first occurrence of the given 'search' string by the 'replacement' string. |
static StringUtil.KeyValuePair |
resolveKeyValue(java.lang.String someString)
Resolves a key value pair from the given string by splitting it at the first found '=' character. |
static java.lang.String |
truncateToMaxLength(java.lang.String inputString,
int maxLength)
Truncates the given string if it is longer than the maximum length specified. |
static java.lang.String |
truncateUtf8String(java.lang.String text,
int maxLengthInBytes,
StringUtil.TruncationMode mode)
Returns the specified string truncated to the specified maximum length in bytes (when encoded in UTF-8 format), with an ellipses (...) if need be. |
static void |
validateMode(java.lang.String mode)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String UTF8_ENCODING
public static final java.lang.String DEFAULT_SYSTEM_CHARSET
Method Detail |
---|
public static java.lang.String getHexString(byte[] raw) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static final boolean isNullOrEmpty(java.lang.String string)
string
-
public static final java.lang.String replace(java.lang.String path, java.lang.String search, java.lang.String replacement)
path
- The path on which the replacement should be donesearch
- search stringreplacement
- replacement string
public static java.lang.String createRandomStringWithBytes(int byteSize)
byteSize
-
public static boolean isInteger(java.lang.String value)
public static java.lang.String createString(java.lang.String[] array, char delimiter)
array
- delimiter
-
public static java.lang.String createString(java.lang.String[] array, int startIndex, char delimiter)
array
- startIndex
- delimiter
-
public static java.lang.String truncateToMaxLength(java.lang.String inputString, int maxLength)
inputString
- The string to truncate, if necessary.maxLength
- The maximum length of the string, after truncation.
public static java.lang.String truncateUtf8String(java.lang.String text, int maxLengthInBytes, StringUtil.TruncationMode mode)
text
- The text to truncate.maxLengthInBytes
- The maximum length in bytes.mode
- The mode for executing the truncation. This can be one of
If the specified mode is any unknown mode, the
default mode StringUtil.TruncationMode.END
is used.
java.lang.IllegalArgumentException
- If maxLengthInBytes is less than 3 or if the given StringUtil.TruncationMode
is
unknown.public static int getLengthInBytes(java.lang.String text, java.lang.String charset)
text
.
text
- The text whose length in bytes should be computed.charset
- The encoding of the text which is needed for converting the text to a byte array. For available
encodings, refer to Charset.availableCharsets()
.
charset
is not supported, this method returns zero.
java.lang.NullPointerException
- If the specified string is null.public static StringUtil.KeyValuePair resolveKeyValue(java.lang.String someString)
someString
- String to resolve. If the string is null or empty, a runtime exception is thrown
public static boolean isAlphaNumeric(java.lang.String stringToCheck)
stringToCheck
-
public static int compare(java.lang.String first, java.lang.String second)
public static void validateMode(java.lang.String mode)
public static StringUtil.RemoveResult removePrefix(java.lang.String string, java.lang.String prefix)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |