public class StringUtil
extends com.labvantage.sapphire.gwt.shared.util.StringUtil
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
arrayToString(java.lang.String[] array,
java.lang.String delimiter)
converts an array to a string with delimiter
|
static java.lang.String |
escape(java.lang.String in)
Escapes a String as per the JavaScript escaping mechanism by converting (most) non-alphanumerics to %nn
|
static java.lang.String |
escapeXMLAttributeValue(java.lang.String attributeValue) |
static java.lang.String[] |
getExpressionTokens(java.lang.String input)
Returns a list of tokens (delimetered by [token]) in a string for a groovy or regular calculation expression
|
static long |
getLen(java.lang.String str)
Returns the length of a string checking for nulls as well as standard length
|
static java.lang.String |
getRandomString(int length)
Fetches you a random string
|
static java.lang.String |
getRGBHex(int value)
Returns an RGB numeric value in Hex format
|
static java.lang.String[] |
getTokens(java.lang.String input)
Returns a list of tokens (delimetered by [token]) in a string
|
static java.lang.String[] |
getTokens(java.lang.String input,
java.lang.String starttoken,
java.lang.String endtoken)
Returns a list of tokens (delimetered by [token]) in a string
|
static java.lang.String[] |
getTokens(java.lang.String input,
java.lang.String starttoken,
java.lang.String endtoken,
boolean ignoreCDATA)
Returns a list of tokens (delimetered by [token]) in a string
|
static java.lang.String[] |
getTokens(java.lang.String input,
java.lang.String starttoken,
java.lang.String endtoken,
boolean ignoreCDATA,
boolean keepDuplicate)
Returns a list of tokens (delimetered by [token]) in a string
|
static java.lang.String |
getYN(java.lang.String input,
java.lang.String defaultresponse)
Converts Yes/No, Y/N, yes/no, true/false, TRUE/FALSE etc.
|
static java.lang.String |
initCaps(java.lang.String in)
Converts the intial letter to caps in a string
|
static java.lang.String |
padLeft(java.lang.String input,
int desiredlength)
Pads the left side of a String with spaces to the desired length
|
static java.lang.String |
padLeft(java.lang.String input,
int desiredlength,
char padchar)
Pads the left side of a String with a specified character to the desired length
|
static java.lang.String |
padRight(java.lang.String input,
int desiredlength)
Pads the right side of a String with a specified character to the desired length
|
static java.lang.String |
padRight(java.lang.String input,
int desiredlength,
char padchar)
Pads the right side of a String with a specified character to the desired length
|
static java.lang.String |
repeat(java.lang.String basestring,
int repeat)
Returns a String that represents a given string repeated 'n' times
|
static java.lang.String |
repeat(java.lang.String basestring,
int repeat,
java.lang.String separator)
Returns a String that represents a given string repeated 'n' times delimited by the
separator
|
static java.lang.String |
replaceAll(java.lang.String inputString,
java.lang.String oldString,
java.lang.String newString)
Replaces all instances of a string in a string
|
static java.lang.String |
replaceAll(java.lang.String inputString,
java.lang.String oldString,
java.lang.String newString,
boolean caseSensitive)
Replaces all instances of a string in a string
|
static java.lang.String[] |
split(java.lang.String input,
java.lang.String delimeter)
Splits a string into an array of substrings
|
static java.lang.String[] |
split(java.lang.String input,
java.lang.String delimeter,
boolean trim)
Splits a string into an array of substrings
|
static java.lang.String |
unescape(java.lang.String in)
Unescapes a String as per the JavaScript unescaping mechanism by converting %nn text to their ascii equivalent
|
public static java.lang.String arrayToString(java.lang.String[] array, java.lang.String delimiter)
array
- The array to convertdelimiter
- the delimiter (defaults to ;).public static java.lang.String[] split(java.lang.String input, java.lang.String delimeter)
input
- the string to be parsed.delimeter
- character(s) that indicate breaks in the source String.
Note that two adjacent delimiters constitutes an additional blank entry
in the final list. For example, parsing "A;B;;C;" will return five substrings.public static java.lang.String[] split(java.lang.String input, java.lang.String delimeter, boolean trim)
input
- the string to be parsed.delimeter
- character(s) that indicate breaks in the source String.trim
- removes white space after spliting the values
Note that two adjacent delimiters constitutes an additional blank entry
in the final list. For example, parsing "A;B;;C;" will return five substrings.public static java.lang.String replaceAll(java.lang.String inputString, java.lang.String oldString, java.lang.String newString, boolean caseSensitive)
inputString
- The String to change things inoldString
- the text that is to be replace.newString
- the new text the old text will be replaced withcaseSensitive
- boolean to indicate whether matching is case sensitive or notpublic static java.lang.String replaceAll(java.lang.String inputString, java.lang.String oldString, java.lang.String newString)
inputString
- The String to change things inoldString
- the text that is to be replace.newString
- the new text the old text will be replaced withpublic static java.lang.String getRandomString(int length)
length
- public static java.lang.String getRGBHex(int value)
value
- Numeric value representing the RGB value (65536*Blue)+(256+Green)+(Red)public static java.lang.String repeat(java.lang.String basestring, int repeat)
basestring
- the string that is to be repeatedrepeat
- the number of times to repeatpublic static java.lang.String repeat(java.lang.String basestring, int repeat, java.lang.String separator)
basestring
- the string that is to be repeatedrepeat
- the number of times to repeatseparator
- the string to be padded between every repetitionpublic static long getLen(java.lang.String str)
str
- the string to be checked.public static java.lang.String[] getExpressionTokens(java.lang.String input)
input
- the String to be parsed.public static java.lang.String[] getTokens(java.lang.String input)
input
- the String to be parsed.public static java.lang.String[] getTokens(java.lang.String input, java.lang.String starttoken, java.lang.String endtoken)
input
- the String to be parsed.starttoken
- the starting delimeter text.endtoken
- the ending delimeter text.public static java.lang.String[] getTokens(java.lang.String input, java.lang.String starttoken, java.lang.String endtoken, boolean ignoreCDATA)
input
- the String to be parsed.starttoken
- the starting delimeter text.endtoken
- the ending delimeter text.ignoreCDATA
- ignore CDATA characters clashespublic static java.lang.String[] getTokens(java.lang.String input, java.lang.String starttoken, java.lang.String endtoken, boolean ignoreCDATA, boolean keepDuplicate)
input
- the String to be parsed.starttoken
- the starting delimeter text.endtoken
- the ending delimeter text.ignoreCDATA
- ignore CDATA characters clasheskeepDuplicate
- whether to keep duplicate tokenspublic static java.lang.String padLeft(java.lang.String input, int desiredlength)
input
- String to be padded.desiredlength
- required final length of the String. Note that the input String is never truncated.public static java.lang.String padLeft(java.lang.String input, int desiredlength, char padchar)
input
- String to be padded.desiredlength
- required final length of the String. Note that the input String is never truncated.padchar
- the character to pad the String with.public static java.lang.String padRight(java.lang.String input, int desiredlength)
input
- String to be padded.desiredlength
- required final length of the String. Note that the input String is never truncated.public static java.lang.String padRight(java.lang.String input, int desiredlength, char padchar)
input
- String to be padded.desiredlength
- required final length of the String. Note that the input String is never truncated.padchar
- the character to pad the String with.public static java.lang.String getYN(java.lang.String input, java.lang.String defaultresponse)
input
- String to be parsed.defaultresponse
- value to return if input value is null or empty Stringpublic static java.lang.String escape(java.lang.String in)
in
- String to be escaped.public static java.lang.String unescape(java.lang.String in)
in
- String to be unescaped.public static java.lang.String initCaps(java.lang.String in)
in
- String to be capitalizedpublic static java.lang.String escapeXMLAttributeValue(java.lang.String attributeValue)