public abstract class N3iosp extends AbstractIOServiceProvider implements IOServiceProviderWriter
concrete class| Modifier and Type | Field and Description |
|---|---|
protected boolean |
debug |
protected boolean |
debugRead |
protected boolean |
debugRecord |
protected boolean |
debugSize |
protected boolean |
debugSPIO |
protected HashMap |
dimHash |
protected boolean |
fill |
protected N3header |
header |
protected long |
lastModified |
static int |
MAX_NUMRECS
The maximum number of records is 2^32-1.
|
static long |
MAX_VARSIZE
Each fixed-size variable and the data for one record's worth of a single record variable are limited
to a little less than 4 GiB.
|
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 long |
NC_FILL_LONG |
static short |
NC_FILL_SHORT |
protected NetcdfFile |
ncfile |
protected boolean |
readonly |
protected boolean |
showHeaderBytes |
protected boolean |
useRecordStructure |
raf| Constructor and Description |
|---|
N3iosp() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
_create(RandomAccessFile raf) |
protected abstract void |
_open(RandomAccessFile raf) |
void |
close()
Close the file.
|
void |
create(String filename,
NetcdfFile ncfile,
int extra,
long preallocateSize,
boolean largeFile)
Create new file, populate it from the objects in ncfile.
|
static String |
createValidNetcdf3ObjectName(String name)
Deprecated.
use makeValidNetcdfObjectName
|
protected void |
fillNonRecordVariables() |
protected void |
fillRecordVariables(int recStart,
int recEnd) |
void |
flush()
Flush all data buffers to disk.
|
String |
getDetailInfo()
Show debug / underlying implementation details
|
String |
getFileTypeDescription()
Get a human-readable description for this file type.
|
String |
getFileTypeId()
Get a unique id for this file type.
|
static Pattern |
getValidNetcdf3ObjectNamePattern()
Valid Netcdf Object name as a regular expression.
|
boolean |
isValidFile(RandomAccessFile raf)
Check if this is a valid file for this IOServiceProvider.
|
static boolean |
isValidNetcdf3ObjectName(String name)
Deprecated.
use isValidNetcdfObjectName
|
static boolean |
isValidNetcdfObjectName(String name)
Determine if the given name can be used for a Dimension, Attribute, or Variable name.
|
static void |
main(String[] args) |
static String |
makeValidNetcdf3ObjectName(String name)
Deprecated.
use makeValidNetcdfObjectName
|
static String |
makeValidNetcdfObjectName(String name)
Convert a name to a legal netcdf-3 name.
|
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.
|
protected abstract Object |
readData(Layout index,
DataType dataType)
Read data subset from file for a variable, create primitive array.
|
protected abstract long |
readData(Layout index,
DataType dataType,
WritableByteChannel out) |
Array |
readData(Variable v2,
Section section)
Read data from a top level Variable and return a memory resident Array.
|
Array |
readNestedData(Variable v2,
Section section) |
long |
readToByteChannel(Variable v2,
Section section,
WritableByteChannel channel)
Read data from a top level Variable and send data to a WritableByteChannel.
|
boolean |
rewriteHeader(boolean largeFile) |
Object |
sendIospMessage(Object message)
A way to communicate arbitrary information to an iosp.
|
void |
setFill(boolean fill)
Set the fill flag.
|
protected void |
setNumrecs(int n) |
static void |
setProperty(String name,
String value)
Set a static property.
|
boolean |
syncExtend()
Extend the NetcdfFile if the underlying dataset has changed
in a way that is compatible with the current metadata.
|
String |
toStringDebug(Object o)
Debug info for this object.
|
void |
updateAttribute(Variable v2,
Attribute att)
Update the value of an existing attribute.
|
protected abstract void |
writeData(Array aa,
Layout index,
DataType dataType)
Write data subset to file for a variable, create primitive array.
|
void |
writeData(Variable v2,
Section section,
Array values)
Write data into a variable.
|
getFileTypeVersion, getLastModified, getStructureIterator, readSection, readToOutputStream, streamToByteChannelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFileTypeVersion, getStructureIterator, readSection, readToOutputStream, streamToByteChannelpublic static final byte NC_FILL_BYTE
public static final char NC_FILL_CHAR
public static final short NC_FILL_SHORT
public static final int NC_FILL_INT
public static final long NC_FILL_LONG
public static final float NC_FILL_FLOAT
public static final double NC_FILL_DOUBLE
public static final long MAX_VARSIZE
public static final int MAX_NUMRECS
protected NetcdfFile ncfile
protected boolean readonly
protected N3header header
protected long lastModified
protected boolean debug
protected boolean debugSize
protected boolean debugSPIO
protected boolean debugRecord
protected boolean debugRead
protected boolean showHeaderBytes
protected boolean useRecordStructure
protected boolean fill
protected HashMap dimHash
public static void setProperty(String name, String value)
name - property namevalue - property valuepublic static String makeValidNetcdfObjectName(String name)
name - convert this namepublic static boolean isValidNetcdfObjectName(String name)
name - test this.public static String makeValidNetcdf3ObjectName(String name)
public static boolean isValidNetcdf3ObjectName(String name)
name - test this.public static Pattern getValidNetcdf3ObjectNamePattern()
public static String createValidNetcdf3ObjectName(String name)
name - convert this namepublic boolean isValidFile(RandomAccessFile raf) throws IOException
IOServiceProviderisValidFile in interface IOServiceProviderraf - RandomAccessFileIOException - if read errorpublic String getDetailInfo()
IOServiceProvidergetDetailInfo in interface IOServiceProvidergetDetailInfo in class AbstractIOServiceProviderpublic void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws 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.IOException - if I/O errorpublic void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws 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.IOException - if read errorpublic void setFill(boolean fill)
IOServiceProviderWritersetFill in interface IOServiceProviderWriterfill - set fill mode true or falsepublic Array readData(Variable v2, Section section) throws 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.IOException - if read errorInvalidRangeException - if invalid sectionRangepublic Array readNestedData(Variable v2, Section section) throws IOException, InvalidRangeException
IOExceptionInvalidRangeExceptionpublic long readToByteChannel(Variable v2, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
IOServiceProviderreadToByteChannel in interface IOServiceProviderreadToByteChannel in class AbstractIOServiceProviderv2 - 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.channel - write data to this WritableByteChannelIOException - if read errorInvalidRangeException - if invalid sectionpublic void create(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile) throws 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 formatIOException - if I/O errorpublic boolean rewriteHeader(boolean largeFile)
throws IOException
rewriteHeader in interface IOServiceProviderWriterIOExceptionpublic void writeData(Variable v2, Section section, Array values) throws 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().IOException - if I/O errorInvalidRangeException - if invalid sectionprotected void setNumrecs(int n)
throws IOException,
InvalidRangeException
IOExceptionInvalidRangeExceptionpublic void updateAttribute(Variable v2, Attribute att) throws IOException
updateAttribute in interface IOServiceProviderWriterv2 - variable, or null for fglobal attributeatt - replace with this valueIOExceptionprotected void fillNonRecordVariables()
throws IOException
IOExceptionprotected void fillRecordVariables(int recStart,
int recEnd)
throws IOException,
InvalidRangeException
IOExceptionInvalidRangeExceptionpublic boolean syncExtend()
throws IOException
IOServiceProvidersyncExtend in interface IOServiceProvidersyncExtend in class AbstractIOServiceProviderIOException - if a read error occured when accessing the underlying dataset.public void flush()
throws IOException
IOServiceProviderWriterflush in interface IOServiceProviderWriterIOException - if I/O errorpublic void close()
throws IOException
IOServiceProviderclose in interface IOServiceProviderclose in class AbstractIOServiceProviderIOException - if read errorpublic String toStringDebug(Object o)
toStringDebug in interface IOServiceProvidertoStringDebug in class AbstractIOServiceProvidero - which objectpublic Object sendIospMessage(Object message)
IOServiceProvidersendIospMessage in interface IOServiceProvidersendIospMessage in class AbstractIOServiceProvidermessage - opaque message sent to the IOSP object when its opened (not when isValidFile() is called)public String getFileTypeId()
IOServiceProvidergetFileTypeId in interface IOServiceProviderpublic String getFileTypeDescription()
IOServiceProvidergetFileTypeDescription in interface IOServiceProviderprotected abstract Object readData(Layout index, DataType dataType) throws IOException
index - handles skipping around in the file.dataType - dataType of the variableIOException - on errorprotected abstract long readData(Layout index, DataType dataType, WritableByteChannel out) throws IOException
IOExceptionprotected abstract void writeData(Array aa, Layout index, DataType dataType) throws IOException
aa - write data in this Array.index - handles skipping around in the file.dataType - dataType of the variableIOException - on errorprotected abstract void _open(RandomAccessFile raf) throws IOException
IOExceptionprotected abstract void _create(RandomAccessFile raf) throws IOException
IOExceptionpublic static void main(String[] args)
Copyright © 1999-2013 UCAR/Unidata. All Rights Reserved.