public class Text
extends java.lang.Object
Constructor and Description |
---|
Text() |
Modifier and Type | Method and Description |
---|---|
static java.util.ArrayList<java.lang.String> |
complement(java.util.ArrayList<java.lang.String> listA,
java.util.ArrayList<java.lang.String> listB)
Create an ArrayList of strings containing the complement of two lists.
|
static java.lang.String |
concatPath(java.lang.String path1,
java.lang.String path2)
Concatenate two paths ensuring that a file separator exists between each part.
|
static java.lang.String |
concatPath(java.lang.String path1,
java.lang.String path2,
java.lang.String separator)
Concatenate two paths ensuring that a file separator exists between each part.
|
static boolean |
endsWith(java.lang.String check,
java.lang.String suffix)
Check if a string ends with a specific value
|
static java.lang.String |
getFile(java.lang.String pathName)
Get the file name portion of a pathname.
|
static java.lang.String |
getFileBase(java.lang.String fileName)
Get the base portion of a file name.
|
static java.lang.String |
getMaskedValue(java.lang.String mask,
java.lang.String value)
Returns the non-mask portion of a string.
|
static java.util.ArrayList<java.lang.String> |
getMatchList(java.util.ArrayList<java.lang.String> terms,
java.util.ArrayList<java.lang.String> list)
Create an ArrayList of all words in a list that match words in a list.
|
static java.util.ArrayList<java.lang.String> |
getMatchList(java.lang.String[] terms,
java.util.ArrayList<java.lang.String> list)
Create an ArrayList of all words in an array that match words in a list.
|
static java.lang.String |
getPath(java.lang.String pathName)
Get the path name portion of a pathname.
|
static int |
getToken(java.lang.String value,
java.lang.String[] list)
Returns the index of the matching item in a list.
|
static java.lang.String |
getURIPath(java.lang.String pathName)
Get the path name portion of a URI.
|
static java.lang.String |
getURLPath(java.lang.String pathName)
Get the path name portion of a URL.
|
static boolean |
getValue(java.lang.String value,
boolean defaultValue)
Returns a value if set (non-null) or the default if not set.
|
static java.lang.String |
getValue(java.lang.String value,
java.lang.String defaultValue)
Returns a value if set (non-null) or the default if not set.
|
static java.lang.String |
getYesNo(boolean state)
Return a string representing the boolean state.
|
static java.util.ArrayList<java.lang.String> |
intersection(java.util.ArrayList<java.lang.String> listA,
java.util.ArrayList<java.lang.String> listB)
Create an ArrayList of strings containing the intersection of two lists.
|
static java.lang.String |
isChecked(java.lang.String base,
java.lang.String value)
Compares a value to a sample string.
|
static boolean |
isEmpty(java.lang.String value)
Determine if a string is empty or not defined.
|
static boolean |
isInList(java.lang.String term,
java.util.ArrayList<java.lang.String> list)
Check if an item is in a list
|
static boolean |
isInList(java.lang.String term,
java.lang.String[] list)
Check if an item is in a list
|
static boolean |
isInPrefixList(java.lang.String term,
java.util.ArrayList<java.lang.String> list)
Check if the term starts with any item in the list.
|
static boolean |
isInPrefixList(java.lang.String term,
java.lang.String[] list)
Check if the term starts with any item in the list.
|
static boolean |
isListEmpty(java.util.ArrayList<java.lang.String> list)
Determine if an ArrayList is empty or not defined.
|
static boolean |
isMatch(java.util.ArrayList<java.lang.String> base,
java.util.ArrayList<java.lang.String> test)
Compares a list of strings to another and returns true if they match.
|
static boolean |
isMatch(java.lang.String base,
java.lang.String test)
Compares one string to another and returns true if they match.
|
static boolean |
isSetMatch(java.util.ArrayList<java.lang.String> base,
java.util.ArrayList<java.lang.String> test)
Compares a list of strings to another and returns true if they match.
|
static boolean |
isSetMatch(java.lang.String base,
java.lang.String test)
Compares one string to another and returns true if they match.
|
static boolean |
isTrue(java.lang.String value)
Determine if a string is equivalent to a true/false state.
|
static boolean |
isTrue(java.lang.String value,
boolean defaultValue)
Determine is a string is equivalent to a true/false state.
|
static java.lang.String |
makeList(java.util.ArrayList<java.lang.String> list)
Construct a comma separated list of values from an ArrayList of Strings.
|
static java.lang.String |
makeList(java.util.ArrayList<java.lang.String> list,
boolean quoted)
Construct a comma separated list of values from an ArrayList of Strings.
|
static java.lang.String |
makeList(java.lang.String[] list)
Construct a comma separated list of values from an array of Strings.
|
static java.lang.String |
makeList(java.lang.String[] list,
boolean quoted)
Construct a comma separated list of values from an array of Strings.
|
static java.lang.String |
pad(java.lang.String base,
int max)
Pad a string with spaces to a fixed width.
|
static java.lang.String[] |
parseList(java.lang.String text)
Parse a comma separated list into an array of Strings, trimming extra white space.
|
static java.lang.String |
replaceAll(java.lang.String regex,
java.lang.String value,
java.lang.String opon)
Replace patterns in a string and return the result.
|
static java.lang.String[] |
splitMixedCase(java.lang.String text)
Divide a string on capital letters that follow lowercase letters
|
static boolean |
startsWith(java.lang.String check,
java.lang.String prefix)
Check if a string starts with a specific value
|
static java.util.ArrayList<java.lang.String> |
toArrayList(java.lang.String[] list)
Convert an
String array to an array list of strings. |
static long |
toBytes(java.lang.String value)
Convert a string with a unitized to a byte count.
|
static long |
toBytes(java.lang.String bytes,
java.lang.String units)
Convert a string and units to a byte count.
|
static double |
toDouble(java.lang.String value)
Converts a string to a double.
|
static java.lang.String |
toDuration(long millis)
Format a count of milliseconds into a HH:mm:ss.SSS duration string.
|
static java.lang.String |
toImproperCase(java.lang.String value)
Convert a string to "improper" case by converting the
first letter to lower case.
|
static int |
toInt(java.lang.String value)
Converts a string to a int.
|
static java.lang.String |
toLowerCase(java.lang.String value)
Convert a string to lower case.
|
static java.lang.String |
toProperCase(java.lang.String value)
Convert a string to proper case by capitalizing the first letter.
|
static java.lang.String |
toThousands(long value)
Convert a long value into a thousands delimited string.
|
static java.lang.String |
toTitleCase(java.lang.String s)
Convert a string to title case by capitalizing the first letter of each word.
|
static java.lang.String |
toUnitizedBytes(long bytes)
Converts a count of bytes into a concise count string with
units like KB, MB, GB.
|
static java.lang.String |
toUpperCase(java.lang.String value)
Convert a string to upper case.
|
static java.lang.String |
trim(java.lang.String opon)
Trim the leading and trailing spaces from a string and return the result.
|
static java.util.ArrayList<java.lang.String> |
uniqueList(java.util.ArrayList<java.lang.String> list,
boolean dropNull)
Create an ArrayList of strings containing unique values.
|
static java.lang.String |
wordWrap(java.lang.String text,
int width,
java.lang.String prefix)
Wrap a string of text so that no line is longer than a given width.
|
static java.lang.String |
zeroPad(java.lang.String base,
int max)
Pad a number with leading zeros to the count given.
|
public static boolean isEmpty(java.lang.String value)
value
- The string to test.true
if the string has zero length or is null.
false
otherwise.public static boolean isListEmpty(java.util.ArrayList<java.lang.String> list)
list
- a list of values.true
if the list has zero length elements or is null.
false
otherwise.public static java.lang.String getYesNo(boolean state)
state
- A boolean set to true or false.public static java.lang.String isChecked(java.lang.String base, java.lang.String value)
base
- The value to compare to the "value" argument.value
- The value to test.public static int getToken(java.lang.String value, java.lang.String[] list)
value
- the value to search for in the list.list
- An array of strings to search.public static java.lang.String getMaskedValue(java.lang.String mask, java.lang.String value)
mask
- the mask pattern to use. A star (*) identifies indicates the desired non-mask portion.value
- the value to mask and extract the value from.public static java.lang.String getValue(java.lang.String value, java.lang.String defaultValue)
value
- the preferred value if set.defaultValue
- the default value.public static boolean getValue(java.lang.String value, boolean defaultValue)
value
- the text string for a boolean value.defaultValue
- the default value.public static boolean isTrue(java.lang.String value)
value
- the value to determine its boolean equivalent.public static boolean isTrue(java.lang.String value, boolean defaultValue)
value
- the value to determine its boolean equivalent.defaultValue
- the default value.public static java.lang.String toTitleCase(java.lang.String s)
value
- the string to convert to title case.public static java.lang.String toProperCase(java.lang.String value)
value
- the string to convert to proper case.public static java.lang.String toLowerCase(java.lang.String value)
value
- the string to convert to proper case.public static java.lang.String toUpperCase(java.lang.String value)
value
- the string to convert to proper case.public static java.lang.String toImproperCase(java.lang.String value)
value
- the string to convert to improper case.public static java.lang.String zeroPad(java.lang.String base, int max)
base
- the string containing the value.max
- the maximum length for the return string.public static java.lang.String pad(java.lang.String base, int max)
base
- the string containing the value.max
- the maximum length for the return string.public static boolean isSetMatch(java.lang.String base, java.lang.String test)
base
- the string to compare to the test value.test
- the value to compare to the base.true
if the two strings match, otherwise false
public static boolean isSetMatch(java.util.ArrayList<java.lang.String> base, java.util.ArrayList<java.lang.String> test)
base
- the array of strings to compare to the test values.test
- the array of values to compare to the base.true
if the two strings match, otherwise false
public static boolean isMatch(java.lang.String base, java.lang.String test)
null
is considered a wild card.base
- the string to compare to the test value.test
- the value to compare to the base.true
if the two strings match, otherwise false
public static boolean isMatch(java.util.ArrayList<java.lang.String> base, java.util.ArrayList<java.lang.String> test)
null
is considered a wild card.base
- the array of strings to compare to the test values.test
- the array of values to compare to the base.true
if the two strings match, otherwise false
public static java.lang.String[] parseList(java.lang.String text)
text
- the string to parse.String
values.public static java.lang.String makeList(java.lang.String[] list)
list
- An array of String
values.String
containing a comma separated list of values.public static java.lang.String makeList(java.lang.String[] list, boolean quoted)
list
- An array of String
values.quoted
- determined if each value should be enclosed in double quotes (").String
containing a comma separated list of values.public static java.lang.String makeList(java.util.ArrayList<java.lang.String> list)
list
- An array of String
values.public static java.lang.String makeList(java.util.ArrayList<java.lang.String> list, boolean quoted)
list
- An array of String
values.public static java.lang.String wordWrap(java.lang.String text, int width, java.lang.String prefix)
text
- the text string to word wrap.width
- the maximum width for a line of text.prefix
- text to add at the beginning of each line.public static java.util.ArrayList<java.lang.String> uniqueList(java.util.ArrayList<java.lang.String> list, boolean dropNull)
list
- the list of values to scan.dropNull
- flag indicating whether null values should be dropped.public static java.util.ArrayList<java.lang.String> intersection(java.util.ArrayList<java.lang.String> listA, java.util.ArrayList<java.lang.String> listB)
listA
- a list of values to scan.listB
- a list of values to scan.public static java.util.ArrayList<java.lang.String> complement(java.util.ArrayList<java.lang.String> listA, java.util.ArrayList<java.lang.String> listB)
listA
- a list of values to scan.listB
- a list of values to scan.public static boolean isInList(java.lang.String term, java.util.ArrayList<java.lang.String> list)
term
- the term (phrase) to search for in the list.list
- the ArrayList of Strings to search.true
if the term is in the list, false
otherwise.public static boolean isInList(java.lang.String term, java.lang.String[] list)
term
- the term (phrase) to search for in the list.list
- the array of Strings to search.true
if the term is in the list, false
otherwise.public static boolean isInPrefixList(java.lang.String term, java.lang.String[] list)
term
- the term (phrase) to search for in the list.list
- the array of Strings to search.true
if the term starts with any item in the list, false
otherwise.public static boolean isInPrefixList(java.lang.String term, java.util.ArrayList<java.lang.String> list)
term
- the term (phrase) to search for in the list.list
- the array of Strings to search.true
if the term starts with any item in the list, false
otherwise.public static java.util.ArrayList<java.lang.String> getMatchList(java.lang.String[] terms, java.util.ArrayList<java.lang.String> list)
terms
- the array of phrases to search for in the list.list
- the ArrayList of Strings to search.public static java.util.ArrayList<java.lang.String> getMatchList(java.util.ArrayList<java.lang.String> terms, java.util.ArrayList<java.lang.String> list)
terms
- the ArrayList
of phrases to search for in the list.list
- the ArrayList
of String
s to search.public static java.util.ArrayList<java.lang.String> toArrayList(java.lang.String[] list)
String
array to an array list of strings.list
- an array of strings to convert to an ArrayList
ArrayList
of String
s.public static long toBytes(java.lang.String value)
toBytes(String bytes, String units)
.value
- a string containing a unitized count.public static long toBytes(java.lang.String bytes, java.lang.String units)
bytes
- a string a count.units
- a string the units to apply to the count.public static java.lang.String toUnitizedBytes(long bytes)
bytes
- a count.public static java.lang.String toThousands(long value)
value
- the value to convert.public static java.lang.String getFileBase(java.lang.String fileName)
fileName
- the name of the file to parse.public static java.lang.String getFile(java.lang.String pathName)
pathName
- the path to a file. Full or partial path is permited.public static java.lang.String getPath(java.lang.String pathName)
pathName
- the path to a file. Full or partial path is permitted.public static java.lang.String getURIPath(java.lang.String pathName)
pathName
- the path to a file. Full or partial path is permitted.public static java.lang.String getURLPath(java.lang.String pathName)
pathName
- the path to a file. Full or partial path is permitted.public static java.lang.String concatPath(java.lang.String path1, java.lang.String path2, java.lang.String separator)
path1
- the first part of the path.path2
- the second part of the path.separator
- the string to place between the first and second part of the path.public static java.lang.String concatPath(java.lang.String path1, java.lang.String path2)
path1
- the first part of the path.path2
- the second part of the path.public static java.lang.String[] splitMixedCase(java.lang.String text)
text
- the string to split on capital letters.public static int toInt(java.lang.String value)
value
- a string representation of a value.public static double toDouble(java.lang.String value)
value
- a string representation of a value.public static java.lang.String replaceAll(java.lang.String regex, java.lang.String value, java.lang.String opon)
regex
- regular expression for pattern to find.value
- The value to replace each found pattern.opon
- a string to operate on.public static java.lang.String trim(java.lang.String opon)
opon
- a string to operate on.public static boolean endsWith(java.lang.String check, java.lang.String suffix)
check
- a string to checksuffix
- the suffix value to look for.public static boolean startsWith(java.lang.String check, java.lang.String prefix)
check
- a string to checkprefix
- the prefix value to look for.public static java.lang.String toDuration(long millis)
millis
- the count of milliseconds.Copyright © 2008-2018 Regents University of California. All Rights Reserved.