ucar.nc2.iosp
Interface IOServiceProvider

All Known Subinterfaces:
IOServiceProviderWriter
All Known Implementing Classes:
AbstractIOServiceProvider, AddeServiceProvider, AreaServiceProvider, BufrIosp, Cinrad2IOServiceProvider, DMSPiosp, Doradeiosp, GempakGridServiceProvider, Giniiosp, Grib1ServiceProvider, Grib2ServiceProvider, GribServiceProvider, GridServiceProvider, GtopoIosp, H4iosp, H5iosp, JniIosp, McIDASGridServiceProvider, N3iosp, N3raf, Nexrad2IOServiceProvider, Nidsiosp, NmcObsLegacy, UFiosp

public interface IOServiceProvider

This is the service provider interface for the low-level I/O access classes (read only). This is only used by service implementors. The NetcdfFile class manages all registered IOServiceProvider classes. When NetcdfFile.open() is called:

  1. the file is opened as a ucar.unidata.io.RandomAccessFile;
  2. the file is handed to the isValidFile() method of each registered IOServiceProvider class (until one returns true, which means it can read the file).
  3. the open() method on the resulting IOServiceProvider class is handed the file.
  4. Author:
    caron
    See Also:
    ;

    Method Summary
     void close()
              Close the file.
     java.lang.String getDetailInfo()
              Show debug / underlying implementation details
     boolean isValidFile(RandomAccessFile raf)
              Check if this is a valid file for this IOServiceProvider.
     void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)
              Open existing file, and populate ncfile with it.
     Array readData(Variable v2, Section section)
              Read data from a top level Variable and return a memory resident Array.
     Array readSection(ParsedSectionSpec cer)
              Allows reading sections of nested variables
     long readToByteChannel(Variable v2, Section section, java.nio.channels.WritableByteChannel channel)
              Read data from a top level Variable and send data to a WritableByteChannel.
     java.lang.Object sendIospMessage(java.lang.Object message)
              A way to communicate arbitrary information to an iosp.
     boolean sync()
              Check if file has changed, and reread metadata if needed.
     boolean syncExtend()
              Extend the file if needed in a way that is compatible with the current metadata.
     java.lang.String toStringDebug(java.lang.Object o)
              Debug info for this object.
     

    Method Detail

    isValidFile

    boolean isValidFile(RandomAccessFile raf)
                        throws java.io.IOException
    Check if this is a valid file for this IOServiceProvider. You must make this method thread safe, ie dont keep any state.

    Parameters:
    raf - RandomAccessFile
    Returns:
    true if valid.
    Throws:
    java.io.IOException - if read error

    open

    void open(RandomAccessFile raf,
              NetcdfFile ncfile,
              CancelTask cancelTask)
              throws java.io.IOException
    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.

    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:
    java.io.IOException - if read error

    readData

    Array readData(Variable v2,
                   Section section)
                   throws java.io.IOException,
                          InvalidRangeException
    Read data from a top level Variable and return a memory resident Array. This Array has the same element type as the Variable, and the requested shape.

    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.
    Returns:
    the requested data in a memory-resident Array
    Throws:
    java.io.IOException - if read error
    InvalidRangeException - if invalid section
    See Also:
    Range

    readToByteChannel

    long readToByteChannel(Variable v2,
                           Section section,
                           java.nio.channels.WritableByteChannel channel)
                           throws java.io.IOException,
                                  InvalidRangeException
    Read data from a top level Variable and send data to a WritableByteChannel. Must be in big-endian order.

    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:
    java.io.IOException - if read error
    InvalidRangeException - if invalid section

    readSection

    Array readSection(ParsedSectionSpec cer)
                      throws java.io.IOException,
                             InvalidRangeException
    Allows reading sections of nested variables

    Parameters:
    cer -
    Returns:
    requested data array
    Throws:
    java.io.IOException
    InvalidRangeException

    close

    void close()
               throws java.io.IOException
    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.

    Throws:
    java.io.IOException - if read error

    syncExtend

    boolean syncExtend()
                       throws java.io.IOException
    Extend the file if needed in a way that is compatible with the current metadata. For example, if the unlimited dimension has grown.

    Returns:
    true if file was extended.
    Throws:
    java.io.IOException - if read error

    sync

    boolean sync()
                 throws java.io.IOException
    Check if file has changed, and reread metadata if needed.

    Returns:
    true if file was changed.
    Throws:
    java.io.IOException - if read error

    sendIospMessage

    java.lang.Object sendIospMessage(java.lang.Object message)
    A way to communicate arbitrary information to an iosp.

    Parameters:
    message - opaque message.
    Returns:
    opaque return, may be null.

    toStringDebug

    java.lang.String toStringDebug(java.lang.Object o)
    Debug info for this object.

    Parameters:
    o - which object
    Returns:
    debug info for this object

    getDetailInfo

    java.lang.String getDetailInfo()
    Show debug / underlying implementation details

    Returns:
    debug info