Package ucar.nc2.internal.iosp.netcdf3
Class N3iospWriter
- java.lang.Object
-
- ucar.nc2.iosp.AbstractIOServiceProvider
-
- ucar.nc2.internal.iosp.netcdf3.N3iospNew
-
- ucar.nc2.internal.iosp.netcdf3.N3iospWriter
-
- All Implemented Interfaces:
IOServiceProvider,IOServiceProviderWriter
public class N3iospWriter extends N3iospNew implements IOServiceProviderWriter
IOServiceProviderWriter for Netcdf3 files.
-
-
Field Summary
-
Fields inherited from class ucar.nc2.internal.iosp.netcdf3.N3iospNew
header, lastModified, log
-
Fields inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
location, ncfile, raf, rafOrder
-
-
Constructor Summary
Constructors Constructor Description N3iospWriter(IOServiceProvider iosp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intappendStructureData(Structure s, StructureData sdata)Append a structureData along the unlimited dimensionvoidcreate(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile)Create new file, populate it from the objects in ncfile.voidflush()Flush all data buffers to disk.voidopenForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)Open existing file and allow writing.booleanrewriteHeader(boolean largeFile)if theres room before data, rewrite header without moving the data.voidsetFill(boolean fill)Set the fill flag.booleansyncExtend()Extend the NetcdfFile if the underlying dataset has changed in a way that is compatible with the current metadata.voidupdateAttribute(Variable v2, Attribute att)Update the value of an existing attribute on disk, not in memory.voidwriteData(Variable v2, Section section, Array values)Write data into a variable.-
Methods inherited from class ucar.nc2.internal.iosp.netcdf3.N3iospNew
build, close, getDetailInfo, getFileTypeDescription, getFileTypeId, getFileTypeVersion, isBuilder, isValidFile, open, reacquire, readData, readToByteChannel, sendIospMessage, toStringDebug
-
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
buildFinish, getLastModified, getStructureIterator, readSection, readToOutputStream, release, setNetcdfFile, streamToByteChannel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ucar.nc2.iosp.IOServiceProvider
build, buildFinish, close, getDetailInfo, getFileTypeDescription, getFileTypeId, getFileTypeVersion, getStructureIterator, isBuilder, isValidFile, open, reacquire, readData, readSection, readToByteChannel, readToOutputStream, release, sendIospMessage, streamToByteChannel, toStringDebug
-
-
-
-
Constructor Detail
-
N3iospWriter
public N3iospWriter(IOServiceProvider iosp)
-
-
Method Detail
-
openForWriting
public void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException
Description copied from interface:IOServiceProviderWriterOpen existing file and allow writing. Netcdf-4 writing is general. Netcdf-3 writing is restricted to writing data into existing variables.- Specified by:
openForWritingin interfaceIOServiceProviderWriter- Parameters:
raf- the file to work on.ncfile- add objects to this empty NetcdfFilecancelTask- used to monitor user cancellation; may be null.- Throws:
IOException- if I/O error
-
setFill
public void setFill(boolean fill)
Description copied from interface:IOServiceProviderWriterSet 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. Set to 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.- Specified by:
setFillin interfaceIOServiceProviderWriter- Parameters:
fill- set fill mode true or false
-
create
public void create(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile) throws IOException
Description copied from interface:IOServiceProviderWriterCreate new file, populate it from the objects in ncfile.- Specified by:
createin interfaceIOServiceProviderWriter- Parameters:
filename- name of file to create.ncfile- get everything but data from hereextra- if > 0, pad header with extra bytespreallocateSize- 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
-
rewriteHeader
public boolean rewriteHeader(boolean largeFile) throws IOExceptionDescription copied from interface:IOServiceProviderWriterif theres room before data, rewrite header without moving the data. netcdf3 only- Specified by:
rewriteHeaderin interfaceIOServiceProviderWriter- Returns:
- true if it worked
- Throws:
IOException
-
writeData
public void writeData(Variable v2, Section section, Array values) throws IOException, InvalidRangeException
Description copied from interface:IOServiceProviderWriterWrite data into a variable.- Specified by:
writeDatain interfaceIOServiceProviderWriter- 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 errorInvalidRangeException- if invalid section
-
appendStructureData
public int appendStructureData(Structure s, StructureData sdata) throws IOException, InvalidRangeException
Description copied from interface:IOServiceProviderWriterAppend a structureData along the unlimited dimension- Specified by:
appendStructureDatain interfaceIOServiceProviderWriter- Parameters:
s- belongs to this structuresdata- the stuctureData to append- Returns:
- the recnum where it was written
- Throws:
IOExceptionInvalidRangeException
-
updateAttribute
public void updateAttribute(Variable v2, Attribute att) throws IOException
Update the value of an existing attribute on disk, not in memory. 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.- Specified by:
updateAttributein interfaceIOServiceProviderWriter- Parameters:
v2- variable, or null for global attributeatt- replace with this value- Throws:
IOException
-
flush
public void flush() throws IOExceptionDescription copied from interface:IOServiceProviderWriterFlush all data buffers to disk.- Specified by:
flushin interfaceIOServiceProviderWriter- Overrides:
flushin classN3iospNew- Throws:
IOException
-
syncExtend
public boolean syncExtend() throws IOExceptionDescription copied from interface:IOServiceProviderExtend 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.- Specified by:
syncExtendin interfaceIOServiceProvider- Overrides:
syncExtendin classN3iospNew- Returns:
- true if the NetcdfFile was extended.
- Throws:
IOException- if a read error occured when accessing the underlying dataset.
-
-