diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-01-16 21:29:34 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-01-16 21:29:34 (GMT) |
commit | a92c735c9b57049e8c4037d3490f7e10f8eef4d6 (patch) | |
tree | 74da25151de6d1e32329dfcd62e17c863e2e3de1 /java/examples | |
parent | 024f7ba09250110c19b070c9699cfbc0f9dc2b96 (diff) | |
download | hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.zip hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.tar.gz hdf5-a92c735c9b57049e8c4037d3490f7e10f8eef4d6.tar.bz2 |
Squashed commit of the token_refactoring branch:
Diffstat (limited to 'java/examples')
-rw-r--r-- | java/examples/groups/H5Ex_G_Intermediate.java | 14 | ||||
-rw-r--r-- | java/examples/groups/H5Ex_G_Iterate.java | 5 | ||||
-rw-r--r-- | java/examples/groups/H5Ex_G_Traverse.java | 32 | ||||
-rw-r--r-- | java/examples/groups/H5Ex_G_Visit.java | 28 |
4 files changed, 40 insertions, 39 deletions
diff --git a/java/examples/groups/H5Ex_G_Intermediate.java b/java/examples/groups/H5Ex_G_Intermediate.java index f7d5a50..e97e5f8 100644 --- a/java/examples/groups/H5Ex_G_Intermediate.java +++ b/java/examples/groups/H5Ex_G_Intermediate.java @@ -19,8 +19,8 @@ package examples.groups; import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; -import hdf.hdf5lib.callbacks.H5O_iterate_cb; import hdf.hdf5lib.callbacks.H5O_iterate_t; +import hdf.hdf5lib.callbacks.H5O_iterate_opdata_t; import hdf.hdf5lib.structs.H5O_info_t; import java.util.ArrayList; @@ -53,9 +53,9 @@ public class H5Ex_G_Intermediate { // Print all the objects in the file_ids to show that intermediate group_ids have been created. System.out.println("Objects in the file_id:"); - // H5O_iterate_t iter_data = null; - H5O_iterate_t iter_data = new H5O_iter_data(); - H5O_iterate_cb iter_cb = new H5O_iter_callback(); + // H5O_iterate_opdata_t iter_data = null; + H5O_iterate_opdata_t iter_data = new H5O_iter_data(); + H5O_iterate_t iter_cb = new H5O_iter_callback(); H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data); } @@ -92,12 +92,12 @@ public class H5Ex_G_Intermediate { } } - private class H5O_iter_data implements H5O_iterate_t { + private class H5O_iter_data implements H5O_iterate_opdata_t { public ArrayList<idata> iterdata = new ArrayList<idata>(); } - private class H5O_iter_callback implements H5O_iterate_cb { - public int callback(long group, String name, H5O_info_t info, H5O_iterate_t op_data) { + private class H5O_iter_callback implements H5O_iterate_t { + public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data) { idata id = new idata(name, info.type); ((H5O_iter_data) op_data).iterdata.add(id); diff --git a/java/examples/groups/H5Ex_G_Iterate.java b/java/examples/groups/H5Ex_G_Iterate.java index 3c9ca82..5acbf65 100644 --- a/java/examples/groups/H5Ex_G_Iterate.java +++ b/java/examples/groups/H5Ex_G_Iterate.java @@ -19,6 +19,7 @@ package examples.groups; import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.structs.H5O_token_t; import java.util.EnumSet; import java.util.HashMap; @@ -75,8 +76,8 @@ public class H5Ex_G_Iterate { String[] oname = new String[count]; int[] otype = new int[count]; int[] ltype = new int[count]; - long[] orefs = new long[count]; - H5.H5Gget_obj_info_all(file_id, DATASETNAME, oname, otype, ltype, orefs, HDF5Constants.H5_INDEX_NAME); + H5O_token_t[] otokens = new H5O_token_t[count]; + H5.H5Gget_obj_info_all(file_id, DATASETNAME, oname, otype, ltype, otokens, HDF5Constants.H5_INDEX_NAME); // Get type of the object and display its name and type. for (int indx = 0; indx < otype.length; indx++) { diff --git a/java/examples/groups/H5Ex_G_Traverse.java b/java/examples/groups/H5Ex_G_Traverse.java index 2a2cba3..6225a9e 100644 --- a/java/examples/groups/H5Ex_G_Traverse.java +++ b/java/examples/groups/H5Ex_G_Traverse.java @@ -25,22 +25,22 @@ package examples.groups; import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; -import hdf.hdf5lib.callbacks.H5L_iterate_cb; import hdf.hdf5lib.callbacks.H5L_iterate_t; +import hdf.hdf5lib.callbacks.H5L_iterate_opdata_t; import hdf.hdf5lib.structs.H5L_info_t; import hdf.hdf5lib.structs.H5O_info_t; import examples.groups.H5Ex_G_Iterate.H5O_type; -class opdata implements H5L_iterate_t { +class opdata implements H5L_iterate_opdata_t { int recurs; opdata prev; - long addr; + H5O_token_t obj_token; } public class H5Ex_G_Traverse { private static String FILE = "h5ex_g_traverse.h5"; - public static H5L_iterate_cb iter_cb = new H5L_iter_callbackT(); + public static H5L_iterate_t iter_cb = new H5L_iter_callbackT(); private static void OpenGroup() { long file_id = -1; @@ -54,7 +54,7 @@ public class H5Ex_G_Traverse { infobuf = H5.H5Oget_info(file_id); od.recurs = 0; od.prev = null; - od.addr = infobuf.addr; + od.obj_token = infobuf.token; } } catch (Exception e) { @@ -64,7 +64,7 @@ public class H5Ex_G_Traverse { // Print the root group and formatting, begin iteration. try { System.out.println("/ {"); - // H5L_iterate_cb iter_cb = new H5L_iter_callbackT(); + // H5L_iterate_t iter_cb = new H5L_iter_callbackT(); H5.H5Literate(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb, od); System.out.println("}"); } @@ -87,8 +87,8 @@ public class H5Ex_G_Traverse { } } -class H5L_iter_callbackT implements H5L_iterate_cb { - public int callback(long group, String name, H5L_info_t info, H5L_iterate_t op_data) { +class H5L_iter_callbackT implements H5L_iterate_t { + public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data) { H5O_info_t infobuf; int return_val = 0; @@ -105,7 +105,7 @@ class H5L_iter_callbackT implements H5L_iterate_cb { switch (H5O_type.get(infobuf.type)) { case H5O_TYPE_GROUP: System.out.println("Group: " + name + " { "); - // Check group address against linked list of operator + // Check group object token against linked list of operator // data structures. We will always run the check, as the // reference count cannot be relied upon if there are // symbolic links, and H5Oget_info_by_name always follows @@ -114,7 +114,7 @@ class H5L_iter_callbackT implements H5L_iterate_cb { // links, however it could still fail if an object's // reference count was manually manipulated with // H5Odecr_refcount. - if (group_check(od, infobuf.addr)) { + if (group_check(od, infobuf.token)) { for (int i = 0; i < spaces; i++) System.out.print(" "); System.out.println(" Warning: Loop detected!"); @@ -127,8 +127,8 @@ class H5L_iter_callbackT implements H5L_iterate_cb { opdata nextod = new opdata(); nextod.recurs = od.recurs + 1; nextod.prev = od; - nextod.addr = infobuf.addr; - H5L_iterate_cb iter_cb2 = new H5L_iter_callbackT(); + nextod.obj_token = infobuf.token; + H5L_iterate_t iter_cb2 = new H5L_iter_callbackT(); return_val = H5.H5Literate_by_name(group, name, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, 0L, iter_cb2, nextod, HDF5Constants.H5P_DEFAULT); } @@ -153,13 +153,13 @@ class H5L_iter_callbackT implements H5L_iterate_cb { return return_val; } - public boolean group_check(opdata od, long target_addr) { - if (od.addr == target_addr) - return true; // Addresses match + public boolean group_check(opdata od, H5O_token_t target_token) { + if (od.obj_token.equals(target_token)) + return true; // Object tokens match else if (od.recurs == 0) return false; // Root group reached with no matches else - return group_check(od.prev, target_addr); // Recursively examine the next node + return group_check(od.prev, target_token); // Recursively examine the next node } } diff --git a/java/examples/groups/H5Ex_G_Visit.java b/java/examples/groups/H5Ex_G_Visit.java index f91c707..4255316 100644 --- a/java/examples/groups/H5Ex_G_Visit.java +++ b/java/examples/groups/H5Ex_G_Visit.java @@ -23,10 +23,10 @@ package examples.groups; import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; -import hdf.hdf5lib.callbacks.H5L_iterate_cb; import hdf.hdf5lib.callbacks.H5L_iterate_t; -import hdf.hdf5lib.callbacks.H5O_iterate_cb; +import hdf.hdf5lib.callbacks.H5L_iterate_opdata_t; import hdf.hdf5lib.callbacks.H5O_iterate_t; +import hdf.hdf5lib.callbacks.H5O_iterate_opdata_t; import hdf.hdf5lib.structs.H5L_info_t; import hdf.hdf5lib.structs.H5O_info_t; @@ -55,13 +55,13 @@ public class H5Ex_G_Visit { // Begin iteration using H5Ovisit System.out.println("Objects in the file:"); - H5O_iterate_t iter_data = new H5O_iter_data(); - H5O_iterate_cb iter_cb = new H5O_iter_callback(); + H5O_iterate_opdata_t iter_data = new H5O_iter_data(); + H5O_iterate_t iter_cb = new H5O_iter_callback(); H5.H5Ovisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb, iter_data); System.out.println(); // Repeat the same process using H5Lvisit - H5L_iterate_t iter_data2 = new H5L_iter_data(); - H5L_iterate_cb iter_cb2 = new H5L_iter_callback(); + H5L_iterate_opdata_t iter_data2 = new H5L_iter_data(); + H5L_iterate_t iter_cb2 = new H5L_iter_callback(); System.out.println("Links in the file:"); H5.H5Lvisit(file_id, HDF5Constants.H5_INDEX_NAME, HDF5Constants.H5_ITER_NATIVE, iter_cb2, iter_data2); @@ -91,12 +91,12 @@ public class H5Ex_G_Visit { } } - private class H5L_iter_data implements H5L_iterate_t { + private class H5L_iter_data implements H5L_iterate_opdata_t { public ArrayList<idata> iterdata = new ArrayList<idata>(); } - private class H5L_iter_callback implements H5L_iterate_cb { - public int callback(long group, String name, H5L_info_t info, H5L_iterate_t op_data) { + private class H5L_iter_callback implements H5L_iterate_t { + public int callback(long group, String name, H5L_info_t info, H5L_iterate_opdata_t op_data) { idata id = new idata(name, info.type); ((H5L_iter_data) op_data).iterdata.add(id); @@ -107,8 +107,8 @@ public class H5Ex_G_Visit { // Get type of the object and display its name and type. The name of the object is passed to this // function by the Library. infobuf = H5.H5Oget_info_by_name(group, name, HDF5Constants.H5P_DEFAULT); - H5O_iterate_cb iter_cbO = new H5O_iter_callback(); - H5O_iterate_t iter_dataO = new H5O_iter_data(); + H5O_iterate_t iter_cbO = new H5O_iter_callback(); + H5O_iterate_opdata_t iter_dataO = new H5O_iter_data(); ret = iter_cbO.callback(group, name, infobuf, iter_dataO); } catch (Exception e) { @@ -119,12 +119,12 @@ public class H5Ex_G_Visit { } } - private class H5O_iter_data implements H5O_iterate_t { + private class H5O_iter_data implements H5O_iterate_opdata_t { public ArrayList<idata> iterdata = new ArrayList<idata>(); } - private class H5O_iter_callback implements H5O_iterate_cb { - public int callback(long group, String name, H5O_info_t info, H5O_iterate_t op_data) { + private class H5O_iter_callback implements H5O_iterate_t { + public int callback(long group, String name, H5O_info_t info, H5O_iterate_opdata_t op_data) { idata id = new idata(name, info.type); ((H5O_iter_data) op_data).iterdata.add(id); |