summaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Makefile.am2
-rw-r--r--java/src/hdf/hdf5lib/H5.java25
-rw-r--r--java/src/jni/h5dImp.c105
-rw-r--r--java/src/jni/h5dImp.h9
-rw-r--r--java/src/jni/h5util.c422
-rw-r--r--java/src/jni/h5util.h2
6 files changed, 544 insertions, 21 deletions
diff --git a/java/src/Makefile.am b/java/src/Makefile.am
index 64eef0c..bd55c39 100644
--- a/java/src/Makefile.am
+++ b/java/src/Makefile.am
@@ -37,7 +37,7 @@ jarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar
hdf5_javadir = $(libdir)
pkgpath = hdf/hdf5lib
-CLASSPATH_ENV=CLASSPATH=.:$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$$CLASSPATH
+CLASSPATH_ENV=CLASSPATH=.:$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$$CLASSPATH
AM_JAVACFLAGS = $(H5_JAVACFLAGS) -deprecation
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java
index f826fbc..4060ca9 100644
--- a/java/src/hdf/hdf5lib/H5.java
+++ b/java/src/hdf/hdf5lib/H5.java
@@ -1752,14 +1752,8 @@ public class H5 implements java.io.Serializable {
(String[]) obj);
}
else if (is1D && (dataClass.getComponentType() == String.class)) {
- log.trace("H5Dread_string type");
- if (H5.H5Tis_variable_str(mem_type_id)) {
- status = H5Dread_VLStrings(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj);
- }
- else {
- status = H5Dread_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id,
- (String[]) obj);
- }
+ log.trace("H5DreadVL type");
+ status = H5DreadVL(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj);
}
else {
// Create a data buffer to hold the data into a Java Array
@@ -1979,7 +1973,7 @@ public class H5 implements java.io.Serializable {
Class dataClass = obj.getClass();
if (!dataClass.isArray()) {
- throw (new HDF5JavaException("H5Dread: data is not an array"));
+ throw (new HDF5JavaException("H5Dwrite: data is not an array"));
}
String cname = dataClass.getName();
@@ -2011,14 +2005,8 @@ public class H5 implements java.io.Serializable {
(double[]) obj, isCriticalPinning);
}
else if (is1D && (dataClass.getComponentType() == String.class)) {
- log.trace("H5Dwrite_string type");
- if (H5.H5Tis_variable_str(mem_type_id)) {
- status = H5Dwrite_VLStrings(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj);
- }
- else {
- status = H5Dwrite_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id,
- (String[]) obj);
- }
+ log.trace("H5DwriteVL type");
+ status = H5DwriteVL(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj);
}
else {
HDFArray theArray = new HDFArray(obj);
@@ -2084,6 +2072,9 @@ public class H5 implements java.io.Serializable {
public synchronized static native int H5Dwrite_string(long dataset_id, long mem_type_id, long mem_space_id,
long file_space_id, long xfer_plist_id, String[] buf) throws HDF5LibraryException, NullPointerException;
+ public synchronized static native int H5DwriteVL(long dataset_id, long mem_type_id, long mem_space_id,
+ long file_space_id, long xfer_plist_id, Object[] buf) throws HDF5LibraryException, NullPointerException;
+
/**
* H5Dwrite_VLStrings writes a (partial) variable length String dataset, specified by its identifier dataset_id, from
* the application memory buffer buf into the file.
diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c
index 1d7b823..6d4d8f1 100644
--- a/java/src/jni/h5dImp.c
+++ b/java/src/jni/h5dImp.c
@@ -56,6 +56,7 @@ extern jobject visit_callback;
static herr_t H5DreadVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DreadVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
+static herr_t H5DwriteVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
static herr_t H5DwriteVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf);
@@ -1194,7 +1195,7 @@ H5DreadVL_asstr
/* we will need to read n number of hvl_t structures */
rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
if (rdata == NULL) {
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read");
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buff for read");
} /* end if */
else {
status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata);
@@ -1202,7 +1203,7 @@ H5DreadVL_asstr
if (status < 0) {
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
HDfree(rdata);
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data");
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to read data");
} /* end if */
else {
/* calculate the largest size of all the hvl_t structures read */
@@ -1220,7 +1221,7 @@ H5DreadVL_asstr
if (h5str.s == NULL) {
H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata);
HDfree(rdata);
- h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buf");
+ h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buf");
} /* end if */
else {
H5T_class_t tclass = H5Tget_class(tid);
@@ -1329,6 +1330,104 @@ H5DreadVL_str
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5DwriteVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DwriteVL
+ (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id,
+ jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ htri_t isStr = 0;
+ htri_t isVlenStr = 0;
+ htri_t isComplex = 0;
+
+ if (buf == NULL) {
+ h5nullArgument(env, "H5DwriteVL: buf is NULL");
+ } /* end if */
+ else {
+ isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
+ if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
+ unsigned i;
+ int nm = H5Tget_nmembers(mem_type_id);
+ for(i = 0; i <nm; i++) {
+ hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
+ isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
+ H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
+ H5Tclose(nested_tid);
+ }
+ }
+ else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
+ isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */
+ }
+ if (isStr == 0 || isComplex>0 || isVlenStr) {
+ status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
+ (hid_t)mem_space_id, (hid_t)file_space_id,
+ (hid_t)xfer_plist_id, buf);
+ }
+ else if (isStr > 0) {
+ status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
+ (hid_t)mem_space_id, (hid_t)file_space_id,
+ (hid_t)xfer_plist_id, buf);
+ }
+ } /* end else */
+
+ return (jint)status;
+} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */
+
+herr_t
+H5DwriteVL_asstr
+ (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf)
+{
+ herr_t status = -1;
+ hvl_t *wdata;
+ jsize size;
+ jint i;
+ jint n;
+
+ /* Get size of string array */
+ n = ENVPTR->GetArrayLength(ENVPAR buf);
+ wdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
+
+ if (wdata == NULL) {
+ h5JNIFatalError(env, "H5DwriteVL_asstr: failed to allocate buff for write");
+ } /* end if */
+ else {
+ for (i = 0; i < n; ++i) {
+ jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i);
+ if (obj != 0) {
+ jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj);
+ const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0);
+
+ if (utf8) {
+ h5str_vlconvert(utf8, did, tid, wdata+i, 0);
+ } /* end if */
+
+ ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8);
+ ENVPTR->DeleteLocalRef(ENVPAR obj);
+ } /* end if */
+ } /* end for (i = 0; i < size; ++i) */
+
+ status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, wdata);
+
+ /* now free memory*/
+ for (i = 0; i < n; i++) {
+ if(wdata+i) {
+ HDfree(wdata+i);
+ } /* end if */
+ } /* end for */
+ HDfree(wdata);
+
+ if (status < 0)
+ h5libraryError(env);
+ } /* end else */
+
+ return status;
+} /* end H5DwriteVL_asstr */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Dwrite_VLStrings
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h
index 3cf24fe..1fe71a8 100644
--- a/java/src/jni/h5dImp.h
+++ b/java/src/jni/h5dImp.h
@@ -213,6 +213,15 @@ Java_hdf_hdf5lib_H5_H5DreadVL
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5DwriteVL
+ * Signature: (JJJJJ[Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_hdf_hdf5lib_H5_H5DwriteVL
+(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Dread_string
* Signature: (JJJJJ[Ljava/lang/String;)I
*/
diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c
index 385bfc7..7ca08cf 100644
--- a/java/src/jni/h5util.c
+++ b/java/src/jni/h5util.c
@@ -159,6 +159,428 @@ h5str_append
On error, a negative number is returned.
*/
size_t
+h5str_vlconvert
+ (char *str, hid_t container, hid_t tid, hvl_t *ptr, int expand_data)
+{
+ unsigned char tmp_uchar = 0;
+ char tmp_char = 0;
+ unsigned short tmp_ushort = 0;
+ short tmp_short = 0;
+ unsigned int tmp_uint = 0;
+ int tmp_int = 0;
+ unsigned long tmp_ulong = 0;
+ long tmp_long = 0;
+ unsigned long long tmp_ullong = 0;
+ long long tmp_llong = 0;
+ float tmp_float = 0.0;
+ double tmp_double = 0.0;
+ long double tmp_ldouble = 0.0;
+ static char fmt_llong[8], fmt_ullong[8];
+
+ hid_t mtid = -1;
+ size_t offset;
+ size_t nll;
+ char *this_str;
+ size_t this_strlen;
+ int n;
+ H5T_class_t tclass = H5Tget_class(tid);
+ size_t size = H5Tget_size(tid);
+ H5T_sign_t nsign = H5Tget_sign(tid);
+ int bdata_print = 0;
+
+ if (!str || !ptr)
+ return 0;
+
+ this_str = NULL;
+ this_strlen = 0;
+
+ switch (tclass) {
+ case H5T_COMPOUND:
+ {
+ unsigned i;
+ n = H5Tget_nmembers(tid);
+
+ /* remove compound indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == '{')
+ str++;
+
+ ptr->p = HDcalloc((size_t)1, size);
+ ptr->len = size;
+ for (i = 0; i < n; i++) {
+ offset = H5Tget_member_offset(tid, i);
+ mtid = H5Tget_member_type(tid, i);
+ str += offset;
+ h5str_convert(&str, container, mtid, ptr, 0, expand_data);
+ /* remove compound indicators */
+ if (str[0] == ',')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ H5Tclose(mtid);
+ }
+ /* remove compound indicators */
+ if (str[0] == '}')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ case H5T_ARRAY:
+ {
+ int rank = 0;
+ hsize_t i, dims[H5S_MAX_RANK], total_elmts;
+
+ /* remove array indicators */
+ if (str[0] == '[')
+ str++;
+ if (str[0] == ' ')
+ str++;
+
+ mtid = H5Tget_super(tid);
+ size = H5Tget_size(mtid);
+ rank = H5Tget_array_ndims(tid);
+
+ H5Tget_array_dims2(tid, dims);
+
+ total_elmts = 1;
+ for (i = 0; i < rank; i++)
+ total_elmts *= dims[i];
+
+ ptr->p = HDcalloc((size_t)total_elmts, size);
+ ptr->len = total_elmts;
+ h5str_convert(&str, container, mtid, ptr, 0, expand_data);
+ H5Tclose(mtid);
+ /* remove array indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == ']')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ default:
+ ptr->len = size;
+ ptr->p = HDcalloc(1, size);
+ this_strlen = h5str_convert(&str, container, tid, ptr, 0, expand_data);
+ break;
+ } /* end switch */
+
+ return this_strlen;
+} /* end h5str_vlconvert */
+
+/** print value of a data point into string.
+ Return Value:
+ On success, the total number of characters printed is returned.
+ On error, a negative number is returned.
+ */
+size_t
+h5str_convert
+ (char **str, hid_t container, hid_t tid, hvl_t *ptr, int ptroffset, int expand_data)
+{
+ unsigned char tmp_uchar = 0;
+ char tmp_char = 0;
+ unsigned short tmp_ushort = 0;
+ short tmp_short = 0;
+ unsigned int tmp_uint = 0;
+ int tmp_int = 0;
+ unsigned long tmp_ulong = 0;
+ long tmp_long = 0;
+ unsigned long long tmp_ullong = 0;
+ long long tmp_llong = 0;
+ float tmp_float = 0.0;
+ double tmp_double = 0.0;
+ long double tmp_ldouble = 0.0;
+ static char fmt_llong[8], fmt_ullong[8];
+ const char delimiter[] = " ,}]";
+
+ char *token;
+ hid_t mtid = -1;
+ size_t offset;
+ size_t nll;
+ char *this_str = *str;
+ size_t this_strlen;
+ int n;
+ char *cptr = (char*) ((ptr->p) + ptroffset);
+ unsigned char *ucptr = (unsigned char*) ((ptr->p) + ptroffset);
+ H5T_class_t tclass = H5Tget_class(tid);
+ size_t size = H5Tget_size(tid);
+ H5T_sign_t nsign = H5Tget_sign(tid);
+ int bdata_print = 0;
+
+ if (!str || !ptr)
+ return 0;
+
+ /* Build default formats for long long types */
+ if (!fmt_llong[0]) {
+ sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
+ sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
+ } /* end if */
+
+ this_strlen = HDstrlen(this_str);
+
+ switch (tclass) {
+ case H5T_FLOAT:
+ if (sizeof(float) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_float = 0;
+ sscanf(token, "%f", &tmp_float);
+ HDmemcpy(cptr, &tmp_float, sizeof(float));
+ }
+ else if (sizeof(double) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_double = 0;
+ sscanf(token, "%%lf", &tmp_double);
+ HDmemcpy(cptr, &tmp_double, sizeof(double));
+ }
+#if H5_SIZEOF_LONG_DOUBLE !=0
+ else if (sizeof(long double) == size) {
+ /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_ldouble = 0;
+ sscanf(token, "%Lf", &tmp_ldouble);
+ HDmemcpy(cptr, &tmp_ldouble, sizeof(long double));
+ }
+#endif
+ break;
+ case H5T_STRING:
+ {
+ if (this_strlen > 0) {
+ HDstrncpy(cptr, this_str, size);
+ }
+ else {
+ cptr = NULL;
+ }
+ }
+ break;
+ case H5T_INTEGER:
+ if (sizeof(char) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_uchar = 0;
+ sscanf(token, "%hu", &tmp_uchar);
+ HDmemcpy(cptr, &tmp_uchar, sizeof(unsigned char));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_char = 0;
+ sscanf(token, "%hd", &tmp_char);
+ HDmemcpy(cptr, &tmp_char, sizeof(char));
+ }
+ }
+ else if (sizeof(int) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_uint = 0;
+ sscanf(token, "%u", &tmp_uint);
+ HDmemcpy(cptr, &tmp_uint, sizeof(unsigned int));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_INT)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_int = 0;
+ sscanf(token, "%d", &tmp_int);
+ HDmemcpy(cptr, &tmp_int, sizeof(int));
+ }
+ }
+ else if (sizeof(short) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_ushort = 0;
+ sscanf(token, "%u", &tmp_ushort);
+ HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_short = 0;
+ sscanf(token, "%d", &tmp_short);
+ HDmemcpy(&tmp_short, cptr, sizeof(short));
+ }
+ }
+ else if (sizeof(long) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_ulong = 0;
+ sscanf(token, "%lu", &tmp_ulong);
+ HDmemcpy(cptr, &tmp_ulong, sizeof(unsigned long));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_long = 0;
+ sscanf(token, "%ld", &tmp_long);
+ HDmemcpy(cptr, &tmp_long, sizeof(long));
+ }
+ }
+ else if (sizeof(long long) == size) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_ullong = 0;
+ sscanf(token, fmt_ullong, &tmp_ullong);
+ HDmemcpy(cptr, &tmp_ullong, sizeof(unsigned long long));
+ }
+ else {
+ /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */
+ token = HDstrtok (this_str, delimiter);
+ tmp_llong = 0;
+ sscanf(token, fmt_llong, &tmp_llong);
+ HDmemcpy(cptr, &tmp_llong, sizeof(long long));
+ }
+ }
+ break;
+ case H5T_COMPOUND:
+ {
+ unsigned i;
+ n = H5Tget_nmembers(tid);
+ /* remove compound indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == '{')
+ str++;
+
+ for (i = 0; i < n; i++) {
+ offset = H5Tget_member_offset(tid, i);
+ mtid = H5Tget_member_type(tid, i);
+ h5str_convert(str, container, mtid, ptr, offset, expand_data);
+ /* remove compound indicators */
+ if (str[0] == ',')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ H5Tclose(mtid);
+ }
+ /* remove compound indicators */
+ if (str[0] == '}')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ case H5T_ENUM:
+ {
+ char enum_name[1024];
+ void *value;
+ if (sizeof(char) == size) {
+ tmp_uchar = 0;
+ value = &tmp_uchar;
+ }
+ else if (sizeof(short) == size) {
+ tmp_ushort = 0;
+ value = &tmp_ushort;
+ }
+ else if (sizeof(long) == size) {
+ tmp_ulong = 0;
+ value = &tmp_ulong;
+ }
+ else if (sizeof(long long) == size) {
+ tmp_ullong = 0;
+ value = &tmp_ullong;
+ }
+ else {
+ tmp_uint = 0;
+ value = &tmp_uint;
+ }
+ token = HDstrtok (this_str, delimiter);
+ H5Tenum_valueof(tid, token, value);
+ HDmemcpy(ucptr, value, size);
+ }
+ break;
+ case H5T_REFERENCE:
+ /* TODO handle reference writing */
+ cptr = NULL;
+ break;
+ case H5T_ARRAY:
+ {
+ int rank = 0;
+ hsize_t i, dims[H5S_MAX_RANK], total_elmts;
+ /* remove array indicators */
+ if (str[0] == '[')
+ str++;
+ if (str[0] == ' ')
+ str++;
+
+ mtid = H5Tget_super(tid);
+ offset = H5Tget_size(mtid);
+ rank = H5Tget_array_ndims(tid);
+
+ H5Tget_array_dims2(tid, dims);
+
+ total_elmts = 1;
+ for (i = 0; i < rank; i++)
+ total_elmts *= dims[i];
+
+ cptr = HDcalloc((size_t)total_elmts, offset);
+ for (i = 0; i < total_elmts; i++) {
+ h5str_convert(str, container, mtid, cptr + (i*offset), offset, expand_data);
+ /* remove array indicators */
+ if (str[0] == ',')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ H5Tclose(mtid);
+ /* remove array indicators */
+ if (str[0] == ' ')
+ str++;
+ if (str[0] == ']')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ break;
+ case H5T_VLEN:
+ {
+ unsigned int i;
+ mtid = H5Tget_super(tid);
+ offset = H5Tget_size(mtid);
+
+ /* remove vlen indicators */
+ if (str[0] == '{')
+ str++;
+ cptr = HDcalloc(offset, sizeof(hvl_t));
+ for (i = 0; (i*offset) < (int)size; i++) {
+ h5str_sprintf(str, container, mtid, cptr + (i*offset), offset, expand_data);
+ /* remove vlen indicators */
+ if (str[0] == ',')
+ str++;
+ if (str[0] == ' ')
+ str++;
+ }
+ H5Tclose(mtid);
+ /* remove vlen indicators */
+ if (str[0] == '}')
+ str++;
+ }
+ break;
+
+ default:
+ {
+ /* All other types get copied raw */
+ HDmemcpy(ucptr, this_str, size);
+ }
+ break;
+ } /* end switch */
+
+ return this_strlen;
+} /* end h5str_convert */
+
+/** print value of a vlen data point into string.
+ Return Value:
+ On success, the total number of characters printed is returned.
+ On error, a negative number is returned.
+ */
+size_t
h5str_vlsprintf
(h5str_t *str, hid_t container, hid_t tid, hvl_t *ptr, int expand_data)
{
diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h
index c6b41d2..23bc424 100644
--- a/java/src/jni/h5util.h
+++ b/java/src/jni/h5util.h
@@ -41,6 +41,8 @@ extern void h5str_resize (h5str_t *str, size_t new_len);
extern char* h5str_append (h5str_t *str, const char* cstr);
extern size_t h5str_vlsprintf(h5str_t *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data);
extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int ptrlen, int expand_data);
+extern size_t h5str_vlsconvert(char *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data);
+extern size_t h5str_convert(char **str, hid_t container, hid_t tid, hvl_t *buf, int ptroffset, int expand_data);
extern void h5str_array_free(char **strs, size_t len);
extern int h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order);
extern int h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_obj);