Class ArrayReader


  • public class ArrayReader
    extends java.lang.Object
    Reads values from a typed numeric array.
    Since:
    21 Jan 2022
    Author:
    Mark Taylor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ArrayReader forClass​(java.lang.Class<?> arrayClazz)
      Returns an instance of this class suitable for a given array class.
      int getLength​(java.lang.Object array)
      Returns array length for a suitable array object.
      double getValue​(java.lang.Object array, int index)
      Returns element numeric value for a suitable array object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getLength

        public int getLength​(java.lang.Object array)
        Returns array length for a suitable array object.
        Parameters:
        array - candidate array object
        Returns:
        array length if array is of type expected by this reader, otherwise -1
      • getValue

        public double getValue​(java.lang.Object array,
                               int index)
        Returns element numeric value for a suitable array object.
        Parameters:
        array - candidate array object
        Returns:
        numeric value of element index if array is of tye expected by this reader, otherwise Double.NaN
      • forClass

        public static ArrayReader forClass​(java.lang.Class<?> arrayClazz)
        Returns an instance of this class suitable for a given array class.
        Parameters:
        arrayClazz - class of arrays to read
        Returns:
        array reader instance for array objects of the submitted type, or null if nothing suitable is available