Package ucar.nc2.iosp

Class AbstractIOServiceProvider

    • Field Detail

      • raf

        protected RandomAccessFile raf
        Subclasses that use AbstractIOServiceProvider.open(...) or .close() should use this (instead of their own private variable).
      • location

        protected String location
      • rafOrder

        protected int rafOrder
    • Constructor Detail

      • AbstractIOServiceProvider

        public AbstractIOServiceProvider()
    • Method Detail

      • open

        public void open​(RandomAccessFile raf,
                         NetcdfFile ncfile,
                         CancelTask cancelTask)
                  throws IOException
        Description copied from interface: IOServiceProvider
        Open existing file, and populate ncfile with it. This method is only called by the NetcdfFile constructor on itself. The provided NetcdfFile object will be empty except for the location String and the IOServiceProvider associated with this NetcdfFile object.
        Specified by:
        open in interface IOServiceProvider
        Parameters:
        raf - the file to work on, it has already passed the isValidFile() test.
        ncfile - add objects to this empty NetcdfFile
        cancelTask - used to monitor user cancellation; may be null.
        Throws:
        IOException - if read error
      • setNetcdfFile

        public void setNetcdfFile​(NetcdfFile ncfile)
      • build

        public void build​(RandomAccessFile raf,
                          Group.Builder rootGroup,
                          CancelTask cancelTask)
                   throws IOException
        Description copied from interface: IOServiceProvider
        Open existing file, and populate it. Note that you cannot reference the NetcdfFile within this routine. This is the bridge to immutable objects that will be used exclusively in version 6.
        Specified by:
        build in interface IOServiceProvider
        Parameters:
        raf - the file to work on, it has already passed the isValidFile() test.
        rootGroup - add objects to the root group.
        cancelTask - used to monitor user cancellation; may be null.
        Throws:
        IOException - if read error
      • close

        public void close()
                   throws IOException
        Description copied from interface: IOServiceProvider
        Close the file. It is the IOServiceProvider's job to close the file (even though it didnt open it), and to free any other resources it has used.
        Specified by:
        close in interface IOServiceProvider
        Throws:
        IOException - if read error
      • release

        public void release()
                     throws IOException
        Description copied from interface: IOServiceProvider
        Release any system resources like file handles. Optional, implement only if you are able to reacquire. Used when object is made inactive in cache.
        Specified by:
        release in interface IOServiceProvider
        Throws:
        IOException
      • readToByteChannel

        public long readToByteChannel​(Variable v2,
                                      Section section,
                                      WritableByteChannel channel)
                               throws IOException,
                                      InvalidRangeException
        Description copied from interface: IOServiceProvider
        Read data from a top level Variable and send data to a WritableByteChannel. Must be in big-endian order.
        Specified by:
        readToByteChannel in interface IOServiceProvider
        Parameters:
        v2 - a top-level Variable
        section - the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.
        channel - write data to this WritableByteChannel
        Returns:
        the number of bytes written to the channel
        Throws:
        IOException - if read error
        InvalidRangeException - if invalid section
      • readToOutputStream

        public long readToOutputStream​(Variable v2,
                                       Section section,
                                       OutputStream out)
                                throws IOException,
                                       InvalidRangeException
        Description copied from interface: IOServiceProvider
        Read data from a top level Variable and send data to a OutputStream. Must be in big-endian order, following ncstream conventions. Default implementation just reads to memory and writes to stream. Allow override for possible performance improvements.
        Specified by:
        readToOutputStream in interface IOServiceProvider
        Parameters:
        v2 - a top-level Variable
        section - the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.
        out - write data to this OutputStream
        Returns:
        the number of bytes written to the channel
        Throws:
        IOException - if read error
        InvalidRangeException - if invalid section
      • getStructureIterator

        public StructureDataIterator getStructureIterator​(Structure s,
                                                          int bufferSize)
                                                   throws IOException
        Description copied from interface: IOServiceProvider
        Get the structure iterator. iosps with top level sequences must override. Not threadsafe; do not use multiple StructureDataIterator for the same iosp.
        Specified by:
        getStructureIterator in interface IOServiceProvider
        Parameters:
        s - the Structure
        bufferSize - the buffersize
        Returns:
        the data iterator
        Throws:
        IOException - if problem reading data
      • sendIospMessage

        @Nullable
        public Object sendIospMessage​(@Nullable
                                      Object message)
        Description copied from interface: IOServiceProvider
        A way to communicate arbitrary information to and from an iosp.
        Specified by:
        sendIospMessage in interface IOServiceProvider
        Parameters:
        message - opaque message sent to the IOSP object when its opened (not when isValidFile() is called)
        Returns:
        opaque Object, may be null.
      • syncExtend

        public boolean syncExtend()
                           throws IOException
        Description copied from interface: IOServiceProvider
        Extend the NetcdfFile if the underlying dataset has changed in a way that is compatible with the current metadata. For example, if the unlimited dimension has grown.
        Specified by:
        syncExtend in interface IOServiceProvider
        Returns:
        true if the NetcdfFile was extended.
        Throws:
        IOException - if a read error occured when accessing the underlying dataset.
      • getLastModified

        public long getLastModified()
        Returns the time that the underlying file(s) were last modified. If they've changed since they were stored in the cache, they will be closed and reopened with FileFactory.
        Returns:
        a long value representing the time the file(s) were last modified or 0L if the last-modified time couldn't be determined for any reason.
      • getFileTypeVersion

        public String getFileTypeVersion()
        Description copied from interface: IOServiceProvider
        Get the version of this file type.
        Specified by:
        getFileTypeVersion in interface IOServiceProvider
        Returns:
        version of the file type
        See Also:
        "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"