public class StringUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
addLeadingZeros(Object number,
int places) |
static String |
appendToPrefix(StringBuffer buffer,
int prefixLength,
String toAppend)
Appends the second String to the indicated prefix of the first.
|
static boolean |
checkException(Throwable t,
String toMatch)
Deprecated.
use ExceptionUtils
|
static String |
convert(String orig,
int from,
int to) |
static String |
getLCSuffix(String prefix,
String full) |
static String |
getPrefix(String name,
String delim) |
static String |
getRandomizedId(String prefix)
Returns an id with a pretty good chance of being unique, by appending to
the given prefix the date, host and a random long.
|
static String |
getRandomizedId(String prefix,
boolean useTimestamp,
boolean useHost,
boolean useLong,
boolean normalize)
Returns an id by appending to the given prefix the date, host and a
random long.
|
static String |
getSequenceId(String base,
long seqno)
Appends a sequence suffix to the base.
|
static String |
getSpaces(int len) |
static String |
getStackTrace(Throwable t)
Deprecated.
use ExceptionUtils
|
static String |
getSuffix(String name,
String delim) |
static String[] |
getTokenArray(String sequence,
String[] chain,
boolean paired,
boolean includeDelim) |
static StringBuffer |
normalizeNonAlphanumeric(StringBuffer sequence)
Normalizes all non-alphanumeric characters to "_".
|
static String |
objectToString(Object o)
To restore the object to string method.
|
static String[] |
parseIntoLines(String string) |
static int |
stringToDecimal(String value) |
static List |
tokenize(String sequence,
String[] chain,
boolean paired,
boolean includeDelim)
Moves through the chain of delimiters in order until one of the tokens is
not found in the remainder of the string.
|
public static String addLeadingZeros(Object number, int places) throws IllegalArgumentException
number
- object representing a number.places
- to the left of decimal to fill with zeros.NCSAException
- if number is not a valid number.IllegalArgumentException
public static String appendToPrefix(StringBuffer buffer, int prefixLength, String toAppend) throws IndexOutOfBoundsException
buffer
- to append to.prefixLength
- length of buffer to retain (-1 = ALL).toAppend
- new suffix.IndexOutOfBoundsException
- if the indicated prefix length exceeds the actual length of
the original String.@Deprecated public static boolean checkException(Throwable t, String toMatch)
public static String getLCSuffix(String prefix, String full)
prefix
- to be discarded.full
- string from which to extract suffix.public static String getRandomizedId(String prefix)
prefix
- to use as id base.public static String getRandomizedId(String prefix, boolean useTimestamp, boolean useHost, boolean useLong, boolean normalize)
prefix
- to use as id base.useTimestamp
- if true, timestamp is included.useHost
- if true, host name is included.useLong
- if true, random is long (else, int).normalize
- if true, normalize alphanumeric is applied.public static String getSequenceId(String base, long seqno)
base
- id to append to.seqno
- suffix to use.public static String getSpaces(int len)
len
- number of spaces.@Deprecated public static String getStackTrace(Throwable t)
public static String[] getTokenArray(String sequence, String[] chain, boolean paired, boolean includeDelim) throws IllegalArgumentException
IllegalArgumentException
public static StringBuffer normalizeNonAlphanumeric(StringBuffer sequence)
sequence
- to normalize.public static String objectToString(Object o)
public static String[] parseIntoLines(String string) throws IOException
IOException
public static int stringToDecimal(String value)
public static List tokenize(String sequence, String[] chain, boolean paired, boolean includeDelim) throws IllegalArgumentException
sequence
- to be tokenized.chain
- list of delimiters to use cyclically.paired
- process delimiters in pairs, returning token between themincludeDelim
- append delimiter to tokenIllegalArgumentException
- if original String is nullCopyright © 2016. All rights reserved.