Package ucar.nc2.grib

Class GribIndex

  • Direct Known Subclasses:
    Grib1Index, Grib2Index

    public abstract class GribIndex
    extends Object
    Abstract superclass for Grib1Index and Grib2Index. Handles gbx9 index for grib.

    Static methods for creating gbx9 indices for a single file.

    Since:
    9/5/11
    • Constructor Detail

      • GribIndex

        public GribIndex()
    • Method Detail

      • open

        @Nullable
        public static GribIndex open​(boolean isGrib1,
                                     MFile mfile)
      • readOrCreateIndexFromSingleFile

        public static GribIndex readOrCreateIndexFromSingleFile​(boolean isGrib1,
                                                                MFile mfile,
                                                                CollectionUpdateType force,
                                                                org.slf4j.Logger logger)
                                                         throws IOException
        Create a gbx9 index from a single grib1 or grib2 file. Use the existing index if it already exists.
        Parameters:
        isGrib1 - true if grib1
        mfile - the grib file
        force - force writing index
        Returns:
        the resulting GribIndex
        Throws:
        IOException - on io error
      • readIndex

        public abstract boolean readIndex​(String location,
                                          long dataModified,
                                          CollectionUpdateType force)
        Read the gbx9 index file.
        Parameters:
        location - location of the data file
        dataModified - last modified date of the data file
        force - rewrite? always, test, nocheck, never
        Returns:
        true if index was successfully read, false if index must be (re)created
      • makeIndex

        public abstract boolean makeIndex​(String location,
                                          RandomAccessFile dataRaf)
                                   throws IOException
        Make the gbx9 index file.
        Parameters:
        location - location of the data file
        dataRaf - already opened data raf (leave open); if null, makeIndex opens and closes)
        Returns:
        true
        Throws:
        IOException - on io error
      • getNRecords

        public abstract int getNRecords()
        The number of records in the index.
        Returns:
        The number of records in the index.