public class Nc4Iosp extends AbstractIOServiceProvider implements IOServiceProviderWriter
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
protected static java.lang.String |
DEFAULTNETCDF4LIBNAME |
static java.lang.String |
JNA_PATH |
static java.lang.String |
JNA_PATH_ENV |
location, ncfile, raf, rafOrder| Constructor and Description |
|---|
Nc4Iosp() |
Nc4Iosp(NetcdfFileWriter.Version version) |
| Modifier and Type | Method and Description |
|---|---|
int |
appendStructureData(Structure s,
StructureData sdata)
Append a structureData along the unlimited dimension
|
void |
close()
Close the file.
|
void |
create(java.lang.String filename,
NetcdfFile ncfile,
int extra,
long preallocateSize,
boolean largeFile)
Create new file, populate it from the objects in ncfile.
|
static void |
dumpbytes(byte[] bytes,
int start,
int len,
java.lang.String tag) |
void |
flush()
Flush all data buffers to disk.
|
java.lang.String |
getFileTypeDescription()
Get a human-readable description for this file type.
|
java.lang.String |
getFileTypeId()
Get a unique id for this file type.
|
static long |
getNativeAddr(int pos,
java.nio.ByteBuffer buf) |
static boolean |
isClibraryPresent()
Test if the netcdf C library is present and loaded
|
boolean |
isValidFile(RandomAccessFile raf)
Checks whether
raf is a valid file NetCDF-4 file. |
protected static java.lang.String |
nullify(java.lang.String s)
Convert a zero-length string to null
|
void |
open(RandomAccessFile raf,
NetcdfFile ncfile,
CancelTask cancelTask)
Open existing file, and populate ncfile with it.
|
void |
openForWriting(RandomAccessFile raf,
NetcdfFile ncfile,
CancelTask cancelTask)
Open existing file and allow writing.
|
Array |
readData(Variable v2,
Section section)
Read data from a top level Variable and return a memory resident Array.
|
boolean |
rewriteHeader(boolean largeFile)
if theres room before data, rewrite header without moving the data.
|
void |
setChunker(Nc4Chunking chunker) |
static void |
setDebugFlags(DebugFlags flags) |
void |
setFill(boolean fill)
Set the fill flag.
|
static void |
setLibraryAndPath(java.lang.String jna_path,
java.lang.String lib_name)
set the path and name of the netcdf c library.
|
static java.lang.String |
show(SizeT[] inta) |
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.
|
getDetailInfo, getFileTypeVersion, getLastModified, getStructureIterator, reacquire, readSection, readToByteChannel, readToOutputStream, release, sendIospMessage, streamToByteChannel, syncExtend, toStringDebugclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDetailInfo, getFileTypeVersion, getStructureIterator, reacquire, readSection, readToByteChannel, readToOutputStream, release, sendIospMessage, streamToByteChannel, syncExtend, toStringDebugpublic static final boolean DEBUG
public static final java.lang.String JNA_PATH
public static final java.lang.String JNA_PATH_ENV
protected static java.lang.String DEFAULTNETCDF4LIBNAME
public Nc4Iosp()
public Nc4Iosp(NetcdfFileWriter.Version version)
public static void setLibraryAndPath(java.lang.String jna_path,
java.lang.String lib_name)
jna_path - path to shared librarieslib_name - library namepublic static boolean isClibraryPresent()
protected static java.lang.String nullify(java.lang.String s)
s - the string to check for lengthpublic static void setDebugFlags(DebugFlags flags)
public void setChunker(Nc4Chunking chunker)
public boolean isValidFile(RandomAccessFile raf) throws java.io.IOException
raf is a valid file NetCDF-4 file. Actually, it checks whether it is a valid HDF-5 file of
any type. Furthermore, it checks whether the NetCDF C library is available on the system. If both conditions are
satisfied, this method returns true; otherwise it returns false.isValidFile in interface IOServiceProviderraf - a file on disk.true if raf is a valid HDF-5 file and the NetCDF C library is available.java.io.IOException - if an I/O error occurs.public java.lang.String getFileTypeDescription()
IOServiceProvidergetFileTypeDescription in interface IOServiceProviderpublic java.lang.String getFileTypeId()
IOServiceProvidergetFileTypeId in interface IOServiceProviderpublic void close()
throws java.io.IOException
IOServiceProviderclose in interface IOServiceProviderclose in class AbstractIOServiceProviderjava.io.IOException - if read errorpublic void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws java.io.IOException
IOServiceProvideropen in interface IOServiceProvideropen in class AbstractIOServiceProviderraf - the file to work on, it has already passed the isValidFile() test.ncfile - add objects to this empty NetcdfFilecancelTask - used to monitor user cancellation; may be null.java.io.IOException - if read errorpublic void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws java.io.IOException
IOServiceProviderWriteropenForWriting in interface IOServiceProviderWriterraf - the file to work on.ncfile - add objects to this empty NetcdfFilecancelTask - used to monitor user cancellation; may be null.java.io.IOException - if I/O errorpublic static void dumpbytes(byte[] bytes,
int start,
int len,
java.lang.String tag)
public Array readData(Variable v2, Section section) throws java.io.IOException, InvalidRangeException
IOServiceProviderreadData in interface IOServiceProviderv2 - a top-level Variablesection - the section of data to read.
There must be a Range for each Dimension in the variable, in order.
Note: no nulls allowed. IOSP may not modify.java.io.IOException - if read errorInvalidRangeException - if invalid sectionRangepublic static java.lang.String show(SizeT[] inta)
public void create(java.lang.String filename,
NetcdfFile ncfile,
int extra,
long preallocateSize,
boolean largeFile)
throws java.io.IOException
IOServiceProviderWritercreate in interface IOServiceProviderWriterfilename - 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 formatjava.io.IOException - if I/O errorpublic void writeData(Variable v2, Section section, Array values) throws java.io.IOException, InvalidRangeException
IOServiceProviderWriterwriteData in interface IOServiceProviderWriterv2 - 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().java.io.IOException - if I/O errorInvalidRangeException - if invalid sectionpublic int appendStructureData(Structure s, StructureData sdata) throws java.io.IOException, InvalidRangeException
IOServiceProviderWriterappendStructureData in interface IOServiceProviderWriters - belongs to this structuresdata - the stuctureData to appendjava.io.IOExceptionInvalidRangeExceptionpublic void flush()
throws java.io.IOException
IOServiceProviderWriterflush in interface IOServiceProviderWriterjava.io.IOException - if I/O errorpublic void setFill(boolean fill)
IOServiceProviderWritersetFill in interface IOServiceProviderWriterfill - set fill mode true or falsepublic boolean rewriteHeader(boolean largeFile)
throws java.io.IOException
IOServiceProviderWriterrewriteHeader in interface IOServiceProviderWriterjava.io.IOExceptionpublic void updateAttribute(Variable v2, Attribute att) throws java.io.IOException
IOServiceProviderWriterupdateAttribute in interface IOServiceProviderWriterv2 - variable, or null for global attributeatt - replace with this valuejava.io.IOException - if I/O errorpublic static long getNativeAddr(int pos,
java.nio.ByteBuffer buf)