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 java.util.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_INT64 |
static long |
NC_FILL_LONG |
static short |
NC_FILL_SHORT |
static java.lang.String |
NC_FILL_STRING |
static byte |
NC_FILL_UBYTE |
static int |
NC_FILL_UINT |
static short |
NC_FILL_USHORT |
protected boolean |
readonly |
protected boolean |
showHeaderBytes |
protected boolean |
useRecordStructure |
location, ncfile, raf, rafOrder
Constructor and Description |
---|
N3iosp() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
_create(RandomAccessFile raf) |
protected abstract void |
_open(RandomAccessFile raf) |
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 java.lang.String |
createValidNetcdf3ObjectName(java.lang.String name)
Deprecated.
use makeValidNetcdfObjectName
|
protected void |
fillNonRecordVariables() |
protected void |
fillRecordVariables(int recStart,
int recEnd) |
void |
flush()
Flush all data buffers to disk.
|
java.lang.String |
getDetailInfo()
Show debug / underlying implementation details
|
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 java.util.regex.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(java.lang.String name)
Deprecated.
use isValidNetcdfObjectName
|
static boolean |
isValidNetcdfObjectName(java.lang.String name)
Determine if the given name can be used for a NetCDF object, i.e.
|
static java.lang.String |
makeValidNetcdf3ObjectName(java.lang.String name)
Deprecated.
use makeValidNetcdfObjectName
|
static java.lang.String |
makeValidNetcdfObjectName(java.lang.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.
|
void |
reacquire() |
protected abstract java.lang.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,
java.nio.channels.WritableByteChannel out) |
Array |
readData(Variable v2,
Section section)
Read data from a top level Variable and return a memory resident Array.
|
long |
readToByteChannel(Variable v2,
Section section,
java.nio.channels.WritableByteChannel channel)
Read data from a top level Variable and send data to a WritableByteChannel.
|
boolean |
rewriteHeader(boolean largeFile)
if theres room before data, rewrite header without moving the data.
|
java.lang.Object |
sendIospMessage(java.lang.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(java.lang.String name,
java.lang.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.
|
java.lang.String |
toStringDebug(java.lang.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, release, streamToByteChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFileTypeVersion, getStructureIterator, readSection, readToOutputStream, release, streamToByteChannel
public 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 byte NC_FILL_UBYTE
public static final short NC_FILL_USHORT
public static final int NC_FILL_UINT
public static final long NC_FILL_INT64
public static final java.lang.String NC_FILL_STRING
public static final long MAX_VARSIZE
public static final int MAX_NUMRECS
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 java.util.HashMap dimHash
public static void setProperty(java.lang.String name, java.lang.String value)
name
- property namevalue
- property valuepublic static boolean isValidNetcdfObjectName(java.lang.String name)
([a-zA-Z0-9_]|{UTF8})([^\x00-\x1F\x7F/]|{UTF8})*where UTF8 represents a multi-byte UTF-8 encoding. Also, no trailing spaces are permitted in names. We do not allow '/' because HDF5 does not permit slashes in names as slash is used as a group separator. If UTF-8 is supported, then a multi-byte UTF-8 character can occur anywhere within an identifier.
name
- the name to validate.true
if the name is valid.public static java.lang.String makeValidNetcdfObjectName(java.lang.String name)
name
- the name to convert.isValidNetcdfObjectName(String)
public static java.lang.String makeValidNetcdf3ObjectName(java.lang.String name)
public static boolean isValidNetcdf3ObjectName(java.lang.String name)
name
- test this.public static java.util.regex.Pattern getValidNetcdf3ObjectNamePattern()
public static java.lang.String createValidNetcdf3ObjectName(java.lang.String name)
name
- convert this namepublic boolean isValidFile(RandomAccessFile raf) throws java.io.IOException
IOServiceProvider
isValidFile
in interface IOServiceProvider
raf
- RandomAccessFilejava.io.IOException
- if read errorpublic java.lang.String getDetailInfo()
IOServiceProvider
getDetailInfo
in interface IOServiceProvider
getDetailInfo
in class AbstractIOServiceProvider
public void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws java.io.IOException
IOServiceProviderWriter
openForWriting
in interface IOServiceProviderWriter
raf
- 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 void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws java.io.IOException
IOServiceProvider
open
in interface IOServiceProvider
open
in class AbstractIOServiceProvider
raf
- 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 setFill(boolean fill)
IOServiceProviderWriter
setFill
in interface IOServiceProviderWriter
fill
- set fill mode true or falsepublic Array readData(Variable v2, Section section) throws java.io.IOException, InvalidRangeException
IOServiceProvider
readData
in interface IOServiceProvider
v2
- 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 sectionRange
public long readToByteChannel(Variable v2, Section section, java.nio.channels.WritableByteChannel channel) throws java.io.IOException, InvalidRangeException
IOServiceProvider
readToByteChannel
in interface IOServiceProvider
readToByteChannel
in class AbstractIOServiceProvider
v2
- 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 WritableByteChanneljava.io.IOException
- if read errorInvalidRangeException
- if invalid sectionpublic void create(java.lang.String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile) throws java.io.IOException
IOServiceProviderWriter
create
in interface IOServiceProviderWriter
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 formatjava.io.IOException
- if I/O errorpublic boolean rewriteHeader(boolean largeFile) throws java.io.IOException
IOServiceProviderWriter
rewriteHeader
in interface IOServiceProviderWriter
java.io.IOException
public void writeData(Variable v2, Section section, Array values) throws java.io.IOException, InvalidRangeException
IOServiceProviderWriter
writeData
in interface IOServiceProviderWriter
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().java.io.IOException
- if I/O errorInvalidRangeException
- if invalid sectionpublic int appendStructureData(Structure s, StructureData sdata) throws java.io.IOException, InvalidRangeException
IOServiceProviderWriter
appendStructureData
in interface IOServiceProviderWriter
s
- belongs to this structuresdata
- the stuctureData to appendjava.io.IOException
InvalidRangeException
protected void setNumrecs(int n) throws java.io.IOException, InvalidRangeException
java.io.IOException
InvalidRangeException
public void updateAttribute(Variable v2, Attribute att) throws java.io.IOException
updateAttribute
in interface IOServiceProviderWriter
v2
- variable, or null for fglobal attributeatt
- replace with this valuejava.io.IOException
protected void fillNonRecordVariables() throws java.io.IOException
java.io.IOException
protected void fillRecordVariables(int recStart, int recEnd) throws java.io.IOException, InvalidRangeException
java.io.IOException
InvalidRangeException
public boolean syncExtend() throws java.io.IOException
IOServiceProvider
syncExtend
in interface IOServiceProvider
syncExtend
in class AbstractIOServiceProvider
java.io.IOException
- if a read error occured when accessing the underlying dataset.public void flush() throws java.io.IOException
IOServiceProviderWriter
flush
in interface IOServiceProviderWriter
java.io.IOException
- if I/O errorpublic void close() throws java.io.IOException
IOServiceProvider
close
in interface IOServiceProvider
close
in class AbstractIOServiceProvider
java.io.IOException
- if read errorpublic void reacquire() throws java.io.IOException
reacquire
in interface IOServiceProvider
reacquire
in class AbstractIOServiceProvider
java.io.IOException
public java.lang.String toStringDebug(java.lang.Object o)
toStringDebug
in interface IOServiceProvider
toStringDebug
in class AbstractIOServiceProvider
o
- which objectpublic java.lang.Object sendIospMessage(java.lang.Object message)
IOServiceProvider
sendIospMessage
in interface IOServiceProvider
sendIospMessage
in class AbstractIOServiceProvider
message
- opaque message sent to the IOSP object when its opened (not when isValidFile() is called)public java.lang.String getFileTypeId()
IOServiceProvider
getFileTypeId
in interface IOServiceProvider
public java.lang.String getFileTypeDescription()
IOServiceProvider
getFileTypeDescription
in interface IOServiceProvider
protected abstract java.lang.Object readData(Layout index, DataType dataType) throws java.io.IOException
index
- handles skipping around in the file.dataType
- dataType of the variablejava.io.IOException
- on errorprotected abstract long readData(Layout index, DataType dataType, java.nio.channels.WritableByteChannel out) throws java.io.IOException
java.io.IOException
protected abstract void writeData(Array aa, Layout index, DataType dataType) throws java.io.IOException
aa
- write data from this Array.index
- handles skipping around in the file.dataType
- dataType of the variablejava.io.IOException
- on errorprotected abstract void _open(RandomAccessFile raf) throws java.io.IOException
java.io.IOException
protected abstract void _create(RandomAccessFile raf) throws java.io.IOException
java.io.IOException