Package ucar.nc2.internal.iosp.netcdf3
Class N3iospNew
- java.lang.Object
-
- ucar.nc2.iosp.AbstractIOServiceProvider
-
- ucar.nc2.internal.iosp.netcdf3.N3iospNew
-
- All Implemented Interfaces:
Comparable<IOServiceProvider>
,IOServiceProvider
- Direct Known Subclasses:
N3iospWriter
public class N3iospNew extends AbstractIOServiceProvider implements IOServiceProvider
Netcdf 3 version iosp, using Builders for immutability.- Since:
- 9/29/2019.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ucar.nc2.iosp.IOServiceProvider
IOServiceProvider.SortGroup
-
-
Field Summary
Fields Modifier and Type Field Description protected N3headerNew
header
protected long
lastModified
protected static org.slf4j.Logger
log
-
Fields inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
location, ncfile, raf, rafOrder
-
-
Constructor Summary
Constructors Constructor Description N3iospNew()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask)
Open existing file, and populate it.void
close()
Close the file.void
flush()
String
getDetailInfo()
Show debug / underlying implementation detailsString
getFileTypeDescription()
Get a human-readable description for this file type.String
getFileTypeId()
Get a unique id for this file type.String
getFileTypeVersion()
Get the version of this file type.boolean
isBuilder()
If this iosp implements build().boolean
isValidFile(RandomAccessFile raf)
Check if this is a valid file for this IOServiceProvider.void
open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask)
Deprecated.void
reacquire()
Reacquire any resources like file handles Used when reactivating in cache.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.Object
sendIospMessage(Object message)
A way to communicate arbitrary information to and from an iosp.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.-
Methods inherited from class ucar.nc2.iosp.AbstractIOServiceProvider
buildFinish, getLastModified, getStructureIterator, 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
buildFinish, compareTo, getSortGroup, getStructureIterator, readSection, readToOutputStream, release, streamToByteChannel
-
-
-
-
Field Detail
-
log
protected static org.slf4j.Logger log
-
header
protected N3headerNew header
-
lastModified
protected long lastModified
-
-
Method Detail
-
isValidFile
public boolean isValidFile(RandomAccessFile raf) throws IOException
Description copied from interface:IOServiceProvider
Check if this is a valid file for this IOServiceProvider. You must make this method thread safe, ie dont keep any state.- Specified by:
isValidFile
in interfaceIOServiceProvider
- Parameters:
raf
- RandomAccessFile- Returns:
- true if valid.
- Throws:
IOException
- if read error
-
getDetailInfo
public String getDetailInfo()
Description copied from interface:IOServiceProvider
Show debug / underlying implementation details- Specified by:
getDetailInfo
in interfaceIOServiceProvider
- Overrides:
getDetailInfo
in classAbstractIOServiceProvider
- Returns:
- debug info
-
open
@Deprecated public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException
Deprecated.Description copied from interface:IOServiceProvider
Open 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:
open
in interfaceIOServiceProvider
- Overrides:
open
in 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
-
isBuilder
public boolean isBuilder()
Description copied from interface:IOServiceProvider
If this iosp implements build().- Specified by:
isBuilder
in interfaceIOServiceProvider
- Overrides:
isBuilder
in classAbstractIOServiceProvider
-
build
public void build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask) throws IOException
Description copied from interface:IOServiceProvider
Open existing file, and populate it. Note that you cannot reference the NetcdfFile within this routine. This is the bridge to immutable objects that will be used exclusively in version 6.- Specified by:
build
in interfaceIOServiceProvider
- Overrides:
build
in classAbstractIOServiceProvider
- Parameters:
raf
- the file to work on, it has already passed the isValidFile() test.rootGroup
- add objects to the root group.cancelTask
- used to monitor user cancellation; may be null.- Throws:
IOException
- if read error
-
readData
public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException
Description copied from interface:IOServiceProvider
Read 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:
readData
in 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
Description copied from interface:IOServiceProvider
Read data from a top level Variable and send data to a WritableByteChannel. Must be in big-endian order.- Specified by:
readToByteChannel
in interfaceIOServiceProvider
- Overrides:
readToByteChannel
in 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
-
syncExtend
public boolean syncExtend() throws IOException
Description copied from interface:IOServiceProvider
Extend 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:
syncExtend
in interfaceIOServiceProvider
- Overrides:
syncExtend
in 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 IOException
- Throws:
IOException
-
close
public void close() throws IOException
Description copied from interface:IOServiceProvider
Close 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:
close
in interfaceIOServiceProvider
- Overrides:
close
in classAbstractIOServiceProvider
- Throws:
IOException
- if read error
-
reacquire
public void reacquire() throws IOException
Description copied from interface:IOServiceProvider
Reacquire any resources like file handles Used when reactivating in cache.- Specified by:
reacquire
in interfaceIOServiceProvider
- Overrides:
reacquire
in classAbstractIOServiceProvider
- Throws:
IOException
-
toStringDebug
public String toStringDebug(Object o)
Description copied from interface:IOServiceProvider
Debug info for this object.- Specified by:
toStringDebug
in interfaceIOServiceProvider
- Overrides:
toStringDebug
in classAbstractIOServiceProvider
- Parameters:
o
- which object- Returns:
- debug info for this object
-
sendIospMessage
public Object sendIospMessage(Object message)
Description copied from interface:IOServiceProvider
A way to communicate arbitrary information to and from an iosp.- Specified by:
sendIospMessage
in interfaceIOServiceProvider
- Overrides:
sendIospMessage
in 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()
Description copied from interface:IOServiceProvider
Get a unique id for this file type.- Specified by:
getFileTypeId
in 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()
Description copied from interface:IOServiceProvider
Get a human-readable description for this file type.- Specified by:
getFileTypeDescription
in interfaceIOServiceProvider
- Returns:
- description of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeVersion
public String getFileTypeVersion()
Description copied from interface:IOServiceProvider
Get the version of this file type.- Specified by:
getFileTypeVersion
in interfaceIOServiceProvider
- Overrides:
getFileTypeVersion
in classAbstractIOServiceProvider
- Returns:
- version of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
-