diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 37 | ||||
-rw-r--r-- | java/src/jni/h5util.c | 68 | ||||
-rw-r--r-- | java/src/jni/h5util.h | 8 |
3 files changed, 108 insertions, 5 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index 443fb25..c2af7b6 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -534,6 +534,33 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException; /** + * H5export_dataset is a utility function to save data in a file. + * + * @param file_export_name + * The file name to export data into. + * @param file_name + * The name of the HDF5 file containing the dataset. + * @param object_path + * The full path of the dataset to be exported. + * @param binary_order + * 99 - export data as text. + * 1 - export data as binary Native Order. + * 2 - export data as binary Little Endian. + * 3 - export data as binary Big Endian. + * + * @exception HDF5LibraryException + * Error from the HDF-5 Library. + **/ + public static void H5export_dataset(String file_export_name, String file_name, String object_path, + int binary_order) throws HDF5LibraryException + { + _H5export_dataset_string(file_export_name, file_name, object_path, binary_order); + } + private synchronized static native void _H5export_dataset_string(String file_export_name, String file_name, + String object_path, int binary_order) + throws HDF5LibraryException; + + /** * H5export_attribute is a utility function to save data in a file. * * @param file_export_name @@ -5303,7 +5330,7 @@ public class H5 implements java.io.Serializable { String n[] = new String[1]; n[0] = new String(""); oname[0] = H5Lget_name_by_idx(loc_id, name, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_INC, - idx, HDF5Constants.H5P_DEFAULT); + idx, HDF5Constants.H5P_DEFAULT); H5L_info_t info = H5Lget_info_by_idx(loc_id, name, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_INC, idx, HDF5Constants.H5P_DEFAULT); type[0] = info.type; @@ -11790,8 +11817,8 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * Error from the HDF-5 Library. **/ - public synchronized static native long H5Sselect_project_intersection(long src_space_id, long dst_space_id, - long src_intersect_space_id) + public synchronized static native long + H5Sselect_project_intersection(long src_space_id, long dst_space_id, long src_intersect_space_id) throws HDF5LibraryException; // //////////////////////////////////////////////////////////// @@ -12633,8 +12660,8 @@ public class H5 implements java.io.Serializable { /** * If any internal bits of a floating point type are unused (that is, those significant bits which are not - * part of the sign, exponent, or mantissa), then H5Tset_inpad will be filled according to the value of the - * padding value property inpad. + * part of the sign, exponent, or mantissa), then H5Tset_inpad will be filled according to the value of + * the padding value property inpad. * * @param type_id * IN: Identifier of datatype to modify. diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index b684d05..4568880 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -3512,6 +3512,74 @@ done: /* * Class: hdf_hdf5lib_H5 + * Method: _H5export_dataset_string + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5__1H5export_1dataset_1string(JNIEnv *env, jclass clss, jstring file_export_name, + jstring file_name, jstring object_path, jint binary_order) +{ + const char *file_export = NULL; + const char *fileName = NULL; + const char *object_name = NULL; + jboolean isCopy; + herr_t ret_val = FAIL; + hid_t file_id = H5I_INVALID_HID; + hid_t dataset_id = H5I_INVALID_HID; + FILE * stream = NULL; + + UNUSED(clss); + + if (NULL == file_export_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_export_name is NULL"); + + if (NULL == file_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_name is NULL"); + + if (NULL == object_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: object_path is NULL"); + + PIN_JAVA_STRING(ENVONLY, file_name, fileName, NULL, "H5export_dataset: file name not pinned"); + + if ((file_id = H5Fopen(fileName, (unsigned)H5F_ACC_RDWR, (hid_t)H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_JAVA_STRING(ENVONLY, object_path, object_name, &isCopy, "H5export_dataset: object_path not pinned"); + + if ((dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_JAVA_STRING(ENVONLY, file_export_name, file_export, NULL, + "H5export_dataset: file_export name not pinned"); + + if (NULL == (stream = HDfopen(file_export, "w+"))) + H5_JNI_FATAL_ERROR(ENVONLY, "HDfopen failed"); + + if ((ret_val = h5str_dump_simple_dset(ENVONLY, stream, dataset_id, binary_order)) < 0) + H5_ASSERTION_ERROR(ENVONLY, "h5str_dump_simple_dset failed"); + + if (stream) { + HDfclose(stream); + stream = NULL; + } + +done: + if (stream) + HDfclose(stream); + if (file_export) + UNPIN_JAVA_STRING(ENVONLY, file_export_name, file_export); + if (object_name) + UNPIN_JAVA_STRING(ENVONLY, object_path, object_name); + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, file_name, fileName); + if (dataset_id >= 0) + H5Dclose(dataset_id); + if (file_id >= 0) + H5Fclose(file_id); +} /* end Java_hdf_hdf5lib_H5_H5export_1dataset */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5export_attribute * Signature: (Ljava/lang/String;JLjava/lang/String;I)V */ diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index 33f1ea7..b7f12bd 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -111,6 +111,14 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5export_1dataset(JNIEnv *, jclass, j /* * Class: hdf_hdf5lib_H5 + * Method: _H5export_dataset_string + * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5__1H5export_1dataset_1string(JNIEnv *, jclass, jstring, jstring, + jstring, jint); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5export_attribute * Signature: (Ljava/lang/String;JLjava/lang/String;I)V */ |