ucar.nc2
Class N3iosp

java.lang.Object
  extended by ucar.nc2.N3iosp
All Implemented Interfaces:
IOServiceProvider, IOServiceProviderWriter

public abstract class N3iosp
extends java.lang.Object
implements IOServiceProviderWriter

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

Author:
caron
See Also:
concrete class

Field Summary
static java.lang.String FillValue
           
static byte NC_FILL_BYTE
           
static char NC_FILL_CHAR
           
static double NC_FILL_DOUBLE
           
static float NC_FILL_FLOAT
           
static int NC_FILL_INT
           
static short NC_FILL_SHORT
           
 
Constructor Summary
N3iosp()
           
 
Method Summary
 void close()
          Close the file.
 void create(java.lang.String filename, NetcdfFile ncfile, boolean fill)
          Create new file, populate it from the objects in ncfile.
 void flush()
          Flush all data buffers to disk.
 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, java.util.List sectionList)
          Read data from a top level Variable and return a memory resident Array.
 Array readNestedData(Variable v2, java.util.List sectionList)
          Read data from a Variable that is nested in the record Structure.
 void setProperties(java.util.List iospProperties)
           
static void setProperty(java.lang.String name, java.lang.String value)
          Set a static property.
 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.
 void writeData(Variable v2, java.util.List sectionList, Array values)
          Write data into a variable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NC_FILL_BYTE

public static final byte NC_FILL_BYTE
See Also:
Constant Field Values

NC_FILL_CHAR

public static final char NC_FILL_CHAR
See Also:
Constant Field Values

NC_FILL_SHORT

public static final short NC_FILL_SHORT
See Also:
Constant Field Values

NC_FILL_INT

public static final int NC_FILL_INT
See Also:
Constant Field Values

NC_FILL_FLOAT

public static final float NC_FILL_FLOAT
See Also:
Constant Field Values

NC_FILL_DOUBLE

public static final double NC_FILL_DOUBLE
See Also:
Constant Field Values

FillValue

public static final java.lang.String FillValue
See Also:
Constant Field Values
Constructor Detail

N3iosp

public N3iosp()
Method Detail

setProperty

public static void setProperty(java.lang.String name,
                               java.lang.String value)
Set a static property. Supported static properties:

Parameters:
name - property name
value - property value

isValidFile

public boolean isValidFile(RandomAccessFile raf)
                    throws java.io.IOException
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.
Throws:
java.io.IOException

getDetailInfo

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

Specified by:
getDetailInfo in interface IOServiceProvider

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.

setProperties

public void setProperties(java.util.List iospProperties)

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

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

readNestedData

public Array readNestedData(Variable v2,
                            java.util.List sectionList)
                     throws java.io.IOException,
                            InvalidRangeException
Read data from a Variable that is nested in the record Structure.

Specified by:
readNestedData in interface IOServiceProvider
Parameters:
v2 - a nested Variable.
sectionList - 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.
Returns:
the requested data in a memory-resident Array
Throws:
java.io.IOException
InvalidRangeException

create

public void create(java.lang.String filename,
                   NetcdfFile ncfile,
                   boolean fill)
            throws java.io.IOException
Description copied from interface: IOServiceProviderWriter
Create new file, populate it from the objects in ncfile.

Specified by:
create in interface IOServiceProviderWriter
Parameters:
filename - name of file to create.
ncfile - get dimensions, attributes, and variables from here.
fill - if true, write fill value into all variables.
Throws:
java.io.IOException

writeData

public void writeData(Variable v2,
                      java.util.List sectionList,
                      Array values)
               throws java.io.IOException,
                      InvalidRangeException
Description copied from interface: IOServiceProviderWriter
Write data into a variable.

Specified by:
writeData in interface IOServiceProviderWriter
Parameters:
v2 - variable to write; must already exist.
sectionList - List of type Range specifying the section of data to write. There must be a Range for each Dimension in the variable, in order. The shape must match the shape of values.
values - data to write. The shape must match the shape of Range list.
Throws:
java.io.IOException
InvalidRangeException

syncExtend

public boolean syncExtend()
                   throws java.io.IOException
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.
Throws:
java.io.IOException

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

flush

public void flush()
           throws java.io.IOException
Description copied from interface: IOServiceProviderWriter
Flush all data buffers to disk.

Specified by:
flush in interface IOServiceProviderWriter
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

toStringDebug

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

Specified by:
toStringDebug in interface IOServiceProvider