Package com.sun.javatest.util
Class StringArray
java.lang.Object
com.sun.javatest.util.StringArray
A class to convert to and from a single string with space separated
substrings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Does the string array contain the target string? Since the list is assumed to have no particular structure, the performance of this search is O(n).static boolean
Does the list contain the target string? This method is string parsing intensive, use with caution.static String
Converts an array of strings into a single space separated string.static String
Converts an array of strings into a single string, * using a specified separator.static String[]
Convert a single whitespace separated string into it's component substrings.static String[]
Split up a comma separated list of values.
-
Constructor Details
-
StringArray
public StringArray()
-
-
Method Details
-
split
Convert a single whitespace separated string into it's component substrings. The substrings can be separated by one or more instances of a space (' '), tab ('\t') or newline ('\n').- Parameters:
s
- The string to break apart. A null string will not cause an error.- Returns:
- Provides the substrings of the given parameter. If the provided string was null or all whitespace, an empty array (length==0) is returned.
-
join
Converts an array of strings into a single space separated string. The strings are appended to the resulting string in ascending index order, left to right. A single space character is used to delimit the values in the resulting string.- Parameters:
ss
- The strings which should be concatenated together. A zero length or null value will not cause an error.- Returns:
- The string which is made up of all the strings provided. The return value is a zero length string if the input value was null or zero length.
-
join
Converts an array of strings into a single string, * using a specified separator. The strings are appended to the resulting string in ascending index order, left to right. A specified separator is used to delimit the values in the resulting string.- Parameters:
ss
- The strings which should be concatenated together. A zero length or null value will not cause an error.sep
- The separator to place between the elements of the string array in the concatenated result- Returns:
- The string which is made up of all the strings provided. The return value is a zero length string if the input value was null or zero length.
-
splitList
Split up a comma separated list of values. Whitespace after each delimiter is removed.- Parameters:
list
- The string to parse for items. Null or zero length strings ok.delim
- The string which separates items in the list. Must be non-null and have a length greater than zero.- Returns:
- The extracted items from the list. Will only be null if the input string is null or zero length.
-
contains
Does the string array contain the target string? Since the list is assumed to have no particular structure, the performance of this search is O(n).- Parameters:
list
- The list of strings to search, null is ok.- Returns:
- True if it does, false otherwise. Will the false if the list was null.
-
contains
Does the list contain the target string? This method is string parsing intensive, use with caution.- Returns:
- True if it does, false otherwise.
-