Package ucar.nc2.iosp
Interface IOServiceProvider
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractIOServiceProvider
public interface IOServiceProvider extends Closeable
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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask)
Read an existing RandomAccessFile, and populate rootGroup.void
buildFinish(NetcdfFile ncfile)
Sometimes the builder needs access to the finished objects.void
close()
Close the file.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.long
getLastModified()
Get last time the file was modified.Iterator<StructureData>
getSequenceIterator(Sequence s, int bufferSize)
Get the structure iterator.boolean
isValidFile(RandomAccessFile raf)
Check if this is a valid file for this IOServiceProvider.void
reacquire()
Reacquire any resources like file handles Used when reactivating in cache.Array<?>
readArrayData(Variable v2, Section section)
Read data from a top level Variable and return a memory resident Array.void
release()
Release any system resources like file handles.Object
sendIospMessage(Object message)
A way to communicate arbitrary information to and from an iosp.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
-
build
void build(RandomAccessFile raf, Group.Builder rootGroup, CancelTask cancelTask) throws IOException
Read an existing RandomAccessFile, and populate rootGroup. Note that you cannot reference the NetcdfFile within this routine, since it hasnt been created yet.- 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 when ncfile is finished being built.
-
readArrayData
Array<?> readArrayData(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
InvalidRangeException
-
getSequenceIterator
Iterator<StructureData> getSequenceIterator(Sequence s, int bufferSize)
Get the structure iterator. Iosps with top level sequences must override.- Parameters:
s
- the StructurebufferSize
- the buffersize, may be -1 for default.- Returns:
- an iterator over the StructureData
-
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.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if read error
-
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
-
getLastModified
long getLastModified()
Get last time the file was modified.
-
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"
-
-