ucar.nc2.iosp
Interface IOServiceProviderWriter

All Superinterfaces:
IOServiceProvider
All Known Implementing Classes:
N3iosp, N3raf

public interface IOServiceProviderWriter
extends IOServiceProvider

This is really just an interface to Netcdf-3 file writing. However, we will probably add Netcdf-4 writing, even if its only through a JNI interface. For now, other parties are discouraged from using this, as it will likely be refactored in 4.x.

Author:
caron

Method Summary
 void create(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile)
          Create new file, populate it from the objects in ncfile.
 void flush()
          Flush all data buffers to disk.
 boolean rewriteHeader(boolean largeFile)
           
 void setFill(boolean fill)
          Set the fill flag.
 void updateAttribute(Variable v2, Attribute att)
          Update the value of an existing attribute.
 void writeData(Variable v2, Section section, Array values)
          Write data into a variable.
 
Methods inherited from interface ucar.nc2.iosp.IOServiceProvider
close, getDetailInfo, getFileTypeDescription, getFileTypeId, getFileTypeVersion, getStructureIterator, isValidFile, open, readData, readSection, readToByteChannel, sendIospMessage, sync, syncExtend, toStringDebug
 

Method Detail

create

void create(String filename,
            NetcdfFile ncfile,
            int extra,
            long preallocateSize,
            boolean largeFile)
            throws IOException
Create new file, populate it from the objects in ncfile.

Parameters:
filename - name of file to create.
ncfile - get dimensions, attributes, and variables from here.
extra - if > 0, pad header with extra bytes
preallocateSize - if > 0, set length of file to this upon creation - this (usually) pre-allocates contiguous storage.
largeFile - if want large file format
Throws:
IOException - if I/O error

setFill

void setFill(boolean fill)
Set the fill flag. For new files, set in the create() method. This method is to set fill for existing files that you want to write. If true, the data is first written with fill values. Leave false if you expect to write all data values, set to true if you want to be sure that unwritten data values have the fill value in it.

Parameters:
fill - set fill mode true or false

writeData

void writeData(Variable v2,
               Section section,
               Array values)
               throws IOException,
                      InvalidRangeException
Write data into a variable.

Parameters:
v2 - variable to write; must already exist.
section - 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. The origin and stride indicate where the data is placed into the stored Variable array.
values - data to write. The shape must match section.getShape().
Throws:
IOException - if I/O error
InvalidRangeException - if invalid section

rewriteHeader

boolean rewriteHeader(boolean largeFile)
                      throws IOException
Throws:
IOException

updateAttribute

void updateAttribute(Variable v2,
                     Attribute att)
                     throws IOException
Update the value of an existing attribute. Attribute is found by name, which must match exactly. You cannot make an attribute longer, or change the number of values. For strings: truncate if longer, zero fill if shorter. Strings are padded to 4 byte boundaries, ok to use padding if it exists. For numerics: must have same number of values.

Parameters:
v2 - variable, or null for global attribute
att - replace with this value
Throws:
IOException - if I/O error

flush

void flush()
           throws IOException
Flush all data buffers to disk.

Throws:
IOException - if I/O error


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