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