Package ucar.nc2.iosp
Interface IOServiceProvider
-
- All Superinterfaces:
Comparable<IOServiceProvider>
- All Known Subinterfaces:
IOServiceProviderWriter
- All Known Implementing Classes:
AbstractIOServiceProvider
,AbstractLightningIOSP
,AreaServiceProvider
,BufrIosp2
,Cinrad2IOServiceProvider
,DMSPiosp
,Doradeiosp
,Fysatiosp
,GempakGridServiceProvider
,GempakSoundingIOSP
,GempakStationFileIOSP
,GempakSurfaceIOSP
,Ghcnm
,Ghcnm2
,Giniiosp
,GradsBinaryGridServiceProvider
,Grib1Iosp
,Grib2Iosp
,GribIosp
,GridServiceProvider
,GtopoIosp
,H4iosp
,H4iosp
,H5iosp
,H5iospNew
,IgraPor
,McIDASGridServiceProvider
,N3iosp
,N3iospNew
,N3iospWriter
,N3raf
,Nc4Iosp
,NcStreamIosp
,Nexrad2IOServiceProvider
,Nidsiosp
,Nldn
,NmcObsLegacy
,NOWRadiosp
,ShapefileIosp
,SigmetIOServiceProvider
,UAMIVServiceProvider
,UFiosp
,Uspln
,Vis5DIosp
,ZarrIosp
public interface IOServiceProvider extends Comparable<IOServiceProvider>
This is the service provider interface for the low-level I/O access classes (read only). This is only used by service implementors. An implementation must have a no-argument constructor. The NetcdfFile class manages all registered IOServiceProvider classes. When NetcdfFiles.open() is called:- the file is opened as a ucar.unidata.io.RandomAccessFile;
- the file is handed to the isValidFile() method of each registered IOServiceProvider class (until one returns true, which means it can read the file).
- the open() method on the resulting IOServiceProvider class is handed the file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IOServiceProvider.SortGroup
Used to determine the ordering for dynamically loaded IOServiceProviders.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask)
Open existing file, and populate it.void
buildFinish(NetcdfFile ncfile)
Sometimes the builder needs access to the finished objects.void
close()
Close the file.default int
compareTo(IOServiceProvider other)
Use the SortGroup to determine the ordering for dynamically loaded IOServiceProviders.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.default IOServiceProvider.SortGroup
getSortGroup()
Get the SortGroup for this IOServiceProvider.StructureDataIterator
getStructureIterator(Structure s, int bufferSize)
Get the structure iterator.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.Use build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask)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.Array
readSection(ParsedSectionSpec cer)
Allows reading sections of nested variableslong
readToByteChannel(Variable v2, Section section, WritableByteChannel channel)
Deprecated.do not uselong
readToOutputStream(Variable v2, Section section, OutputStream out)
Read data from a top level Variable and send data to a OutputStream.void
release()
Release any system resources like file handles.Object
sendIospMessage(Object message)
A way to communicate arbitrary information to and from an iosp.long
streamToByteChannel(Variable v2, Section section, WritableByteChannel channel)
Deprecated.do not useboolean
syncExtend()
Deprecated.Do not use.String
toStringDebug(Object o)
Debug info for this object.
-
-
-
Method Detail
-
isValidFile
boolean isValidFile(RandomAccessFile raf) throws IOException
Check if this is a valid file for this IOServiceProvider. You must make this method thread safe, ie dont keep any state.- Parameters:
raf
- RandomAccessFile- Returns:
- true if valid.
- Throws:
IOException
- if read error
-
open
@Deprecated void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException
Deprecated.Use build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask)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.- 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
boolean isBuilder()
If this iosp implements build().
-
build
void build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask) throws IOException
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.- 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
-
buildFinish
void buildFinish(NetcdfFile ncfile)
Sometimes the builder needs access to the finished objects. This is called after ncfile.build()
-
readData
Array readData(Variable v2, Section section) throws IOException, InvalidRangeException
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.- 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
@Deprecated long readToByteChannel(Variable v2, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
Deprecated.do not useRead data from a top level Variable and send data to a WritableByteChannel. Must be in big-endian order.- 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
-
streamToByteChannel
@Deprecated long streamToByteChannel(Variable v2, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
Deprecated.do not use- Throws:
IOException
InvalidRangeException
-
readToOutputStream
long readToOutputStream(Variable v2, Section section, OutputStream out) throws IOException, InvalidRangeException
Read data from a top level Variable and send data to a OutputStream. Must be in big-endian order, following ncstream conventions. Default implementation just reads to memory and writes to stream. Allow override for possible performance improvements.- 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.out
- write data to this OutputStream- Returns:
- the number of bytes written to the channel
- Throws:
IOException
- if read errorInvalidRangeException
- if invalid section
-
readSection
Array readSection(ParsedSectionSpec cer) throws IOException, InvalidRangeException
Allows reading sections of nested variables- Parameters:
cer
- section specification : what data is wanted- Returns:
- requested data array
- Throws:
IOException
- on read errorInvalidRangeException
- if section spec is invalid
-
getStructureIterator
StructureDataIterator getStructureIterator(Structure s, int bufferSize) throws IOException
Get the structure iterator. iosps with top level sequences must override. Not threadsafe; do not use multiple StructureDataIterator for the same iosp.- Parameters:
s
- the StructurebufferSize
- the buffersize- Returns:
- the data iterator
- Throws:
IOException
- if problem reading data
-
close
void close() throws IOException
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.- Throws:
IOException
- if read error
-
syncExtend
@Deprecated boolean syncExtend() throws IOException
Deprecated.Do not use.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.- Returns:
- true if the NetcdfFile was extended.
- Throws:
IOException
- if a read error occured when accessing the underlying dataset.
-
release
void release() throws IOException
Release any system resources like file handles. Optional, implement only if you are able to reacquire. Used when object is made inactive in cache.- Throws:
IOException
-
reacquire
void reacquire() throws IOException
Reacquire any resources like file handles Used when reactivating in cache.- Throws:
IOException
-
sendIospMessage
@Nullable Object sendIospMessage(@Nullable Object message)
A way to communicate arbitrary information to and from an iosp.- Parameters:
message
- opaque message sent to the IOSP object when its opened (not when isValidFile() is called)- Returns:
- opaque Object, may be null.
-
toStringDebug
String toStringDebug(Object o)
Debug info for this object.- Parameters:
o
- which object- Returns:
- debug info for this object
-
getDetailInfo
String getDetailInfo()
Show debug / underlying implementation details- Returns:
- debug info
-
getFileTypeId
String getFileTypeId()
Get a unique id for this file type.- Returns:
- registered id of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeVersion
String getFileTypeVersion()
Get the version of this file type.- Returns:
- version of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeDescription
String getFileTypeDescription()
Get a human-readable description for this file type.- Returns:
- description of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getSortGroup
default IOServiceProvider.SortGroup getSortGroup()
Get the SortGroup for this IOServiceProvider. This determines the order in which the dynamically loaded IOServiceProviders are checked to see if they can open a file with isValidFile().- Returns:
- SortGroup, by default the SortGroup.LAST_GROUP will be used.
-
compareTo
default int compareTo(IOServiceProvider other)
Use the SortGroup to determine the ordering for dynamically loaded IOServiceProviders.- Specified by:
compareTo
in interfaceComparable<IOServiceProvider>
-
-