Search in sources :

Example 1 with HDFParser

use of org.apache.tika.parser.hdf.HDFParser in project tika by apache.

the class HDFParserTest method testHDF4.

@Test
public void testHDF4() throws Exception {
    if (System.getProperty("java.version").startsWith("1.5")) {
        return;
    }
    Parser parser = new HDFParser();
    ContentHandler handler = new BodyContentHandler();
    Metadata metadata = new Metadata();
    /*
       * this is a publicly available HDF4 file from the HD4 examples:
       * 
       * http://www.hdfgroup.org/training/hdf4_chunking/Chunkit/bin/input54kmdata.hdf
       */
    try (InputStream stream = HDFParser.class.getResourceAsStream("/test-documents/test.hdf")) {
        parser.parse(stream, handler, metadata, new ParseContext());
    }
    assertNotNull(metadata);
    assertEquals("Direct read of HDF4 file through CDM library", metadata.get("_History"));
    assertEquals("Ascending", metadata.get("Pass"));
    assertEquals("Hierarchical Data Format, version 4", metadata.get("File-Type-Description"));
}
Also used : BodyContentHandler(org.apache.tika.sax.BodyContentHandler) InputStream(java.io.InputStream) Metadata(org.apache.tika.metadata.Metadata) ParseContext(org.apache.tika.parser.ParseContext) HDFParser(org.apache.tika.parser.hdf.HDFParser) BodyContentHandler(org.apache.tika.sax.BodyContentHandler) ContentHandler(org.xml.sax.ContentHandler) Parser(org.apache.tika.parser.Parser) HDFParser(org.apache.tika.parser.hdf.HDFParser) Test(org.junit.Test)

Example 2 with HDFParser

use of org.apache.tika.parser.hdf.HDFParser in project tika by apache.

the class HDFParserTest method testParseGlobalMetadata.

@Test
public void testParseGlobalMetadata() throws Exception {
    if (System.getProperty("java.version").startsWith("1.5")) {
        return;
    }
    Parser parser = new HDFParser();
    ContentHandler handler = new BodyContentHandler();
    Metadata metadata = new Metadata();
    /*
         * this is a publicly available HDF5 file from the MLS mission:
         * 
         * 
         * ftp://acdisc.gsfc.nasa.gov/data/s4pa///Aura_MLS_Level2/ML2O3.002//2009
         * /MLS-Aura_L2GP-O3_v02-23-c01_2009d122.he5
         */
    try (InputStream stream = HDFParser.class.getResourceAsStream("/test-documents/test.he5")) {
        parser.parse(stream, handler, metadata, new ParseContext());
    }
    assertNotNull(metadata);
    assertEquals("5", metadata.get("GranuleMonth"));
}
Also used : BodyContentHandler(org.apache.tika.sax.BodyContentHandler) InputStream(java.io.InputStream) Metadata(org.apache.tika.metadata.Metadata) ParseContext(org.apache.tika.parser.ParseContext) HDFParser(org.apache.tika.parser.hdf.HDFParser) BodyContentHandler(org.apache.tika.sax.BodyContentHandler) ContentHandler(org.xml.sax.ContentHandler) Parser(org.apache.tika.parser.Parser) HDFParser(org.apache.tika.parser.hdf.HDFParser) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)2 Metadata (org.apache.tika.metadata.Metadata)2 ParseContext (org.apache.tika.parser.ParseContext)2 Parser (org.apache.tika.parser.Parser)2 HDFParser (org.apache.tika.parser.hdf.HDFParser)2 BodyContentHandler (org.apache.tika.sax.BodyContentHandler)2 Test (org.junit.Test)2 ContentHandler (org.xml.sax.ContentHandler)2