/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close() when done. * * @param factory use this factory to open the file; may not be null * @param location file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, location, location, -1, cancelTask, null); }
/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close when done. * * @param factory use this factory to open the file; may not be null * @param durl file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, DatasetUrl durl, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, durl.trueurl, durl, -1, cancelTask, null); }
/** * Acquire a FileCacheable, and lock it so no one else can use it. * call FileCacheable.close() when done. * * @param factory use this factory to open the file; may not be null * @param location file location, also used as the cache name, will be passed to the NetcdfFileFactory * @param cancelTask user can cancel, ok to be null. * @return NetcdfFile corresponding to location. * @throws IOException on error */ public FileCacheable acquire(FileFactory factory, String location, ucar.nc2.util.CancelTask cancelTask) throws IOException { return acquire(factory, location, location, -1, cancelTask, null); }
@Override public FileCacheable acquire(FileFactory factory, DatasetUrl durl) throws IOException { return acquire(factory, durl.trueurl, durl, -1, null, null); }
@Override public FileCacheable acquire(FileFactory factory, String location) throws IOException { return acquire(factory, location, location, -1, null, null); }
static private NetcdfFile acquireNcml(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return NcMLReader.readNcML(location, cancelTask); if (factory == null) factory = new NcMLFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireNcml(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return NcMLReader.readNcML(location, cancelTask); if (factory == null) factory = new NcMLFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireDODS(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) { return openDodsByReflection(location, cancelTask); } if (factory == null) factory = new DodsFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireDODS(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) { return openDodsByReflection(location, cancelTask); } if (factory == null) factory = new DodsFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireDap4(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) { return openDap4ByReflection(location, cancelTask); } if (factory == null) factory = new Dap4Factory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireDap4(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if(cache == null) { return openDap4ByReflection(location,cancelTask); } if (factory == null) factory = new Dap4Factory(); return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireNcml(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return NcMLReader.readNcML(location, cancelTask); if (factory == null) factory = new NcMLFactory(); // LOOK maybe always should use NcMLFactory ? return (NetcdfFile) cache.acquire(factory, hashKey, DatasetUrl.findDatasetUrl(location), buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireDODS(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) { return openDodsByReflection(location, cancelTask); } if (factory == null) factory = new DodsFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, new DatasetUrl(ServiceType.OPENDAP, location), buffer_size, cancelTask, spiObject); }
static private NetcdfFile acquireCdmRemote(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) return new CdmRemote(location); if (factory == null) factory = new RemoteFactory(); return (NetcdfFile) cache.acquire(factory, hashKey, new DatasetUrl(ServiceType.CdmRemote, location), buffer_size, cancelTask, spiObject); }
public FileCacheable call() throws Exception { DatasetUrl durl = new DatasetUrl(null, location); return cache.acquire(factory, durl); } }
static private NetcdfFile acquireDap4(FileCache cache, FileFactory factory, Object hashKey, String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException { if (cache == null) { return openDap4ByReflection(location, cancelTask); } if (factory == null) factory = new Dap4Factory(); return (NetcdfFile) cache.acquire(factory, hashKey, new DatasetUrl(ServiceType.DAP4, location), buffer_size, cancelTask, spiObject); }
void loadFilesIntoCache(File dir, FileCache cache) { File[] files = dir.listFiles(); if ( files == null) return; for (File f : files) { if (f.isDirectory()) loadFilesIntoCache(f, cache); else if (f.getPath().endsWith(".nc") && f.length() > 0) { //System.out.println(" open "+f.getPath()); try { String want = StringUtil2.replace(f.getPath(), '\\', "/"); DatasetUrl durl = new DatasetUrl(null, want); cache.acquire(factory, durl); count++; } catch (IOException e) { // e.printStackTrace(); System.out.println(" *** failed on " + f.getPath()); } } } }
return (NetcdfFile) cache.acquire(factory, hashKey, durl, buffer_size, cancelTask, spiObject);