Package ucar.nc2.iosp.netcdf3
Class N3iosp
- java.lang.Object
-
- ucar.nc2.iosp.AbstractIOServiceProvider
-
- ucar.nc2.iosp.netcdf3.N3iosp
-
- All Implemented Interfaces:
Comparable<IOServiceProvider>,IOServiceProvider,IOServiceProviderWriter
- Direct Known Subclasses:
N3raf
@Deprecated public abstract class N3iosp extends AbstractIOServiceProvider implements IOServiceProviderWriter
Deprecated.do not useIOServiceProvider implementation abstract base class to read/write "version 3" netcdf files. AKA "file format version 1" files.- See Also:
concrete class
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ucar.nc2.iosp.IOServiceProvider
IOServiceProvider.SortGroup
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandebugDeprecated.protected booleandebugReadDeprecated.protected booleandebugRecordDeprecated.protected booleandebugSizeDeprecated.protected booleandebugSPIODeprecated.protected booleanfillDeprecated.protected N3headerheaderDeprecated.protected longlastModifiedDeprecated.static intMAX_NUMRECSDeprecated.The maximum number of records is 2^32-1.static longMAX_VARSIZEDeprecated.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 byteNC_FILL_BYTEDeprecated.static charNC_FILL_CHARDeprecated.static doubleNC_FILL_DOUBLEDeprecated.static floatNC_FILL_FLOATDeprecated.static intNC_FILL_INTDeprecated.static longNC_FILL_INT64Deprecated.static shortNC_FILL_SHORTDeprecated.static StringNC_FILL_STRINGDeprecated.static byteNC_FILL_UBYTEDeprecated.static intNC_FILL_UINTDeprecated.static longNC_FILL_UINT64Deprecated.static shortNC_FILL_USHORTDeprecated.protected booleanreadonlyDeprecated.protected booleanshowHeaderBytesDeprecated.protected booleanuseRecordStructureDeprecated.-
Fields inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
location, ncfile, raf, rafOrder
-
-
Constructor Summary
Constructors Constructor Description N3iosp()Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract void_create(RandomAccessFile raf)Deprecated.protected abstract void_open(RandomAccessFile raf)Deprecated.intappendStructureData(Structure s, StructureData sdata)Deprecated.Append a structureData along the unlimited dimensionvoidclose()Deprecated.Close the file.voidcreate(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile)Deprecated.Create new file, populate it from the objects in ncfile.static StringcreateValidNetcdf3ObjectName(String name)Deprecated.use makeValidNetcdfObjectNameprotected voidfillNonRecordVariables()Deprecated.protected voidfillRecordVariables(int recStart, int recEnd)Deprecated.voidflush()Deprecated.Flush all data buffers to disk.StringgetDetailInfo()Deprecated.Show debug / underlying implementation detailsStringgetFileTypeDescription()Deprecated.Get a human-readable description for this file type.StringgetFileTypeId()Deprecated.Get a unique id for this file type.StringgetFileTypeVersion()Deprecated.Get the version of this file type.static NumbergetFillValueDefault(DataType dtype)Deprecated.static com.google.re2j.PatterngetValidNetcdf3ObjectNamePattern()Deprecated.Valid Netcdf Object name as a regular expression.booleanisValidFile(RandomAccessFile raf)Deprecated.Check if this is a valid file for this IOServiceProvider.static booleanisValidNetcdf3ObjectName(String name)Deprecated.use isValidNetcdfObjectNamestatic booleanisValidNetcdfObjectName(String name)Deprecated.Determine if the given name can be used for a NetCDF object, i.e.static StringmakeValidNetcdf3ObjectName(String name)Deprecated.use makeValidNetcdfObjectNamestatic StringmakeValidNetcdfObjectName(String name)Deprecated.Convert a name to a legal netcdf-3 name.voidopen(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)Deprecated.Open existing file, and populate ncfile with it.voidopenForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)Deprecated.Open existing file and allow writing.voidreacquire()Deprecated.Reacquire any resources like file handles Used when reactivating in cache.protected abstract ObjectreadData(Layout index, DataType dataType)Deprecated.Read data subset from file for a variable, create primitive array.protected abstract longreadData(Layout index, DataType dataType, WritableByteChannel out)Deprecated.ArrayreadData(Variable v2, Section section)Deprecated.Read data from a top level Variable and return a memory resident Array.longreadToByteChannel(Variable v2, Section section, WritableByteChannel channel)Deprecated.Read data from a top level Variable and send data to a WritableByteChannel.booleanrewriteHeader(boolean largeFile)Deprecated.if theres room before data, rewrite header without moving the data.ObjectsendIospMessage(Object message)Deprecated.A way to communicate arbitrary information to and from an iosp.voidsetFill(boolean fill)Deprecated.Set the fill flag.protected voidsetNumrecs(int n)Deprecated.static voidsetProperty(String name, String value)Deprecated.Set a static property.booleansyncExtend()Deprecated.Extend the NetcdfFile if the underlying dataset has changed in a way that is compatible with the current metadata.StringtoStringDebug(Object o)Deprecated.Debug info for this object.voidupdateAttribute(Variable v2, Attribute att)Deprecated.Update the value of an existing attribute.protected abstract voidwriteData(Array aa, Layout index, DataType dataType)Deprecated.Write data subset to file for a variable, create primitive array.voidwriteData(Variable v2, Section section, Array values)Deprecated.Write data into a variable.-
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
build, buildFinish, getLastModified, getStructureIterator, isBuilder, readSection, readToOutputStream, release, setNetcdfFile, streamToByteChannel
-
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
build, buildFinish, compareTo, getSortGroup, getStructureIterator, isBuilder, readSection, readToOutputStream, release, streamToByteChannel
-
-
-
-
Field Detail
-
NC_FILL_BYTE
public static final byte NC_FILL_BYTE
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_CHAR
public static final char NC_FILL_CHAR
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_SHORT
public static final short NC_FILL_SHORT
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_INT
public static final int NC_FILL_INT
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_FLOAT
public static final float NC_FILL_FLOAT
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_DOUBLE
public static final double NC_FILL_DOUBLE
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_UBYTE
public static final byte NC_FILL_UBYTE
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_USHORT
public static final short NC_FILL_USHORT
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_UINT
public static final int NC_FILL_UINT
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_INT64
public static final long NC_FILL_INT64
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_UINT64
public static final long NC_FILL_UINT64
Deprecated.- See Also:
- Constant Field Values
-
NC_FILL_STRING
public static final String NC_FILL_STRING
Deprecated.- See Also:
- Constant Field Values
-
MAX_VARSIZE
public static final long MAX_VARSIZE
Deprecated.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.- See Also:
- Constant Field Values
-
MAX_NUMRECS
public static final int MAX_NUMRECS
Deprecated.The maximum number of records is 2^32-1.- See Also:
- Constant Field Values
-
readonly
protected boolean readonly
Deprecated.
-
header
protected N3header header
Deprecated.
-
lastModified
protected long lastModified
Deprecated.
-
debug
protected boolean debug
Deprecated.
-
debugSize
protected boolean debugSize
Deprecated.
-
debugSPIO
protected boolean debugSPIO
Deprecated.
-
debugRecord
protected boolean debugRecord
Deprecated.
-
debugRead
protected boolean debugRead
Deprecated.
-
showHeaderBytes
protected boolean showHeaderBytes
Deprecated.
-
useRecordStructure
protected boolean useRecordStructure
Deprecated.
-
fill
protected boolean fill
Deprecated.
-
-
Method Detail
-
setProperty
public static void setProperty(String name, String value)
Deprecated.Set a static property. Supported static properties:- syncExtendOnly = "true" : assume all file changes are syncExtend only.
- Parameters:
name- property namevalue- property value
-
isValidNetcdfObjectName
public static boolean isValidNetcdfObjectName(String name)
Deprecated.Determine if the given name can be used for a NetCDF object, i.e. a Dimension, Attribute, or Variable. The allowed name syntax (in RE form) is:([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.- Parameters:
name- the name to validate.- Returns:
trueif the name is valid.
-
makeValidNetcdfObjectName
public static String makeValidNetcdfObjectName(String name)
Deprecated.Convert a name to a legal netcdf-3 name.- Parameters:
name- the name to convert.- Returns:
- the converted name.
- See Also:
isValidNetcdfObjectName(String)
-
makeValidNetcdf3ObjectName
public static String makeValidNetcdf3ObjectName(String name)
Deprecated.use makeValidNetcdfObjectName
-
isValidNetcdf3ObjectName
public static boolean isValidNetcdf3ObjectName(String name)
Deprecated.use isValidNetcdfObjectNameDetermine if the given name can be used for a Dimension, Attribute, or Variable name. Should match makeValidNetcdf3ObjectName.- Parameters:
name- test this.- Returns:
- true if valid name.
-
getValidNetcdf3ObjectNamePattern
public static com.google.re2j.Pattern getValidNetcdf3ObjectNamePattern()
Deprecated.Valid Netcdf Object name as a regular expression.- Returns:
- regular expression pattern describing valid Netcdf Object names.
-
createValidNetcdf3ObjectName
public static String createValidNetcdf3ObjectName(String name)
Deprecated.use makeValidNetcdfObjectNameConvert a name to a legal netcdf name. From the user manual: "The names of dimensions, variables and attributes consist of arbitrary sequences of alphanumeric characters (as well as underscore '_' and hyphen '-'), beginning with a letter or underscore. (However names commencing with underscore are reserved for system use.) Case is significant in netCDF names." Algorithm:- leading character: if alpha or underscore, ok; if digit, prepend "N"; otherwise discard
- other characters: if space, change to underscore; other delete.
- Parameters:
name- convert this name- Returns:
- converted name
-
isValidFile
public boolean isValidFile(RandomAccessFile raf) throws IOException
Deprecated.Description copied from interface:IOServiceProviderCheck if this is a valid file for this IOServiceProvider. You must make this method thread safe, ie dont keep any state.- Specified by:
isValidFilein interfaceIOServiceProvider- Parameters:
raf- RandomAccessFile- Returns:
- true if valid.
- Throws:
IOException- if read error
-
getDetailInfo
public String getDetailInfo()
Deprecated.Description copied from interface:IOServiceProviderShow debug / underlying implementation details- Specified by:
getDetailInfoin interfaceIOServiceProvider- Overrides:
getDetailInfoin classAbstractIOServiceProvider- Returns:
- debug info
-
openForWriting
public void openForWriting(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException
Deprecated.Description copied from interface:IOServiceProviderWriterOpen existing file and allow writing. Netcdf-4 writing is general. Netcdf-3 writing is restricted to writing data into existing variables.- Specified by:
openForWritingin interfaceIOServiceProviderWriter- Parameters:
raf- the file to work on.ncfile- add objects to this empty NetcdfFilecancelTask- used to monitor user cancellation; may be null.- Throws:
IOException- if I/O error
-
open
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException
Deprecated.Description copied from interface:IOServiceProviderOpen existing file, and populate ncfile with it. This method is only called by the NetcdfFile constructor on itself. The provided NetcdfFile object will be empty except for the location String and the IOServiceProvider associated with this NetcdfFile object.- Specified by:
openin interfaceIOServiceProvider- Overrides:
openin classAbstractIOServiceProvider- Parameters:
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.- Throws:
IOException- if read error
-
setFill
public void setFill(boolean fill)
Deprecated.Description copied from interface:IOServiceProviderWriterSet the fill flag. For new files, set in the create() method. This method is to set fill for existing files that you want to write. If true, the data is first written with fill values. Set to false if you expect to write all data values, set to true if you want to be sure that unwritten data values have the fill value in it.- Specified by:
setFillin interfaceIOServiceProviderWriter- Parameters:
fill- set fill mode true or false
-
readData
public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException
Deprecated.Description copied from interface:IOServiceProviderRead data from a top level Variable and return a memory resident Array. This Array has the same element type as the Variable, and the requested shape.- Specified by:
readDatain interfaceIOServiceProvider- Parameters:
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.- Returns:
- the requested data in a memory-resident Array
- Throws:
IOException- if read errorInvalidRangeException- if invalid section- See Also:
Range
-
readToByteChannel
public long readToByteChannel(Variable v2, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
Deprecated.Description copied from interface:IOServiceProviderRead data from a top level Variable and send data to a WritableByteChannel. Must be in big-endian order.- Specified by:
readToByteChannelin interfaceIOServiceProvider- Overrides:
readToByteChannelin classAbstractIOServiceProvider- Parameters:
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 WritableByteChannel- Returns:
- the number of bytes written to the channel
- Throws:
IOException- if read errorInvalidRangeException- if invalid section
-
create
public void create(String filename, NetcdfFile ncfile, int extra, long preallocateSize, boolean largeFile) throws IOException
Deprecated.Description copied from interface:IOServiceProviderWriterCreate new file, populate it from the objects in ncfile.- Specified by:
createin interfaceIOServiceProviderWriter- Parameters:
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 format- Throws:
IOException- if I/O error
-
rewriteHeader
public boolean rewriteHeader(boolean largeFile) throws IOExceptionDeprecated.Description copied from interface:IOServiceProviderWriterif theres room before data, rewrite header without moving the data. netcdf3 only- Specified by:
rewriteHeaderin interfaceIOServiceProviderWriter- Returns:
- true if it worked
- Throws:
IOException
-
writeData
public void writeData(Variable v2, Section section, Array values) throws IOException, InvalidRangeException
Deprecated.Description copied from interface:IOServiceProviderWriterWrite data into a variable.- Specified by:
writeDatain interfaceIOServiceProviderWriter- Parameters:
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().- Throws:
IOException- if I/O errorInvalidRangeException- if invalid section
-
appendStructureData
public int appendStructureData(Structure s, StructureData sdata) throws IOException, InvalidRangeException
Deprecated.Description copied from interface:IOServiceProviderWriterAppend a structureData along the unlimited dimension- Specified by:
appendStructureDatain interfaceIOServiceProviderWriter- Parameters:
s- belongs to this structuresdata- the stuctureData to append- Returns:
- the recnum where it was written
- Throws:
IOExceptionInvalidRangeException
-
setNumrecs
protected void setNumrecs(int n) throws IOException, InvalidRangeExceptionDeprecated.- Throws:
IOExceptionInvalidRangeException
-
updateAttribute
public void updateAttribute(Variable v2, Attribute att) throws IOException
Deprecated.Update the value of an existing attribute. Attribute is found by name, which must match exactly. You cannot make an attribute longer, or change the number of values. For strings: truncate if longer, zero fill if shorter. Strings are padded to 4 byte boundaries, ok to use padding if it exists. For numerics: must have same number of values.- Specified by:
updateAttributein interfaceIOServiceProviderWriter- Parameters:
v2- variable, or null for fglobal attributeatt- replace with this value- Throws:
IOException
-
fillNonRecordVariables
protected void fillNonRecordVariables() throws IOExceptionDeprecated.- Throws:
IOException
-
fillRecordVariables
protected void fillRecordVariables(int recStart, int recEnd) throws IOException, InvalidRangeExceptionDeprecated.- Throws:
IOExceptionInvalidRangeException
-
syncExtend
public boolean syncExtend() throws IOExceptionDeprecated.Description copied from interface:IOServiceProviderExtend the NetcdfFile if the underlying dataset has changed in a way that is compatible with the current metadata. For example, if the unlimited dimension has grown.- Specified by:
syncExtendin interfaceIOServiceProvider- Overrides:
syncExtendin classAbstractIOServiceProvider- Returns:
- true if the NetcdfFile was extended.
- Throws:
IOException- if a read error occured when accessing the underlying dataset.
-
flush
public void flush() throws IOExceptionDeprecated.Description copied from interface:IOServiceProviderWriterFlush all data buffers to disk.- Specified by:
flushin interfaceIOServiceProviderWriter- Throws:
IOException
-
close
public void close() throws IOExceptionDeprecated.Description copied from interface:IOServiceProviderClose the file. It is the IOServiceProvider's job to close the file (even though it didnt open it), and to free any other resources it has used.- Specified by:
closein interfaceIOServiceProvider- Overrides:
closein classAbstractIOServiceProvider- Throws:
IOException- if read error
-
reacquire
public void reacquire() throws IOExceptionDeprecated.Description copied from interface:IOServiceProviderReacquire any resources like file handles Used when reactivating in cache.- Specified by:
reacquirein interfaceIOServiceProvider- Overrides:
reacquirein classAbstractIOServiceProvider- Throws:
IOException
-
toStringDebug
public String toStringDebug(Object o)
Deprecated.Debug info for this object.- Specified by:
toStringDebugin interfaceIOServiceProvider- Overrides:
toStringDebugin classAbstractIOServiceProvider- Parameters:
o- which object- Returns:
- debug info for this object
-
sendIospMessage
public Object sendIospMessage(Object message)
Deprecated.Description copied from interface:IOServiceProviderA way to communicate arbitrary information to and from an iosp.- Specified by:
sendIospMessagein interfaceIOServiceProvider- Overrides:
sendIospMessagein classAbstractIOServiceProvider- Parameters:
message- opaque message sent to the IOSP object when its opened (not when isValidFile() is called)- Returns:
- opaque Object, may be null.
-
getFileTypeId
public String getFileTypeId()
Deprecated.Description copied from interface:IOServiceProviderGet a unique id for this file type.- Specified by:
getFileTypeIdin interfaceIOServiceProvider- Returns:
- registered id of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeDescription
public String getFileTypeDescription()
Deprecated.Description copied from interface:IOServiceProviderGet a human-readable description for this file type.- Specified by:
getFileTypeDescriptionin interfaceIOServiceProvider- Returns:
- description of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeVersion
public String getFileTypeVersion()
Deprecated.Description copied from interface:IOServiceProviderGet the version of this file type.- Specified by:
getFileTypeVersionin interfaceIOServiceProvider- Overrides:
getFileTypeVersionin classAbstractIOServiceProvider- Returns:
- version of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
readData
protected abstract Object readData(Layout index, DataType dataType) throws IOException
Deprecated.Read data subset from file for a variable, create primitive array.- Parameters:
index- handles skipping around in the file.dataType- dataType of the variable- Returns:
- primitive array with data read in
- Throws:
IOException- on error
-
readData
protected abstract long readData(Layout index, DataType dataType, WritableByteChannel out) throws IOException
Deprecated.- Throws:
IOException
-
writeData
protected abstract void writeData(Array aa, Layout index, DataType dataType) throws IOException
Deprecated.Write data subset to file for a variable, create primitive array.- Parameters:
aa- write data from this Array.index- handles skipping around in the file.dataType- dataType of the variable- Throws:
IOException- on error
-
_open
protected abstract void _open(RandomAccessFile raf)
Deprecated.
-
_create
protected abstract void _create(RandomAccessFile raf)
Deprecated.
-
-