240 likes | 263 Views
Learn about HDF-Java products, including Viewer, Editor, and Wrapper, at the HDF and HDF-EOS Workshop XII. Explore the pros and cons of using the pure Java library versus the Java Native Interface (JNI) for HDF file manipulation. Find out how to read datasets using the HDF-Java Java Wrapper. Discover the different levels of objects in the HDF4 and HDF5 implementations. Get an overview of HDFView and its GUI components. This report is based on work supported by NASA.
E N D
HDF-Java Products Peter Cao The HDF Group HDF and HDF-EOS Workshop XII October 15, 2008 HDF and HDF-EOS Workshop XII
What are the HDF-Java products? HDF-Java HDF Java Wrapper Object Package Viewer Editor HDF and HDF-EOS Workshop XII
Java Wrapper HDF HDF and HDF-EOS Workshop XII
Java Wrapper Pure Java Library HDF Java Native Interface a programming framework that allows Java code to call and be called by applications and libraries written in other languages HDF HDF and HDF-EOS Workshop XII
Pure Java Library • Pros: • True platform independence • Direct access to file (no data conversion between C and Java) Pure Java Library • Cons: • Substantial amount of work to implement • Hard to maintain (new features or format changes) HDF HDF and HDF-EOS Workshop XII
HDF JNI • Pros: • Easy to implement • Easy to maintain HDF Java Native Interface • Cons: • Requires data conversion between C and Java • HDF JNI is platform dependent HDF HDF and HDF-EOS Workshop XII
Java Wrapper HDF Java Native Interface libjhdf.so (or dll) libjhdf5.so (or dll) HDFLibrary.java H5.java HDF4 library HDF5 library HDF and HDF-EOS Workshop XII
Java Wrapper: C versus Java hid_t H5Fcreate ( const char *name, unsigned flags, hid_t create_id, hid_t access_id ); hid_t H5Fopen ( const char *name, unsigned flags, hid_t access_id ); herr_t H5Fclose ( hid_t file_id ); • public static native int H5Fcreate ( • String name, • int flags, • int create_id, • int access_id); • public static native int H5Fopen ( • String name, • int flags, • int access_id); • public static native int H5Fclose ( • int file_id); C Java HDF and HDF-EOS Workshop XII
Object Package HDF-Java HDF Java Wrapper Object Package Viewer Editor HDF and HDF-EOS Workshop XII
Java Wrapper: simple dataset read int fid, did, sid, tid, rank; long dims[], maxDims[]; Object theData; fid = H5.H5Fopen( fname, HDF5Constants.H5F_ACC_RDWR, HDF5Constants.H5P_DEFAULT); did = H5.H5Dopen(fid, dname); sid = H5.H5Dget_space(did); tid = H5.H5Dget_type(did); rank = H5.H5Sget_simple_extent_ndims(sid); dims = new long[rank]; maxDims = new long[rank]; H5.H5Sget_simple_extent_dims(sid, dims, maxDims); theData = allocateArray(tid, dims); H5.H5Dread( did, tid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, theData); H5.H5Sclose(sid); H5.H5Tclose(tid); H5.H5Dclose(did); H5.H5Fclose(fid); HDF and HDF-EOS Workshop XII
Object Package: the easy way theData = Dataset.read(); HDF and HDF-EOS Workshop XII
Object Package: main purposes • Simplifies access to HDF files • Separates applications from libraries • Modular design • Client server model • Makes testing and maintenance easy HDF and HDF-EOS Workshop XII
Object Package: levels of objects Common Objects ncsa.hdf.object jhdfobj.jar Abstract classes HDF5 ncsa.hdf.object.h5 jhdf5obj.jar HDF4 ncsa.hdf.object.h4 jhdf4obj.jar Implementation HDF and HDF-EOS Workshop XII
Object Package: abstract classes FileFormat HObject Dataset Group ScalarDS CompoundDS October 15-17, 2008 HDF and HDF-EOS Workshop XII 14
Object Package: HDF4 implementation ScalarDS CompounDS Group H4Vdata H4Group H4SDS H4GRImage H4File FileFormat October 15-17, 2008 HDF and HDF-EOS Workshop XII 15
Object Package: HDF5 implementation ScalarDS CompounDS Group H5Group H5ScalarDS H5CompoundDS H5File FileFormat October 15-17, 2008 HDF and HDF-EOS Workshop XII 16
Object Package: file create import ncsa.hdf.object.*; public class H5FileCreate { private static String fname = "H5FileCreate.h5"; public static void main( String args[] ) throws Exception { FileFormat fileFormat = FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5); fileFormat.createFile(fname, FileFormat.FILE_CREATE); } } HDF and HDF-EOS Workshop XII
HDFView HDF-Java HDF Java Wrapper Object Package Viewer Editor HDF and HDF-EOS Workshop XII
HDFView: basic components HDF and HDF-EOS Workshop XII
HDFView: GUI components HDFView (GUI) MetaDataView TreeView UserImp UserImp TableView TextView ImageView UserImp UserImp UserImp HDF and HDF-EOS Workshop XII
HDFView: all together HDF and HDF-EOS Workshop XII
What are the HDF-Java products? HDF-Java HDF Java Wrapper Object Package Viewer Editor HDF and HDF-EOS Workshop XII
Thank You! This report is based upon work supported in part by a Cooperative Agreement with the National Aeronautics and Space Administration (NASA) under NASA Awards NNX06AC83A and NNX08AO77A. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Aeronautics and Space Administration. HDF and HDF-EOS Workshop XII
Questions/comments? HDF and HDF-EOS Workshop XII