diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-04-26 01:32:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 01:32:50 (GMT) |
commit | 41a36efde14a1db65cc8be0ef9de1ec41fe86ed6 (patch) | |
tree | 645c2a1b8d6eecc141cd0a063a3974bfdaaa8abe /java/examples/datasets/H5Ex_D_UnlimitedMod.java | |
parent | d19d9b4c8ace3c712cc8126e37f2a7e3ff68e8a9 (diff) | |
download | hdf5-41a36efde14a1db65cc8be0ef9de1ec41fe86ed6.zip hdf5-41a36efde14a1db65cc8be0ef9de1ec41fe86ed6.tar.gz hdf5-41a36efde14a1db65cc8be0ef9de1ec41fe86ed6.tar.bz2 |
Add java to format source (#1690)
Diffstat (limited to 'java/examples/datasets/H5Ex_D_UnlimitedMod.java')
-rw-r--r-- | java/examples/datasets/H5Ex_D_UnlimitedMod.java | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/java/examples/datasets/H5Ex_D_UnlimitedMod.java b/java/examples/datasets/H5Ex_D_UnlimitedMod.java index 0708898..ccabcdd 100644 --- a/java/examples/datasets/H5Ex_D_UnlimitedMod.java +++ b/java/examples/datasets/H5Ex_D_UnlimitedMod.java @@ -26,25 +26,26 @@ import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; public class H5Ex_D_UnlimitedMod { - private static String FILENAME = "H5Ex_D_UnlimitedMod.h5"; + private static String FILENAME = "H5Ex_D_UnlimitedMod.h5"; private static String DATASETNAME = "DS1"; - private static final int DIM_X = 4; - private static final int DIM_Y = 7; - private static final int EDIM_X = 6; - private static final int EDIM_Y = 10; - private static final int CHUNK_X = 4; - private static final int CHUNK_Y = 4; - private static final int RANK = 2; - private static final int NDIMS = 2; - - private static void writeUnlimited() { - long file_id = HDF5Constants.H5I_INVALID_HID; - long dcpl_id = HDF5Constants.H5I_INVALID_HID; + private static final int DIM_X = 4; + private static final int DIM_Y = 7; + private static final int EDIM_X = 6; + private static final int EDIM_Y = 10; + private static final int CHUNK_X = 4; + private static final int CHUNK_Y = 4; + private static final int RANK = 2; + private static final int NDIMS = 2; + + private static void writeUnlimited() + { + long file_id = HDF5Constants.H5I_INVALID_HID; + long dcpl_id = HDF5Constants.H5I_INVALID_HID; long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM_X, DIM_Y }; - long[] chunk_dims = { CHUNK_X, CHUNK_Y }; - long[] maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED }; + long dataset_id = HDF5Constants.H5I_INVALID_HID; + long[] dims = {DIM_X, DIM_Y}; + long[] chunk_dims = {CHUNK_X, CHUNK_Y}; + long[] maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED}; int[][] dset_data = new int[DIM_X][DIM_Y]; // Initialize the dataset. @@ -55,7 +56,7 @@ public class H5Ex_D_UnlimitedMod { // Create a new file using default properties. try { file_id = H5.H5Fcreate(FILENAME, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -90,7 +91,7 @@ public class H5Ex_D_UnlimitedMod { try { if ((file_id >= 0) && (dataspace_id >= 0) && (dcpl_id >= 0)) dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id, - HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -99,8 +100,8 @@ public class H5Ex_D_UnlimitedMod { // Write the data to the dataset. try { if (dataset_id >= 0) - H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, dset_data); + H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, + HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data); } catch (Exception e) { e.printStackTrace(); @@ -141,12 +142,13 @@ public class H5Ex_D_UnlimitedMod { } } - private static void extendUnlimited() { - long file_id = HDF5Constants.H5I_INVALID_HID; + private static void extendUnlimited() + { + long file_id = HDF5Constants.H5I_INVALID_HID; long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM_X, DIM_Y }; - long[] extdims = { EDIM_X, EDIM_Y }; + long dataset_id = HDF5Constants.H5I_INVALID_HID; + long[] dims = {DIM_X, DIM_Y}; + long[] extdims = {EDIM_X, EDIM_Y}; int[][] dset_data; int[][] extend_dset_data = new int[EDIM_X][EDIM_Y]; @@ -187,13 +189,13 @@ public class H5Ex_D_UnlimitedMod { } // Allocate array of pointers to rows. - dset_data = new int[(int) dims[0]][(int) dims[1]]; + dset_data = new int[(int)dims[0]][(int)dims[1]]; // Read the data using the default properties. try { if (dataset_id >= 0) - H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, dset_data); + H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, + HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data); } catch (Exception e) { e.printStackTrace(); @@ -244,7 +246,7 @@ public class H5Ex_D_UnlimitedMod { try { if ((dataspace_id >= 0) && (dataset_id >= 0)) H5.H5Dwrite(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, dataspace_id, - HDF5Constants.H5P_DEFAULT, extend_dset_data); + HDF5Constants.H5P_DEFAULT, extend_dset_data); } catch (Exception e) { e.printStackTrace(); @@ -277,11 +279,12 @@ public class H5Ex_D_UnlimitedMod { } } - private static void readUnlimited() { - long file_id = HDF5Constants.H5I_INVALID_HID; + private static void readUnlimited() + { + long file_id = HDF5Constants.H5I_INVALID_HID; long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM_X, DIM_Y }; + long dataset_id = HDF5Constants.H5I_INVALID_HID; + long[] dims = {DIM_X, DIM_Y}; int[][] dset_data; // Open an existing file. @@ -318,13 +321,13 @@ public class H5Ex_D_UnlimitedMod { e.printStackTrace(); } // Allocate array of pointers to rows. - dset_data = new int[(int) dims[0]][(int) dims[1]]; + dset_data = new int[(int)dims[0]][(int)dims[1]]; // Read the data using the default properties. try { if (dataset_id >= 0) - H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, dset_data); + H5.H5Dread(dataset_id, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, + HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data); } catch (Exception e) { e.printStackTrace(); @@ -367,10 +370,10 @@ public class H5Ex_D_UnlimitedMod { } } - public static void main(String[] args) { + public static void main(String[] args) + { H5Ex_D_UnlimitedMod.writeUnlimited(); H5Ex_D_UnlimitedMod.extendUnlimited(); H5Ex_D_UnlimitedMod.readUnlimited(); } - } |