public class UtlText extends Object
This class IS NOT intended to be used by end users.
Constructor and Description |
---|
UtlText() |
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHexString(byte[] bytes)
Encodes input byte array as String of hexadecimal digits.
|
static String |
deCamelCase(String camelCase)
Takes a camel case string and splits into to a space separated string
|
static byte[] |
hexToBytes(String hexString)
Converts a hexadecimal string to a byte array after first stripping
an spaces from the provided text.
|
static boolean |
isNullOrEmpty(String text) |
static String[] |
parseAsArgs(String argString,
boolean preserveInnerEscapes)
Parses the provided argsString into a set of tokens delimited by spaces.
|
static String[] |
parseAsArgs(String argString,
boolean preserveInnerEscapes,
boolean preserveQuotes)
Parses the provided argsString into a set of tokens delimited by spaces.
|
static String |
quoteAndEscape(String string)
If the given string contains spaces or quotes, quote it and escape an inner
quotes in the sting.
|
static String |
readFully(InputStream input,
String charset)
Reads an InputStream fully as a string.
|
static String |
removeLineBreaks(String text)
Removes line breaks for the given text, replacing breaks with a single space.
|
static String[] |
retokenizeWithQuotes(StringTokenizer tokenizer,
boolean preserveInnerEscapes)
Given a StringTokenizer this method concatenates all tokens into a string
delimited by a single space.
|
static LinkedList<String> |
splitCamelCaseString(String s)
accept a string, like aCamelString and return
a list containing strings, in this case, [a, Camel, String]
|
static boolean |
startsWithIgnoreCase(String text,
String prefix)
Indicates whether the provided text begins with the prefix, without regard for capitalization.
|
static String |
stripQuotesAndUnescape(String string)
Strips leading and trailing quotes from the given string, if the
String starts with a leading '"' character, and unescapes
any escaped '"' within the quoted string.
|
static String |
toCamelCase(String text,
boolean includeFirstLetter)
Converts text to camel case.
|
static String |
toFirstLetterLowercase(String str)
Returns a string with lowercase first letter.
|
static String |
toFirstLetterUppercase(String str)
Returns a string with uppercases first letter.
|
static double |
uniformMetric(String text)
Map a string to it's location in a uniform distribution of text, with resulting value between 0.0 and 1.0,
excluding 1.0 itself.
|
static String |
upperCaseFirstLetters(String str)
Changes the first letter of each word in the provided string to uppercase.
|
public static double uniformMetric(String text)
text
- The text to examine.public static String toFirstLetterUppercase(String str)
str
- The stringpublic static String toFirstLetterLowercase(String str)
str
- The stringpublic static boolean startsWithIgnoreCase(String text, String prefix)
text
- The text to examine.prefix
- The prefix to check for.true if the text starts with the prefix.
public static boolean isNullOrEmpty(String text)
text
- to check.public static String removeLineBreaks(String text)
text
- The text from which to remove line breaks.public static String toCamelCase(String text, boolean includeFirstLetter)
text
- the text to be camelcased.includeFirstLetter
- Whether or not to uppercase the first letter or leave it as is.public static final String deCamelCase(String camelCase)
camelCase
- The camel case inputpublic static String upperCaseFirstLetters(String str)
str
- The str to augment.public static LinkedList<String> splitCamelCaseString(String s)
s
- The str to split.public static final byte[] hexToBytes(String hexString)
hexString
- The hex encoded string.public static final String bytesToHexString(byte[] bytes)
bytes
- Array to convert.public static final String[] retokenizeWithQuotes(StringTokenizer tokenizer, boolean preserveInnerEscapes)
'"' or ''' encountered within quotes can be escaped by prefixing them with a '\'. When in a quote block such tokens are either converted represented in the resulting token either with the escape preserved or removed accoring to the value of preserverInnerEscapes.
tokenizer
- The tokenizer to retokenize.preserveInnerEscapes
- If true escape characters inside of quotes are preservedpublic static final String[] parseAsArgs(String argString, boolean preserveInnerEscapes)
This call is equivalent to calling parseAsArgs(argString, preserveInnerEscapes, false)
argString
- The string to parse into arguments.preserveInnerEscapes
- If true escape characters inside of quotes are preserved.IllegalArgumentException
- If the argsString has unbalanced quotes.public static final String[] parseAsArgs(String argString, boolean preserveInnerEscapes, boolean preserveQuotes)
Single or double quotes can be used within the argument string to allow arguments
that contain spaces. '"' or ''' encountered within quotes can be escaped by prefixing
them with a '\'. Escape characters are removed from quoted strings in the returned
set of arguments unless preserveInnerEscapes=false
or preserveQuotes=true
argString
- The string to parse into arguments.preserveInnerEscapes
- If true escape characters inside of quotes are preserved.
This value is ignored if preserveQuotes is set to true
.preserveQuotes
- If true the quotes around quoted arguments are preserved.IllegalArgumentException
- If the argsString has unbalanced quotes.public static final String quoteAndEscape(String string)
string
- The string to quote.public static final String stripQuotesAndUnescape(String string)
string
- The string to strip.public static final String readFully(InputStream input, String charset) throws IOException
input
- The InputStreamcharset
- The character set to use for file contentIOException
- If there is an error reading the fileCopyright © 2019 Neeve Research, LLC. All Rights Reserved.