@Test public void testParseBasicInfo() { assumeTrue(canRun()); final String expectedDriver = "netCDF/Network Common Data Format"; final String expectedUpperRight = "512.0, 0.0"; final String expectedUpperLeft = "0.0, 0.0"; final String expectedLowerLeft = "0.0, 512.0"; final String expectedLowerRight = "512.0, 512.0"; final String expectedCoordinateSystem = "`'"; final String expectedSize = "512, 512"; GDALParser parser = new GDALParser(); InputStream stream = TestGDALParser.class .getResourceAsStream("/test-documents/sresa1b_ncar_ccsm3_0_run1_200001.nc"); Metadata met = new Metadata(); BodyContentHandler handler = new BodyContentHandler(); try { parser.parse(stream, handler, met, new ParseContext()); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } assertNotNull(met); assertNotNull(met.get("Driver")); assertEquals(expectedDriver, met.get("Driver")); assumeTrue(met.get("Files") != null); assertNotNull(met.get("Coordinate System")); assertEquals(expectedCoordinateSystem, met.get("Coordinate System")); assertNotNull(met.get("Size")); assertEquals(expectedSize, met.get("Size")); assertNotNull(met.get("Upper Right")); assertEquals(expectedUpperRight, met.get("Upper Right")); assertNotNull(met.get("Upper Left")); assertEquals(expectedUpperLeft, met.get("Upper Left")); assertNotNull(met.get("Upper Right")); assertEquals(expectedLowerRight, met.get("Lower Right")); assertNotNull(met.get("Upper Right")); assertEquals(expectedLowerLeft, met.get("Lower Left")); }
@Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); void setCommand(String command); String getCommand(); String processCommand(InputStream stream); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
                      Metadata metadata, ParseContext context); }
GDALParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { if (!ExternalParser.check("gdalinfo")) { return; } TemporaryResources tmp = new TemporaryResources(); TikaInputStream tis = TikaInputStream.get(stream, tmp); String runCommand = processCommand(tis); String output = execCommand(new String[]{runCommand}); extractMetFromOutput(output, metadata); applyPatternsToOutput(output, metadata, getPatterns()); processOutput(handler, metadata, output); } GDALParser(); void setCommand(String command); String getCommand(); String processCommand(InputStream stream); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
                      Metadata metadata, ParseContext context);  }