Class Array

    • Method Detail

      • isArray

        public static boolean isArray​(Element arrayE)
        Utility method to check if an XML element is an array.
        Parameters:
        arrayE - the XML element to check
        Returns:
        returns true if the XML element is an array
      • create

        public static Array create​(Element arrayE)
                            throws Exception
        Static factory method for creating non-sparse or sparse array types as needed.
        Parameters:
        arrayE - the XML element encapsulating the array
        Returns:
        an appropriate Array type
        Throws:
        Exception - if there is a problem when constructing the array
      • getType

        public Array.ArrayType getType()
        Get the type of this array.
        Returns:
        the type of the array.
      • isSparse

        public boolean isSparse()
        Is this array a SparseArray?
        Returns:
        true if this array is sparse.
      • numValues

        public int numValues()
        Get the number of values in this array.
        Returns:
        the number of values in this array.
      • contains

        public boolean contains​(String value)
        Returns true if the array contains this string value.
        Parameters:
        value - the value to check for.
        Returns:
        true if the array contains this string value
      • contains

        public boolean contains​(int value)
        Returns true if the array contains this integer value.
        Parameters:
        value - the value to check for
        Returns:
        true if the array contains this integer value
      • contains

        public boolean contains​(double value)
        Returns true if the array contains this real value.
        Parameters:
        value - the value to check for
        Returns:
        true if the array contains this real value
      • contains

        public boolean contains​(float value)
        Returns true if the array contains this real value.
        Parameters:
        value - the value to check for
        Returns:
        true if the array contains this real value
      • index

        public int index​(int position)
        Returns the index of the value stored at the given position
        Parameters:
        position - the position
        Returns:
        the index of the value stored at the given position
      • value

        public String value​(int index)
                     throws Exception
        Gets the value at index from the array.
        Parameters:
        index - the index of the value to get.
        Returns:
        the value at index in the array as as String.
        Throws:
        Exception - if index is out of bounds.
      • valueString

        public String valueString​(int index)
                           throws Exception
        Gets the value at index from the array as a String. Calls value().
        Parameters:
        index - the index of the value to get.
        Returns:
        the value at index in the array as a String.
        Throws:
        Exception - if index is out of bounds.
      • valueDouble

        public double valueDouble​(int index)
                           throws Exception
        Gets the value at index from the array as a double.
        Parameters:
        index - the index of the value to get.
        Returns:
        the value at index in the array as a double.
        Throws:
        Exception - if index is out of bounds.
      • valueFloat

        public float valueFloat​(int index)
                         throws Exception
        Gets the value at index from the array as a float.
        Parameters:
        index - the index of the value to get.
        Returns:
        the value at index in the array as a float.
        Throws:
        Exception - if index is out of bounds.
      • valueInt

        public int valueInt​(int index)
                     throws Exception
        Gets the value at index from the array as an int.
        Parameters:
        index - the index of the value to get.
        Returns:
        the value at index in the array as an int.
        Throws:
        Exception - if index is out of bounds.
      • valueSparse

        public String valueSparse​(int indexOfIndex)
                           throws Exception
        Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
        Parameters:
        indexOfIndex - the index of the index of the value to get.
        Returns:
        a value from the array as a String.
        Throws:
        Exception - if indexOfIndex is out of bounds.
      • valueSparseString

        public String valueSparseString​(int indexOfIndex)
                                 throws Exception
        Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
        Parameters:
        indexOfIndex - the index of the index of the value to get.
        Returns:
        a value from the array as a String.
        Throws:
        Exception - if indexOfIndex is out of bounds.
      • valueSparseDouble

        public double valueSparseDouble​(int indexOfIndex)
                                 throws Exception
        Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
        Parameters:
        indexOfIndex - the index of the index of the value to get.
        Returns:
        a value from the array as a double.
        Throws:
        Exception - if indexOfIndex is out of bounds.
      • valueSparseFloat

        public float valueSparseFloat​(int indexOfIndex)
                               throws Exception
        Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
        Parameters:
        indexOfIndex - the index of the index of the value to get.
        Returns:
        a value from the array as a float.
        Throws:
        Exception - if indexOfIndex is out of bounds.
      • valueSparseInt

        public int valueSparseInt​(int indexOfIndex)
                           throws Exception
        Gets the value at indexOfIndex from the array. Does the same as value() if this array is not sparse.
        Parameters:
        indexOfIndex - the index of the index of the value to get.
        Returns:
        a value from the array as an int.
        Throws:
        Exception - if indexOfIndex is out of bounds.