/** * Get the file type id for the underlying data source. * * @return registered id of the file type * @see "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html" */ public String getFileTypeId() { if (spi != null) return spi.getFileTypeId(); return "N/A"; }
/** * Get a human-readable description for this file type. * * @return description of the file type * @see "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html" */ public String getFileTypeDescription() { if (spi != null) return spi.getFileTypeDescription(); return "N/A"; }
/** * Get the version of this file type. * * @return version of the file type * @see "http://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html" */ public String getFileTypeVersion() { if (spi != null) return spi.getFileTypeVersion(); return "N/A"; }
spi = (IOServiceProvider) iospClass.newInstance(); if (debugSPI) log.info("NetcdfFile uses iosp = {}", spi.getClass().getName()); if (iospParam != null) spi.sendIospMessage(iospParam); this.spi.open(raf, this, cancelTask); finish(); spi.close(); } catch (Throwable t1) { spi.close(); } catch (Throwable t1) {
if (currentSpi.isValidFile(raf)) { Class c = currentSpi.getClass(); try { if (debugSPI) System.out.println(" try iosp = " + registeredSpi.getClass().getName()); if (registeredSpi.isValidFile(raf)) { spi.sendIospMessage(iospMessage); spi.sendIospMessage(iospMessage);
/** * This can only be used for netcdf-3 files served over HTTP * * @param url HTTP URL location * @throws java.io.IOException if error * @deprecated use NetcdfFile.open( http:location) or NetcdfDataset.openFile( http:location) */ public NetcdfFile(URL url) throws IOException { this.location = url.toString(); ucar.unidata.io.RandomAccessFile raf = new ucar.unidata.io.http.HTTPRandomAccessFile(location); this.spi = SPFactory.getServiceProvider(); spi.open(raf, this, null); finish(); }
protected StructureDataIterator getStructureIterator(Structure s, int bufferSize) throws java.io.IOException { return spi.getStructureIterator(s, bufferSize); }
private static boolean canOpen(ucar.unidata.io.RandomAccessFile raf) throws IOException { if (N3header.isValidFile(raf)) { return true; } else { for (IOServiceProvider iosp : ServiceLoader.load(IOServiceProvider.class)) { log.info("ServiceLoader IOServiceProvider {}", iosp.getClass().getName()); if (iosp.isValidFile(raf)) { return true; } } for (IOServiceProvider registeredSpi : registeredProviders) { if (registeredSpi.isValidFile(raf)) return true; } } return false; }
public void getDetailInfo(Formatter f) { f.format("NetcdfFile location= %s%n", getLocation()); f.format(" title= %s%n", getTitle()); f.format(" id= %s%n", getId()); f.format(" fileType= %s%n", getFileTypeId()); f.format(" fileDesc= %s%n", getFileTypeDescription()); f.format(" fileVersion= %s%n", getFileTypeVersion()); f.format(" class= %s%n", getClass().getName()); if (spi == null) { f.format(" has no IOSP%n"); } else { f.format(" iosp= %s%n%n", spi.getClass()); f.format("%s", spi.getDetailInfo()); } showCached(f); showProxies(f); }
/** * Close all resources (files, sockets, etc) associated with this file. * If the underlying file was acquired, it will be released, otherwise closed. * if isClosed() already, nothing will happen * * @throws java.io.IOException if error when closing */ public synchronized void close() throws java.io.IOException { if (cache != null) { if (cache.release(this)) return; } try { if (null != spi) { // log.warn("NetcdfFile.close called for ncfile="+this.hashCode()+" for iosp="+spi.hashCode()); spi.close(); } } finally { spi = null; } }
/** * Read a variable using the given section specification. * The result is always an array of the type of the innermost variable. * Its shape is the accumulation of all the shapes of its parent structures. * * @param variableSection the constraint expression. * @return data requested * @throws IOException if error * @throws InvalidRangeException if variableSection is invalid * @see <a href="http://www.unidata.ucar.edu/software/netcdf-java/reference/SectionSpecification.html">SectionSpecification</a> */ public Array readSection(String variableSection) throws IOException, InvalidRangeException { /* if (unlocked) throw new IllegalStateException("File is unlocked - cannot use"); */ ParsedSectionSpec cer = ParsedSectionSpec.parseVariableSection(this, variableSection); if (cer.child == null) { return cer.v.read(cer.section); } if (spi == null) return IospHelper.readSection(cer); else // allow iosp to optimize return spi.readSection(cer); }
protected Array readData(ucar.nc2.Variable v, Section ranges) throws IOException, InvalidRangeException { long start = 0; if (showRequest) { log.info("Data request for variable: {} section {}...", v.getFullName(), ranges); start = System.currentTimeMillis(); } /* if (unlocked) { String info = cache.getInfo(this); throw new IllegalStateException("File is unlocked - cannot use\n" + info); } */ if (spi == null) { throw new IOException("spi is null, perhaps file has been closed. Trying to read variable " + v.getFullName()); } Array result = spi.readData(v, ranges); if (showRequest) { long took = System.currentTimeMillis() - start; log.info(" ...took= {} msecs", took); } return result; }
spi = (IOServiceProvider) iospClass.newInstance(); if (debugSPI) System.out.println("NetcdfFile uses iosp = " + spi.getClass().getName()); if (iospParam != null) spi.sendIospMessage(iospParam); this.spi.open(raf, this, cancelTask); finish(); spi.close(); } catch (Throwable t1) { spi.close(); } catch (Throwable t1) { spi.close(); } catch (Throwable t1) {
if (currentSpi.isValidFile(raf)) { Class c = currentSpi.getClass(); try { if (debugSPI) log.info(" try iosp = {}", registeredSpi.getClass().getName()); if (registeredSpi.isValidFile(raf)) { spi.sendIospMessage(iospMessage); spi.sendIospMessage(iospMessage);
/** * This can only be used for netcdf-3 files served over HTTP * * @param url HTTP URL location * @throws java.io.IOException if error * @deprecated use NetcdfFile.open( http:location) or NetcdfDataset.openFile( http:location) */ public NetcdfFile(URL url) throws IOException { this.location = url.toString(); ucar.unidata.io.RandomAccessFile raf = new ucar.unidata.io.http.HTTPRandomAccessFile(location); this.spi = SPFactory.getServiceProvider(); spi.open(raf, this, null); finish(); }
protected StructureDataIterator getStructureIterator(Structure s, int bufferSize) throws java.io.IOException { return spi.getStructureIterator(s, bufferSize); }
private static boolean canOpen(ucar.unidata.io.RandomAccessFile raf) throws IOException { if (N3header.isValidFile(raf)) { return true; } else { Iterator<IOServiceProvider> iterator = ServiceLoader.load(IOServiceProvider.class).iterator(); while(iterator.hasNext()) { if (iterator.next().isValidFile(raf)) { return true; } } for (IOServiceProvider registeredSpi : registeredProviders) { if (registeredSpi.isValidFile(raf)) return true; } } return false; }
public void getDetailInfo(Formatter f) { f.format("NetcdfFile location= %s%n", getLocation()); f.format(" title= %s%n", getTitle()); f.format(" id= %s%n", getId()); f.format(" fileType= %s%n", getFileTypeId()); f.format(" fileDesc= %s%n", getFileTypeDescription()); f.format(" class= %s%n", getClass().getName()); if (spi == null) { f.format(" has no IOSP%n"); } else { f.format(" iosp= %s%n%n", spi.getClass()); f.format("%s", spi.getDetailInfo()); } showCached(f); showProxies(f); }