ucar.nc2.iosp
Interface IOServiceProvider

All Known Subinterfaces:
IOServiceProviderWriter
All Known Implementing Classes:
AbstractIOServiceProvider, AbstractLightningIOSP, AreaServiceProvider, BufrIosp, Cinrad2IOServiceProvider, DMSPiosp, Doradeiosp, Fysatiosp, GempakGridServiceProvider, GempakSoundingIOSP, GempakStationFileIOSP, GempakSurfaceIOSP, Ghcnm, Ghcnm2, Giniiosp, GradsBinaryGridServiceProvider, GribGridServiceProvider, GridServiceProvider, GtopoIosp, H4iosp, H5iosp, IgraPor, JniIosp, McIDASGridServiceProvider, N3iosp, N3raf, NcStreamIosp, Nexrad2IOServiceProvider, Nidsiosp, Nldn, NmcObsLegacy, NOWRadiosp, SigmetIOServiceProvider, UAMIVServiceProvider, UFiosp, Uspln, Vis5DIosp

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.
     String getDetailInfo()
              Show debug / underlying implementation details
     String getFileTypeDescription()
              Get a human-readable description for this file type.
     String getFileTypeId()
              Get a unique id for this file type.
     String getFileTypeVersion()
              Get the version of this file type.
     StructureDataIterator getStructureIterator(Structure s, int bufferSize)
               
     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, WritableByteChannel channel)
              Read data from a top level Variable and send data to a WritableByteChannel.
     Object sendIospMessage(Object message)
              A way to communicate arbitrary information to an iosp.
     boolean sync()
              Update the metadata in the NetcdfFile if the underlying dataset has changed.
     boolean syncExtend()
              Extend the NetcdfFile if the underlying dataset has changed in a way that is compatible with the current metadata.
     String toStringDebug(Object o)
              Debug info for this object.
     

    Method Detail

    isValidFile

    boolean isValidFile(RandomAccessFile raf)
                        throws 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:
    IOException - if read error

    open

    void open(RandomAccessFile raf,
              NetcdfFile ncfile,
              CancelTask cancelTask)
              throws 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:
    IOException - if read error

    readData

    Array readData(Variable v2,
                   Section section)
                   throws 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:
    IOException - if read error
    InvalidRangeException - if invalid section
    See Also:
    Range

    readToByteChannel

    long readToByteChannel(Variable v2,
                           Section section,
                           WritableByteChannel channel)
                           throws 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:
    IOException - if read error
    InvalidRangeException - if invalid section

    readSection

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

    Parameters:
    cer - section specification : what data is wanted
    Returns:
    requested data array
    Throws:
    IOException - on read error
    InvalidRangeException - if section spec is invalid

    getStructureIterator

    StructureDataIterator getStructureIterator(Structure s,
                                               int bufferSize)
                                               throws IOException
    Throws:
    IOException

    close

    void close()
               throws 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:
    IOException - if read error

    syncExtend

    boolean syncExtend()
                       throws IOException
    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.

    Returns:
    true if the NetcdfFile was extended.
    Throws:
    IOException - if a read error occured when accessing the underlying dataset.

    sync

    boolean sync()
                 throws IOException
    Update the metadata in the NetcdfFile if the underlying dataset has changed.

    Returns:
    true if the NetcdfFile was changed.
    Throws:
    IOException - if a read error occured when accessing the underlying dataset.

    sendIospMessage

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

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

    toStringDebug

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

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

    getDetailInfo

    String getDetailInfo()
    Show debug / underlying implementation details

    Returns:
    debug info

    getFileTypeId

    String getFileTypeId()
    Get a unique id for this file type.

    Returns:
    registered id of the file type
    See Also:
    "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"

    getFileTypeVersion

    String getFileTypeVersion()
    Get the version of this file type.

    Returns:
    version of the file type
    See Also:
    "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"

    getFileTypeDescription

    String getFileTypeDescription()
    Get a human-readable description for this file type.

    Returns:
    description of the file type
    See Also:
    "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"


    Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.