ucar.nc2.iosp.grib
Class GribServiceProvider

java.lang.Object
  extended by ucar.nc2.iosp.grib.GribServiceProvider
All Implemented Interfaces:
IOServiceProvider
Direct Known Subclasses:
Grib1ServiceProvider, Grib2ServiceProvider

public abstract class GribServiceProvider
extends java.lang.Object
implements IOServiceProvider

Superclass for grib1 and grib2 iosp.

Version:
$Revision:63 $ $Date:2006-07-12 21:50:51Z $
Author:
caron

Field Summary
static boolean addLatLon
           
static boolean extendIndex
           
protected  FmrcCoordSys fmrcCoordSys
           
static boolean forceNewIndex
           
protected  NetcdfFile ncfile
           
protected  java.lang.StringBuffer parseInfo
           
protected  RandomAccessFile raf
           
static boolean useMaximalCoordSys
           
 
Constructor Summary
GribServiceProvider()
           
 
Method Summary
protected abstract  float[] _readData(long offset1, long offset2, int decimalScale, boolean bmsExists)
           
 void close()
          Close the file.
 java.lang.String getDetailInfo()
          Show debug / underlying implementation details
protected  ucar.grib.Index getIndex(int edition, java.lang.String location, CancelTask cancelTask)
          Open the index file.
 boolean isMissingXY(Variable v2, int timeIdx, int levIdx)
           
protected abstract  void open(ucar.grib.Index index, CancelTask cancelTask)
           
 void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)
          Open existing file, and populate ncfile with it.
 Array readData(Variable v2, java.util.List section)
          Read data from a top level Variable and return a memory resident Array.
 void readLevel(Variable v2, int timeIdx, Range levelRange, Range yRange, Range xRange, IndexIterator ii)
           
 Array readNestedData(Variable v2, java.util.List section)
          Read data from a Variable that is nested in one or more Structures.
 void readXY(Variable v2, int timeIdx, int levIdx, Range yRange, Range xRange, IndexIterator ii)
           
static void setDebugFlags(DebugFlags debugFlag)
           
static void setExtendIndex(boolean b)
           
static void setIndexAlwaysInCache(boolean b)
          Set disk cache policy for index files.
 void setSpecial(java.lang.Object special)
          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.
static void useMaximalCoordSys(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ucar.nc2.IOServiceProvider
isValidFile
 

Field Detail

ncfile

protected NetcdfFile ncfile

raf

protected RandomAccessFile raf

parseInfo

protected java.lang.StringBuffer parseInfo

fmrcCoordSys

protected FmrcCoordSys fmrcCoordSys

addLatLon

public static boolean addLatLon

forceNewIndex

public static boolean forceNewIndex

useMaximalCoordSys

public static boolean useMaximalCoordSys

extendIndex

public static boolean extendIndex
Constructor Detail

GribServiceProvider

public GribServiceProvider()
Method Detail

useMaximalCoordSys

public static void useMaximalCoordSys(boolean b)

setExtendIndex

public static void setExtendIndex(boolean b)

setIndexAlwaysInCache

public static void setIndexAlwaysInCache(boolean b)
Set disk cache policy for index files. Default = false, meaning try to write index files in same directory as grib file. True means always use the DiskCache area. TDS sets this to true, so it wont interfere with external indexer.

Parameters:
b -

setDebugFlags

public static void setDebugFlags(DebugFlags debugFlag)

open

protected abstract void open(ucar.grib.Index index,
                             CancelTask cancelTask)
                      throws java.io.IOException
Throws:
java.io.IOException

open

public void open(RandomAccessFile raf,
                 NetcdfFile ncfile,
                 CancelTask cancelTask)
          throws java.io.IOException
Description copied from interface: IOServiceProvider
Open existing file, and populate ncfile with it.

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 NetcdfFile
cancelTask - used to monito user cancellation; may be null.
Throws:
java.io.IOException

getIndex

protected ucar.grib.Index getIndex(int edition,
                                   java.lang.String location,
                                   CancelTask cancelTask)
                            throws java.io.IOException
Open the index file. If not exists, create it. When writing use DiskCache, to make sure location is writeable.

Parameters:
edition - which grib edition
location - location of the file. The index file has ".gbx" appended.
cancelTask - user may cancel
Returns:
ucar.grib.Index
Throws:
java.io.IOException

syncExtend

public boolean syncExtend()
Description copied from interface: IOServiceProvider
Extend the file if needed 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 file was exteneed.

sync

public boolean sync()
             throws java.io.IOException
Description copied from interface: IOServiceProvider
Check if file has changed, and reread metadata if needed.

Specified by:
sync in interface IOServiceProvider
Returns:
true if file was changed.
Throws:
java.io.IOException

readData

public Array readData(Variable v2,
                      java.util.List section)
               throws java.io.IOException,
                      InvalidRangeException
Description copied from interface: IOServiceProvider
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.

Specified by:
readData in interface IOServiceProvider
Parameters:
v2 - a top-level Variable
section - List of type Range specifying the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls.
Returns:
the requested data in a memory-resident Array
Throws:
java.io.IOException
InvalidRangeException
See Also:
Range

readLevel

public void readLevel(Variable v2,
                      int timeIdx,
                      Range levelRange,
                      Range yRange,
                      Range xRange,
                      IndexIterator ii)
               throws java.io.IOException,
                      InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readXY

public void readXY(Variable v2,
                   int timeIdx,
                   int levIdx,
                   Range yRange,
                   Range xRange,
                   IndexIterator ii)
            throws java.io.IOException,
                   InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

isMissingXY

public boolean isMissingXY(Variable v2,
                           int timeIdx,
                           int levIdx)
                    throws InvalidRangeException
Throws:
InvalidRangeException

_readData

protected abstract float[] _readData(long offset1,
                                     long offset2,
                                     int decimalScale,
                                     boolean bmsExists)
                              throws java.io.IOException
Throws:
java.io.IOException

readNestedData

public Array readNestedData(Variable v2,
                            java.util.List section)
                     throws java.io.IOException,
                            InvalidRangeException
Description copied from interface: IOServiceProvider
Read data from a Variable that is nested in one or more Structures. If there are no Structures in the file, this will never be called. Return an Array of the same type as the Variable and the requested shape. The shape must be an accumulation of all the shapes of the Structures containing the variable.

v2.getParent() is called to get the containing Structures.

Specified by:
readNestedData in interface IOServiceProvider
Parameters:
v2 - a nested Variable.
section - List of type Range specifying the section of data to read. There must be a Range for each Dimension in each parent, as well as in the Variable itself. Must be in order from outer to inner. Note: no nulls.
Returns:
the requested data in a memory-resident Array
Throws:
java.io.IOException
InvalidRangeException

close

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

setSpecial

public void setSpecial(java.lang.Object special)
Description copied from interface: IOServiceProvider
A way to communicate arbitrary information to an iosp. Typically this is set before open() is called.

Specified by:
setSpecial in interface IOServiceProvider
Parameters:
special - opaque special settings.

toStringDebug

public java.lang.String toStringDebug(java.lang.Object o)
Description copied from interface: IOServiceProvider
Debug info for this object.

Specified by:
toStringDebug in interface IOServiceProvider

getDetailInfo

public java.lang.String getDetailInfo()
Description copied from interface: IOServiceProvider
Show debug / underlying implementation details

Specified by:
getDetailInfo in interface IOServiceProvider