Package ucar.nc2.iosp

Class IospArrayHelper


  • public class IospArrayHelper
    extends Object
    Helper methods for IOSP's for reading data.
    • Constructor Detail

      • IospArrayHelper

        public IospArrayHelper()
    • Method Detail

      • readDataFill

        public static Object readDataFill​(RandomAccessFile raf,
                                          Layout index,
                                          ArrayType arrayType,
                                          Object fillValue,
                                          ByteOrder byteOrder)
                                   throws IOException
        Read data subset from RandomAccessFile, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.
        Parameters:
        raf - read from here.
        index - handles skipping around in the file.
        arrayType - ArrayType of the variable
        fillValue - must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
        byteOrder - if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before reading
        Returns:
        primitive array with data read in
        Throws:
        IOException - on read error
      • readData

        public static Object readData​(RandomAccessFile raf,
                                      Layout layout,
                                      ArrayType arrayType,
                                      Object arr,
                                      ByteOrder byteOrder)
                               throws IOException
        Read data subset from RandomAccessFile, place in given primitive array. Reading is controlled by the Layout object.
        Parameters:
        raf - read from here.
        layout - handles skipping around in the file.
        arrayType - ArrayType of the variable
        arr - primitive array to read data into
        byteOrder - if equal to RandomAccessFile.ORDER_XXXX, set the byte order just before reading
        Returns:
        primitive array with data read in
        Throws:
        IOException - on read error
      • readDataFill

        public static Object readDataFill​(PositioningDataInputStream is,
                                          Layout index,
                                          ArrayType ArrayType,
                                          Object fillValue)
                                   throws IOException
        Read data subset from PositioningDataInputStream, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.
        Parameters:
        is - read from here.
        index - handles skipping around in the file.
        ArrayType - ArrayType of the variable
        fillValue - must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
        Returns:
        primitive array with data read in
        Throws:
        IOException - on read error
      • readData

        public static Object readData​(PositioningDataInputStream raf,
                                      Layout index,
                                      ArrayType arrayType,
                                      Object arr)
                               throws IOException
        Read data subset from PositioningDataInputStream, place in given primitive array. Reading is controlled by the Layout object.
        Parameters:
        raf - read from here.
        index - handles skipping around in the file.
        arrayType - ArrayType of the variable
        arr - primitive array to read data into
        Returns:
        primitive array with data read in
        Throws:
        IOException - on read error
      • readDataFill

        public static Object readDataFill​(LayoutBB layout,
                                          ArrayType arrayType,
                                          Object fillValue)
        Read data subset from ByteBuffer, create primitive array of size Layout.getTotalNelems. Reading is controlled by the Layout object.
        Parameters:
        layout - handles skipping around in the file, provide ByteBuffer to read from
        arrayType - ArrayType of the variable
        fillValue - must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
        Returns:
        primitive array with data read in
      • readData

        public static Object readData​(LayoutBB layout,
                                      ArrayType arrayType,
                                      Object arr)
        Read data subset from ByteBuffer, place in given primitive array. Reading is controlled by the LayoutBB object.
        Parameters:
        layout - handles skipping around in the file, privide ByteBuffer to read from
        arrayType - ArrayType of the variable
        arr - primitive array to read data into
        Returns:
        the primitive array with data read in
      • makePrimitiveArray

        public static Object makePrimitiveArray​(int size,
                                                ArrayType arrayType)
        Create 1D primitive array of the given size and type
        Parameters:
        size - the size of the array to create
        arrayType - ArrayType of the variable
        Returns:
        primitive array with all zeroes
      • makePrimitiveArray

        public static Object makePrimitiveArray​(int size,
                                                ArrayType arrayType,
                                                Object fillValue)
        Create 1D primitive array of the given size and type, fill it with the given value
        Parameters:
        size - the size of the array to create
        arrayType - ArrayType of the variable
        fillValue - must be Number if ArrayType.isNumeric(), or String for STRING, byte[] for Structure, or null for none
        Returns:
        primitive array with data read in