/** * Returns the MIME type of the storage file format, or {@code null} if unknown or not applicable. * * @param storage the input/output object as a URL, file, image input stream, <i>etc.</i>. * @return the storage MIME type, or {@code null} if unknown or not applicable. * @throws DataStoreException if an error occurred while opening the storage. */ public String probeContentType(final Object storage) throws DataStoreException { ArgumentChecks.ensureNonNull("storage", storage); final ProbeProviderPair p = lookup(storage, false); return (p != null) ? p.probe.getMimeType() : null; }
/** * Returns the MIME type of the storage file format, or {@code null} if unknown or not applicable. * * @param storage the input/output object as a URL, file, image input stream, <i>etc.</i>. * @return the storage MIME type, or {@code null} if unknown or not applicable. * @throws DataStoreException if an error occurred while opening the storage. */ public String probeContentType(final Object storage) throws DataStoreException { ArgumentChecks.ensureNonNull("storage", storage); final ProbeProviderPair p = lookup(storage, false); return (p != null) ? p.probe.getMimeType() : null; }
/** * Tests {@link StoreProvider#probeContent(StorageConnector)} method from a {@link java.io.Reader} object. * * @throws DataStoreException if en error occurred while reading the XML. */ @Test public void testProbeContentFromReader() throws DataStoreException { final StoreProvider p = new StoreProvider(); final StorageConnector c = new StorageConnector(new StringReader(StoreTest.XML)); final ProbeResult r = p.probeContent(c); c.closeAllExcept(null); assertTrue ("isSupported", r.isSupported()); assertEquals("mimeType", "application/vnd.iso.19139+xml", r.getMimeType()); } }
/** * Implementation of {@link #testProbeContentFromReader()}. */ private static void testProbeContentFromReader(final boolean isSupported, final int version, final StoreProvider p, final String wkt) throws DataStoreException { final StorageConnector c = new StorageConnector(new StringReader(wkt)); final ProbeResult r = p.probeContent(c); c.closeAllExcept(null); assertEquals("isSupported", isSupported, r.isSupported()); if (isSupported) { assertEquals("mimeType", "application/wkt", r.getMimeType()); assertEquals("version", version, r.getVersion().getMajor()); } } }
/** * 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()); } }
/** * 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); }