|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ckkloverdos.string.StringUtil
public final class StringUtil
Utility, string-based methods.
Field Summary | |
---|---|
static java.util.regex.Pattern |
DOT_PATTERN
|
static java.lang.String |
EMPTY_STRING
"" |
static char[] |
HEX_DIGITS
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'} |
static java.lang.String |
UTF8
UTF-8 |
Method Summary | |
---|---|
static java.lang.String |
getStringPart(java.lang.String str,
java.lang.String regularExpression,
int index)
Splits str according to the given regularExpression and
returns the index th item. |
static java.lang.String |
getStringUID()
Generates a Unique ID in string form. |
static java.lang.String |
getStringUID(java.util.Random random)
Generates a Unique ID in string form by using the provided random number generator. |
static java.lang.String |
getTextLine(java.lang.String text,
int n)
Splits the provided text into lines and returns the
n th line. |
static char |
hexToAscii(int h)
Returns the ASCII character represententation of the
hexadecimal value h . |
static java.lang.String |
messageDigest(java.lang.String input)
Computes a message digest for the given input . |
static java.lang.String |
messageDigest(java.lang.String input,
java.lang.String algorithm)
Computes a message digest for the given input ,
by using the specified algorithm . |
static java.lang.String |
messageDigest(java.lang.String msg,
java.lang.String algorithm,
java.lang.String encoding)
Computes a message digest for the given input ,
by using the specified algorithm . |
static java.lang.String |
safeRemoveSuffix(java.lang.String str,
java.lang.String suffix)
Safely removes the suffix from str . |
static java.lang.String |
safeRemoveSuffixRepeat(java.lang.String str,
java.lang.String suffix)
Safely removes the suffix from str . |
static java.lang.String[] |
splitDots(java.lang.String s)
Splits the input by dots. |
static java.lang.String |
substring(java.lang.String s,
int beginIndex)
GC-friendly version of String.substring(int) . |
static java.lang.String |
substring(java.lang.String s,
int beginIndex,
int endIndex)
GC-friendly version of String.substring(int, int) . |
static java.lang.String |
toHex(byte b)
Returns the hex representation of the input. |
static java.lang.String |
toHex(byte[] b)
Returns the hex representation of the input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.regex.Pattern DOT_PATTERN
public static final java.lang.String UTF8
public static final java.lang.String EMPTY_STRING
public static final char[] HEX_DIGITS
Method Detail |
---|
public static java.lang.String toHex(byte[] b)
b
- public static java.lang.String toHex(byte b)
b
- public static char hexToAscii(int h)
ASCII
character represententation of the
hexadecimal value h
.
h
- public static java.lang.String messageDigest(java.lang.String input)
input
.
input
- public static java.lang.String messageDigest(java.lang.String input, java.lang.String algorithm)
input
,
by using the specified algorithm
.
input
- algorithm
- public static java.lang.String messageDigest(java.lang.String msg, java.lang.String algorithm, java.lang.String encoding)
input
,
by using the specified algorithm
.
The encoding
is used to obtain byte values from
the input
, by using String.getBytes(String)
.
If the algorithm
is null
, then SHA1
is used.
If the encoding
is null
, then UTF8
is used.
msg
- algorithm
- encoding
- public static java.lang.String safeRemoveSuffixRepeat(java.lang.String str, java.lang.String suffix)
suffix
from str
. This is performed
until str
no more ends with
suffix
.
If any of the input is null
, then a safe
value for str
is returned.
str
- suffix
- public static java.lang.String getStringPart(java.lang.String str, java.lang.String regularExpression, int index)
str
according to the given regularExpression
and
returns the index
th item.
It returns null
in case of an ArrayIndexOutOfBoundsException
, null
.
str
- regularExpression
- index
- public static java.lang.String safeRemoveSuffix(java.lang.String str, java.lang.String suffix)
suffix
from str
. This is performed
once, in contrast to safeRemoveSuffixRepeat(String, String)
.
If any of the input is null
, then a safe
value for str
is returned.
str
- suffix
- public static java.lang.String substring(java.lang.String s, int beginIndex)
String.substring(int)
.
See this bug
s
- beginIndex
- public static java.lang.String substring(java.lang.String s, int beginIndex, int endIndex)
String.substring(int, int)
.
See this bug
s
- beginIndex
- endIndex
- public static java.lang.String[] splitDots(java.lang.String s)
s
- public static java.lang.String getStringUID()
public static java.lang.String getStringUID(java.util.Random random)
random
- public static java.lang.String getTextLine(java.lang.String text, int n)
text
into lines and returns the
n
th line. Line numbering starts from one.
text
- n
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |