@Test public void testParseGlobalMetadata() throws Exception { try (InputStream stream = EnviHeaderParser.class.getResourceAsStream( "/test-documents/envi_test_header.hdr")) { assertNotNull("Test ENVI file 'envi_test_header.hdr' not found", stream); parser.parse(stream, handler, metadata, new ParseContext()); } String content = handler.toString(); assertContains("<body><p>ENVI</p>", content); assertContains("<p>samples = 2400</p>", content); assertContains("<p>lines = 2400</p>", content); assertContains("<p>map info = {Sinusoidal, 1.5000, 1.5000, -10007091.3643, 5559289.2856, 4.6331271653e+02, 4.6331271653e+02, , units=Meters}</p>", content); assertContains("content=\"application/envi.hdr\"", content); assertContains("projection info = {16, 6371007.2, 0.000000, 0.0, 0.0, Sinusoidal, units=Meters}", content); }
@Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, ENVI_MIME_TYPE); TikaConfig tikaConfig = context.get(TikaConfig.class); if (tikaConfig == null) { tikaConfig = TikaConfig.getDefaultConfig(); } try (AutoDetectReader reader = new AutoDetectReader( new CloseShieldInputStream(stream), metadata, getEncodingDetector(context))){ Charset charset = reader.getCharset(); metadata.set(Metadata.CONTENT_ENCODING, charset.name()); xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); readLines(reader, metadata); xhtml.endDocument(); } catch (IOException | TikaException e) { LOG.error("Error reading input data stream.", e); } }
EnviHeaderParser extends AbstractEncodingDetectorParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, ENVI_MIME_TYPE); TikaConfig tikaConfig = context.get(TikaConfig.class); if (tikaConfig == null) { tikaConfig = TikaConfig.getDefaultConfig(); } try (AutoDetectReader reader = new AutoDetectReader( new CloseShieldInputStream(stream), metadata, getEncodingDetector(context))){ Charset charset = reader.getCharset(); metadata.set(Metadata.CONTENT_ENCODING, charset.name()); xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); readLines(reader, metadata); xhtml.endDocument(); } catch (IOException | TikaException e) { LOG.error("Error reading input data stream.", e); } } }
EnviHeaderParser extends AbstractEncodingDetectorParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, ENVI_MIME_TYPE); TikaConfig tikaConfig = context.get(TikaConfig.class); if (tikaConfig == null) { tikaConfig = TikaConfig.getDefaultConfig(); } try (AutoDetectReader reader = new AutoDetectReader( new CloseShieldInputStream(stream), metadata, getEncodingDetector(context))){ Charset charset = reader.getCharset(); metadata.set(Metadata.CONTENT_ENCODING, charset.name()); xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); readLines(reader, metadata); xhtml.endDocument(); } catch (IOException | TikaException e) { LOG.error("Error reading input data stream.", e); } } EnviHeaderParser();  EnviHeaderParser(EncodingDetector encodingDetector); }
EnviHeaderParser extends AbstractEncodingDetectorParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, ENVI_MIME_TYPE); TikaConfig tikaConfig = context.get(TikaConfig.class); if (tikaConfig == null) { tikaConfig = TikaConfig.getDefaultConfig(); } try (AutoDetectReader reader = new AutoDetectReader( new CloseShieldInputStream(stream), metadata, getEncodingDetector(context))){ Charset charset = reader.getCharset(); metadata.set(Metadata.CONTENT_ENCODING, charset.name()); xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); readLines(reader, metadata); xhtml.endDocument(); } catch (IOException | TikaException e) { LOG.error("Error reading input data stream.", e); } } EnviHeaderParser();  EnviHeaderParser(EncodingDetector encodingDetector); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); }
EnviHeaderParser extends AbstractEncodingDetectorParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { metadata.set(Metadata.CONTENT_TYPE, ENVI_MIME_TYPE); TikaConfig tikaConfig = context.get(TikaConfig.class); if (tikaConfig == null) { tikaConfig = TikaConfig.getDefaultConfig(); } try (AutoDetectReader reader = new AutoDetectReader( new CloseShieldInputStream(stream), metadata, getEncodingDetector(context))){ Charset charset = reader.getCharset(); metadata.set(Metadata.CONTENT_ENCODING, charset.name()); xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); readLines(reader, metadata); xhtml.endDocument(); } catch (IOException | TikaException e) { LOG.error("Error reading input data stream.", e); } } EnviHeaderParser();  EnviHeaderParser(EncodingDetector encodingDetector); @Override Set<MediaType> getSupportedTypes(ParseContext context); @Override void parse(InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); static final String ENVI_MIME_TYPE; }