Package ucar.nc2.iosp
Interface IOServiceProvider
- All Superinterfaces:
Comparable<IOServiceProvider>
- All Known Implementing Classes:
AbstractIOServiceProvider
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 ClassesModifier and TypeInterfaceDescriptionstatic enumUsed to determine the ordering for dynamically loaded IOServiceProviders. -
Method Summary
Modifier and TypeMethodDescriptionvoidbuild(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask) Open existing file, and populate it.voidbuildFinish(NetcdfFile ncfile) Sometimes the builder needs access to the finished objects.voidclose()Close the file.default intcompareTo(IOServiceProvider other) Use the SortGroup to determine the ordering for dynamically loaded IOServiceProviders.Show debug / underlying implementation detailsGet a human-readable description for this file type.Get a unique id for this file type.Get the version of this file type.default IOServiceProvider.SortGroupGet the SortGroup for this IOServiceProvider.getStructureIterator(Structure s, int bufferSize) Get the structure iterator.booleanIf this iosp implements build().booleanCheck if this is a valid file for this IOServiceProvider.voidReacquire any resources like file handles Used when reactivating in cache.Read data from a top level Variable and return a memory resident Array.Allows reading sections of nested variableslongreadToOutputStream(Variable v2, Section section, OutputStream out) Read data from a top level Variable and send data to a OutputStream.voidrelease()Release any system resources like file handles.sendIospMessage(Object message) A way to communicate arbitrary information to and from an iosp.Debug info for this object.
-
Method Details
-
isValidFile
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
-
isBuilder
boolean isBuilder()If this iosp implements build(). -
build
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
Sometimes the builder needs access to the finished objects. This is called after ncfile.build() -
readData
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:
-
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
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
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
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
-
release
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
Reacquire any resources like file handles Used when reactivating in cache.- Throws:
IOException
-
sendIospMessage
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
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
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
Use the SortGroup to determine the ordering for dynamically loaded IOServiceProviders.- Specified by:
compareToin interfaceComparable<IOServiceProvider>
-