Package org.jibx.util

Class StringArray


  • public class StringArray
    extends Object
    Wrapper for arrays of ordered strings. This verifies the arrays and supports efficient lookups.
    Author:
    Dennis M. Sosnoski
    • Field Detail

      • EMPTY_ARRAY

        public static final StringArray EMPTY_ARRAY
        Empty array of strings.
    • Constructor Detail

      • StringArray

        public StringArray​(String[] list)
        Constructor from array of values. This checks the array values to make sure they're ordered and unique, and if they're not throws an exception. Once the array has been passed to this constructor it must not be modified by outside code.
        Parameters:
        list - array of values
      • StringArray

        public StringArray​(String[] list,
                           StringArray base)
        Constructor from array of values to be added to base instance. This merges the array values, making sure they're ordered and unique, and if they're not throws an exception.
        Parameters:
        list - array of values
        base - base instance
      • StringArray

        public StringArray​(StringArray array1,
                           StringArray array2)
        Constructor from pair of base instances. This merges the values, making sure they're unique, and if they're not throws an exception.
        Parameters:
        array1 - first base array
        array2 - second base array
      • StringArray

        public StringArray​(String[] list,
                           StringArray array1,
                           StringArray array2)
        Constructor from array of values to be added to pair of base instances. This merges the array values, making sure they're ordered and unique, and if they're not throws an exception.
        Parameters:
        list - array of values
        array1 - first base array
        array2 - second base array
      • StringArray

        public StringArray​(String[] list,
                           StringArray array1,
                           StringArray array2,
                           StringArray array3)
        Constructor from array of values to be added to three base instances. This merges the array values, making sure they're ordered and unique, and if they're not throws an exception.
        Parameters:
        list - array of values
        array1 - first base array
        array2 - second base array
        array3 - third base array
      • StringArray

        public StringArray​(String[] list,
                           StringArray array1,
                           StringArray array2,
                           StringArray array3,
                           StringArray array4)
        Constructor from array of values to be added to four base instances. This merges the array values, making sure they're ordered and unique, and if they're not throws an exception.
        Parameters:
        list - array of values
        array1 - first base array
        array2 - second base array
        array3 - third base array
        array4 - fourth base array
    • Method Detail

      • get

        public String get​(int index)
        Get string at a particular index in the list.
        Parameters:
        index - list index to be returned
        Returns:
        string at that index position
      • indexOf

        public int indexOf​(String value)
        Find index of a particular string in the array. This does a binary search through the array values, using a pair of index bounds to track the subarray of possible matches at each iteration.
        Parameters:
        value - string to be found in list
        Returns:
        index of string in array, or -1 if not present
      • size

        public int size()
        Get number of values in array
        Returns:
        number of values in array