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_INT64 |
static long |
NC_FILL_LONG |
static short |
NC_FILL_SHORT |
static 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(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.
|
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)
if theres room before data, rewrite header without moving the data.
|
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, reacquire, readSection, readToOutputStream, release, streamToByteChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFileTypeVersion, getStructureIterator, reacquire, 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 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 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
IOServiceProvider
isValidFile
in interface IOServiceProvider
raf
- RandomAccessFileIOException
- if read errorpublic String getDetailInfo()
IOServiceProvider
getDetailInfo
in interface IOServiceProvider
getDetailInfo
in class AbstractIOServiceProvider
public void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws 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.IOException
- if I/O errorpublic void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws 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.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 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.IOException
- if read errorInvalidRangeException
- if invalid sectionRange
public long readToByteChannel(Variable v2, Section section, WritableByteChannel channel) throws 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 WritableByteChannelIOException
- if read errorInvalidRangeException
- if invalid sectionpublic void create(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile) throws 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 formatIOException
- if I/O errorpublic boolean rewriteHeader(boolean largeFile) throws IOException
IOServiceProviderWriter
rewriteHeader
in interface IOServiceProviderWriter
IOException
public void writeData(Variable v2, Section section, Array values) throws 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().IOException
- if I/O errorInvalidRangeException
- if invalid sectionpublic int appendStructureData(Structure s, StructureData sdata) throws IOException, InvalidRangeException
IOServiceProviderWriter
appendStructureData
in interface IOServiceProviderWriter
s
- belongs to this structuresdata
- the stuctureData to appendIOException
InvalidRangeException
protected void setNumrecs(int n) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public void updateAttribute(Variable v2, Attribute att) throws IOException
updateAttribute
in interface IOServiceProviderWriter
v2
- variable, or null for fglobal attributeatt
- replace with this valueIOException
protected void fillNonRecordVariables() throws IOException
IOException
protected void fillRecordVariables(int recStart, int recEnd) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public boolean syncExtend() throws IOException
IOServiceProvider
syncExtend
in interface IOServiceProvider
syncExtend
in class AbstractIOServiceProvider
IOException
- if a read error occured when accessing the underlying dataset.public void flush() throws IOException
IOServiceProviderWriter
flush
in interface IOServiceProviderWriter
IOException
- if I/O errorpublic void close() throws IOException
IOServiceProvider
close
in interface IOServiceProvider
close
in class AbstractIOServiceProvider
IOException
- if read errorpublic String toStringDebug(Object o)
toStringDebug
in interface IOServiceProvider
toStringDebug
in class AbstractIOServiceProvider
o
- which objectpublic Object sendIospMessage(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 String getFileTypeId()
IOServiceProvider
getFileTypeId
in interface IOServiceProvider
public String getFileTypeDescription()
IOServiceProvider
getFileTypeDescription
in interface IOServiceProvider
protected 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
IOException
protected abstract void writeData(Array aa, Layout index, DataType dataType) throws IOException
aa
- write data from this Array.index
- handles skipping around in the file.dataType
- dataType of the variableIOException
- on errorprotected abstract void _open(RandomAccessFile raf) throws IOException
IOException
protected abstract void _create(RandomAccessFile raf) throws IOException
IOException
public static void main(String[] args)
Copyright © 1999–2019 UCAR/Unidata. All rights reserved.