|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.nc2.iosp.AbstractIOServiceProvider
ucar.nc2.iosp.netcdf3.N3iosp
public abstract class N3iosp
IOServiceProvider implementation abstract base class to read/write "version 3" netcdf files. AKA "file format version 1" files.
concrete class| Field Summary | |
|---|---|
protected boolean |
debug
|
protected boolean |
debugRecord
|
protected boolean |
debugSize
|
protected boolean |
debugSPIO
|
protected boolean |
debugSync
|
protected java.util.HashMap |
dimHash
|
protected long |
fileUsed
|
protected boolean |
fill
|
static java.lang.String |
FillValue
|
protected N3header |
headerParser
|
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 int |
numrecs
|
protected boolean |
readonly
|
protected long |
recsize
|
protected long |
recStart
|
protected boolean |
showHeaderBytes
|
protected boolean |
useRecordStructure
|
| Fields inherited from class ucar.nc2.iosp.AbstractIOServiceProvider |
|---|
raf |
| Constructor Summary | |
|---|---|
N3iosp()
|
|
| Method Summary | |
|---|---|
protected abstract void |
_create(RandomAccessFile raf)
|
protected abstract void |
_open(RandomAccessFile raf)
|
void |
close()
Close the file. |
protected static char[] |
convertByteToCharUTF(byte[] byteArray)
|
protected static byte[] |
convertCharToByteUTF(char[] from)
|
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)
Convert a name to a legal netcdf name. |
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)
Determine if the given name can be used for a Dimension, Attribute, or Variable name. |
static java.lang.String |
makeValidNetcdfObjectName(java.lang.String name)
Convert a name to a legal netcdf-3 name. |
static java.lang.String |
makeValidNetcdfObjectNameOld(java.lang.String name)
|
void |
open(RandomAccessFile raf,
NetcdfFile ncfile,
CancelTask cancelTask)
Open existing file, and populate ncfile with it. |
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. |
Array |
readNestedData(Variable v2,
Section section)
|
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)
|
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 |
sync()
Update the metadata in the NetcdfFile if the underlying dataset has changed. |
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. |
| Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider |
|---|
copyToByteChannel, createValidNetcdfObjectName, getFileTypeVersion, getStructureIterator, readSection |
| 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 |
|---|
getFileTypeVersion, readSection |
| Field Detail |
|---|
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 java.lang.String FillValue
public static final long MAX_VARSIZE
public static final int MAX_NUMRECS
protected NetcdfFile ncfile
protected boolean readonly
protected N3header headerParser
protected int numrecs
protected long recsize
protected long lastModified
protected long fileUsed
protected long recStart
protected boolean debug
protected boolean debugSize
protected boolean debugSPIO
protected boolean debugRecord
protected boolean debugSync
protected boolean showHeaderBytes
protected boolean useRecordStructure
protected boolean fill
protected java.util.HashMap dimHash
| Constructor Detail |
|---|
public N3iosp()
| Method Detail |
|---|
public static void setProperty(java.lang.String name,
java.lang.String value)
name - property namevalue - property valuepublic static java.lang.String makeValidNetcdfObjectName(java.lang.String name)
name - convert this name
public static java.lang.String makeValidNetcdfObjectNameOld(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 name
public boolean isValidFile(RandomAccessFile raf)
throws java.io.IOException
IOServiceProvider
isValidFile in interface IOServiceProviderraf - RandomAccessFile
java.io.IOException - if read errorpublic java.lang.String getDetailInfo()
IOServiceProvider
getDetailInfo in interface IOServiceProvidergetDetailInfo in class AbstractIOServiceProvider
public void open(RandomAccessFile raf,
NetcdfFile ncfile,
CancelTask cancelTask)
throws java.io.IOException
IOServiceProvider
open in interface IOServiceProviderraf - 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 IOServiceProviderWriterfill - set fill mode true or false
public Array readData(Variable v2,
Section section)
throws java.io.IOException,
InvalidRangeException
IOServiceProvider
readData 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 error
InvalidRangeException - if invalid sectionRange
public Array readNestedData(Variable v2,
Section section)
throws java.io.IOException,
InvalidRangeException
java.io.IOException
InvalidRangeException
public long readToByteChannel(Variable v2,
Section section,
java.nio.channels.WritableByteChannel channel)
throws java.io.IOException,
InvalidRangeException
IOServiceProvider
readToByteChannel 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 WritableByteChannel
java.io.IOException - if read error
InvalidRangeException - if invalid sectionprotected static char[] convertByteToCharUTF(byte[] byteArray)
protected static byte[] convertCharToByteUTF(char[] from)
public void create(java.lang.String filename,
NetcdfFile ncfile,
int extra,
long preallocateSize,
boolean largeFile)
throws java.io.IOException
IOServiceProviderWriter
create in interface IOServiceProviderWriterfilename - name of file to create.ncfile - get dimensions, attributes, and variables from here.extra - 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
java.io.IOException - if I/O error
public boolean rewriteHeader(boolean largeFile)
throws java.io.IOException
rewriteHeader in interface IOServiceProviderWriterjava.io.IOException
public void writeData(Variable v2,
Section section,
Array values)
throws java.io.IOException,
InvalidRangeException
IOServiceProviderWriter
writeData 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 error
InvalidRangeException - if invalid section
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 IOServiceProviderWriterv2 - variable, or null for fglobal attributeatt - replace with this value
java.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 IOServiceProvidersyncExtend in class AbstractIOServiceProviderjava.io.IOException - if a read error occured when accessing the underlying dataset.
public boolean sync()
throws java.io.IOException
IOServiceProvider
sync in interface IOServiceProvidersync in class AbstractIOServiceProviderjava.io.IOException - if a read error occured when accessing the underlying dataset.
public void flush()
throws java.io.IOException
IOServiceProviderWriter
flush in interface IOServiceProviderWriterjava.io.IOException - if I/O error
public void close()
throws java.io.IOException
IOServiceProvider
close in interface IOServiceProviderclose in class AbstractIOServiceProviderjava.io.IOException - if read errorpublic java.lang.String toStringDebug(java.lang.Object o)
toStringDebug in interface IOServiceProvidertoStringDebug in class AbstractIOServiceProvidero - which object
public java.lang.Object sendIospMessage(java.lang.Object message)
IOServiceProvider
sendIospMessage in interface IOServiceProvidersendIospMessage in class AbstractIOServiceProvidermessage - opaque message.
public java.lang.String getFileTypeId()
IOServiceProvider
getFileTypeId in interface IOServiceProviderpublic 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 variable
java.io.IOException - on error
protected 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 in this Array.index - handles skipping around in the file.dataType - dataType of the variable
java.io.IOException - on error
protected 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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||