ucar.nc2.iosp.gini
Class Giniiosp

java.lang.Object
  extended by ucar.nc2.iosp.gini.Giniiosp
All Implemented Interfaces:
IOServiceProvider

public class Giniiosp
extends java.lang.Object
implements IOServiceProvider

IOServiceProvider implementation abstract base class to read/write "version 3" netcdf files. AKA "file format version 1" files. see concrete class


Field Summary
protected  boolean debug
           
protected  boolean debugSize
           
protected  boolean debugSPIO
           
protected  java.util.HashMap dimHash
           
protected  int fileUsed
           
protected  boolean fill
           
protected  ucar.nc2.iosp.gini.Giniheader headerParser
           
protected  boolean readonly
           
protected  int recStart
           
protected  boolean showHeaderBytes
           
 
Constructor Summary
Giniiosp()
           
 
Method Summary
 void close()
          Close the file.
protected static char[] convertByteToChar(byte[] byteArray)
           
protected static byte[] convertCharToByte(char[] from)
           
 short convertunsignedByte2Short(byte b)
           
 void flush()
           
 java.lang.String getDetailInfo()
          Show debug / underlying implementation details
 boolean isValidFile(RandomAccessFile raf)
          Check if this is a valid file for this IOServiceProvider.
static void main(java.lang.String[] args)
           
 void open(RandomAccessFile raf, NetcdfFile file, CancelTask cancelTask)
          Open existing file, and populate ncfile with it.
 Array readCompressedData(Variable v2, long dataPos, int[] origin, int[] shape, int[] stride)
           
 Array readCompressedZlib(Variable v2, long dataPos, int nx, int ny, int[] origin, int[] shape, int[] stride)
           
 Array readData(Variable v2, java.util.List sectionList)
          Read data from a top level Variable and return a memory resident Array.
 Array readDataOld(Variable v2, long dataPos, int[] origin, int[] shape, int[] stride)
           
 Array readNestedData(Variable v2, java.util.List section)
          Read data from a Variable that is nested in one or more Structures.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readonly

protected boolean readonly

headerParser

protected ucar.nc2.iosp.gini.Giniheader headerParser

fileUsed

protected int fileUsed

recStart

protected int recStart

debug

protected boolean debug

debugSize

protected boolean debugSize

debugSPIO

protected boolean debugSPIO

showHeaderBytes

protected boolean showHeaderBytes

fill

protected boolean fill

dimHash

protected java.util.HashMap dimHash
Constructor Detail

Giniiosp

public Giniiosp()
Method Detail

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.

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

isValidFile

public boolean isValidFile(RandomAccessFile raf)
Description copied from interface: IOServiceProvider
Check if this is a valid file for this IOServiceProvider.

Specified by:
isValidFile in interface IOServiceProvider
Parameters:
raf - RandomAccessFile
Returns:
true if valid.

open

public void open(RandomAccessFile raf,
                 NetcdfFile file,
                 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.
file - add objects to this NetcdfFile
cancelTask - used to monito user cancellation; may be null.
Throws:
java.io.IOException

readData

public Array readData(Variable v2,
                      java.util.List sectionList)
               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
sectionList - 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

readDataOld

public Array readDataOld(Variable v2,
                         long dataPos,
                         int[] origin,
                         int[] shape,
                         int[] stride)
                  throws java.io.IOException,
                         InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readCompressedData

public Array readCompressedData(Variable v2,
                                long dataPos,
                                int[] origin,
                                int[] shape,
                                int[] stride)
                         throws java.io.IOException,
                                InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

readCompressedZlib

public Array readCompressedZlib(Variable v2,
                                long dataPos,
                                int nx,
                                int ny,
                                int[] origin,
                                int[] shape,
                                int[] stride)
                         throws java.io.IOException,
                                InvalidRangeException
Throws:
java.io.IOException
InvalidRangeException

convertByteToChar

protected static char[] convertByteToChar(byte[] byteArray)

convertCharToByte

protected static byte[] convertCharToByte(char[] from)

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

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

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()
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.

convertunsignedByte2Short

public short convertunsignedByte2Short(byte b)

toStringDebug

public java.lang.String toStringDebug(java.lang.Object o)
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

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception,
                        java.io.IOException,
                        java.lang.InstantiationException,
                        java.lang.IllegalAccessException
Throws:
java.lang.Exception
java.io.IOException
java.lang.InstantiationException
java.lang.IllegalAccessException