Package ucar.nc2.util.cache
Interface FileCacheable
-
- All Known Subinterfaces:
FeatureDataset,FeatureDatasetPoint,GridDataset,RadialDatasetSweep,StationRadialDataset
- All Known Implementing Classes:
AbstractRadialAdapter,CdmRemote,CFRadialAdapter,Dorade2RadialAdapter,FeatureDatasetCoverage,FeatureDatasetImpl,GridDataset,HTTPRandomAccessFile,InMemoryRandomAccessFile,MMapRandomAccessFile,NetcdfDataset,NetcdfFile,NetcdfFileSubclass,Nexrad2RadialAdapter,NidsRadialAdapter,NsslRadialAdapter,PointDatasetImpl,PointDatasetRemote,RandomAccessFile,RemoteRandomAccessFile,SimpleGeometryFeatureDataset,UF2RadialAdapter
public interface FileCacheableInterface for files that can be stored in FileCache. Requirements: 1. hashCode() must return Object.hashCode() 2. close() must call cache.release(this) if cache is not null. 3. must be able to detect changes in underlying object, and indicate whether it has changed. THIS IS AN INTERNAL CLASS, DO NOT USE DIRECTLY.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close the FileCacheable, release all resources.longgetLastModified()Returns the time that the underlying file(s) were last modified.StringgetLocation()The location of the FileCacheable.voidreacquire()Reacquire any resources like file handles Used when reactivating in cache.voidrelease()Release any system resources like file handles.voidsetFileCache(FileCacheIF fileCache)If the FileCache is not null, FileCacheable.close() must call FileCache.release()
-
-
-
Method Detail
-
getLocation
String getLocation()
The location of the FileCacheable. This must be sufficient for FileFactory.factory() to create the FileCacheable object- Returns:
- location
-
close
void close() throws IOExceptionClose the FileCacheable, release all resources. Must call cache.release(this) if cache is not null.- Throws:
IOException- on io error
-
getLastModified
long getLastModified()
Returns the time that the underlying file(s) were last modified. If they've changed since they were stored in the cache, they will be closed and reopened withFileFactory.- Returns:
- a
longvalue representing the time the file(s) were last modified or0Lif the last-modified time couldn't be determined for any reason.
-
setFileCache
void setFileCache(FileCacheIF fileCache)
If the FileCache is not null, FileCacheable.close() must call FileCache.release()public synchronized void close() throws java.io.IOException { if (cache != null) { if (cache.release(this)) return; } reallyClose(); }- Parameters:
fileCache- must store this, use it on close as above.
-
release
void release() throws IOExceptionRelease 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 IOExceptionReacquire any resources like file handles Used when reactivating in cache.- Throws:
IOException
-
-