throws IOException, DataStoreException ensureInitialized(true);
@Override protected void classpathChanged() { reset(); } });
/** * Creates a new netCDF store from the given file, URL, stream or {@link ucar.nc2.NetcdfFile} object. * This constructor invokes {@link StorageConnector#closeAllExcept(Object)}, keeping open only the * needed resource. * * @param provider the factory that created this {@code DataStore} instance, or {@code null} if unspecified. * @param connector information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, <i>etc</i>). * @throws DataStoreException if an error occurred while opening the netCDF file. * * @since 0.8 */ public NetcdfStore(final NetcdfStoreProvider provider, final StorageConnector connector) throws DataStoreException { super(provider, connector); location = connector.getStorageAs(URI.class); try { decoder = NetcdfStoreProvider.decoder(listeners, connector); } catch (IOException e) { throw new DataStoreException(e); } if (decoder == null) { throw new UnsupportedStorageException(super.getLocale(), NetcdfStoreProvider.NAME, connector.getStorage(), connector.getOption(OptionKey.OPEN_OPTIONS)); } }
/** * Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for a UCAR {@link NetcdfFile} object. * * @throws IOException if an error occurred while opening the netCDF file. * @throws DataStoreException if a logical error occurred. */ @Test public void testProbeContentFromUCAR() throws IOException, DataStoreException { try (NetcdfFile file = createUCAR(TestData.NETCDF_2D_GEOGRAPHIC)) { final StorageConnector c = new StorageConnector(file); final NetcdfStoreProvider provider = new NetcdfStoreProvider(); final ProbeResult probe = provider.probeContent(c); assertTrue ("isSupported", probe.isSupported()); assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType()); assertNull ("getVersion", probe.getVersion()); } }
final String path = connector.getStorageAs(String.class); if (path != null) try { decoder = createByReflection(path, false, geomlib, listeners); keepOpen = path; } catch (IOException | DataStoreException s) { } else { keepOpen = connector.getStorage(); decoder = createByReflection(keepOpen, true, geomlib, listeners);
final Path path = connector.getStorageAs(Path.class); try { decoder = NetcdfStoreProvider.decoder(listeners, connector); } catch (IOException | ArithmeticException e) { throw new DataStoreException(e);
/** * Tests {@link NetcdfStoreProvider#probeContent(StorageConnector)} for an input stream which shall * be recognized as a classic netCDF file. * * @throws DataStoreException if a logical error occurred. */ @Test public void testProbeContentFromStream() throws DataStoreException { final StorageConnector c = new StorageConnector(TestData.NETCDF_2D_GEOGRAPHIC.location()); final NetcdfStoreProvider provider = new NetcdfStoreProvider(); final ProbeResult probe = provider.probeContent(c); assertTrue ("isSupported", probe.isSupported()); assertEquals("getMimeType", NetcdfStoreProvider.MIME_TYPE, probe.getMimeType()); assertEquals("getVersion", new Version("1"), probe.getVersion()); c.closeAllExcept(null); }
final String path = connector.getStorageAs(String.class); if (path != null) try { decoder = createByReflection(path, false, geomlib, listeners); keepOpen = path; } catch (IOException | DataStoreException s) { } else { keepOpen = connector.getStorage(); decoder = createByReflection(keepOpen, true, geomlib, listeners);
/** * Tests {@link NetcdfStoreProvider#decoder(WarningListeners, StorageConnector)} for an input stream which * shall be recognized as a classic netCDF file. The provider shall instantiate a {@link ChannelDecoder}. * * @throws IOException if an error occurred while opening the netCDF file. * @throws DataStoreException if a logical error occurred. */ @Test public void testDecoderFromStream() throws IOException, DataStoreException { final StorageConnector c = new StorageConnector(TestData.NETCDF_2D_GEOGRAPHIC.open()); try (Decoder decoder = NetcdfStoreProvider.decoder(LISTENERS, c)) { assertInstanceOf("decoder", ChannelDecoder.class, decoder); } }
@Override protected void classpathChanged() { reset(); } });
throws IOException, DataStoreException ensureInitialized(true);
/** * Tests {@link NetcdfStoreProvider#decoder(WarningListeners, StorageConnector)} for a UCAR * {@link NetcdfFile} object. The provider shall instantiate a {@link DecoderWrapper}. * * @throws IOException if an error occurred while opening the netCDF file. * @throws DataStoreException if a logical error occurred. */ @Test public void testDecoderFromUCAR() throws IOException, DataStoreException { final StorageConnector c = new StorageConnector(createUCAR(TestData.NETCDF_2D_GEOGRAPHIC)); try (Decoder decoder = NetcdfStoreProvider.decoder(LISTENERS, c)) { assertInstanceOf("decoder", DecoderWrapper.class, decoder); } } }
reset(); netcdfFileClass = Void.TYPE;
final String path = connector.getStorageAs(String.class); if (path != null) { ensureInitialized(false); final Method method = canOpenFromPath; if (method != null) try {
reset(); netcdfFileClass = Void.TYPE;
final String path = connector.getStorageAs(String.class); if (path != null) { ensureInitialized(false); final Method method = canOpenFromPath; if (method != null) try {