Class StringArray

java.lang.Object
com.sun.javatest.util.StringArray

public class StringArray extends Object
A class to convert to and from a single string with space separated substrings.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(String[] list, String target)
    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
    contains(String list, String target)
    Does the list contain the target string? This method is string parsing intensive, use with caution.
    static String
    join(String... ss)
    Converts an array of strings into a single space separated string.
    static String
    join(String[] ss, String sep)
    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[]
    splitList(String list, String delim)
    Split up a comma separated list of values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StringArray

      public StringArray()
  • Method Details

    • split

      public static String[] split(String s)
      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

      public static String join(String... ss)
      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

      public static String join(String[] ss, String sep)
      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

      public static String[] splitList(String list, String delim)
      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

      public static boolean contains(String[] list, String target)
      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

      public static boolean contains(String list, String target)
      Does the list contain the target string? This method is string parsing intensive, use with caution.
      Returns:
      True if it does, false otherwise.