diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-04-22 15:24:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 15:24:27 (GMT) |
commit | 974aefb8416d78b0687a54e5f72f21d0ca72ae2d (patch) | |
tree | 0fe4e4327b95c38f362ceace220d59cb08aa88a3 /java/examples/datasets/H5Ex_D_Alloc.java | |
parent | f5042fd4d3549e9e3453ab99d81bb46f1688b240 (diff) | |
download | hdf5-974aefb8416d78b0687a54e5f72f21d0ca72ae2d.zip hdf5-974aefb8416d78b0687a54e5f72f21d0ca72ae2d.tar.gz hdf5-974aefb8416d78b0687a54e5f72f21d0ca72ae2d.tar.bz2 |
Add java clang-format (#1672)
Diffstat (limited to 'java/examples/datasets/H5Ex_D_Alloc.java')
-rw-r--r-- | java/examples/datasets/H5Ex_D_Alloc.java | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/java/examples/datasets/H5Ex_D_Alloc.java b/java/examples/datasets/H5Ex_D_Alloc.java index 4e10c23..4853cc0 100644 --- a/java/examples/datasets/H5Ex_D_Alloc.java +++ b/java/examples/datasets/H5Ex_D_Alloc.java @@ -29,49 +29,47 @@ import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; public class H5Ex_D_Alloc { - private static String FILENAME = "H5Ex_D_Alloc.h5"; + private static String FILENAME = "H5Ex_D_Alloc.h5"; private static String DATASETNAME1 = "DS1"; private static String DATASETNAME2 = "DS2"; - private static final int DIM_X = 4; - private static final int DIM_Y = 7; - private static final int FILLVAL = 99; - private static final int RANK = 2; + private static final int DIM_X = 4; + private static final int DIM_Y = 7; + private static final int FILLVAL = 99; + private static final int RANK = 2; // Values for the status of space allocation enum H5D_space_status { - H5D_SPACE_STATUS_ERROR(-1), H5D_SPACE_STATUS_NOT_ALLOCATED(0), H5D_SPACE_STATUS_PART_ALLOCATED(1), H5D_SPACE_STATUS_ALLOCATED( - 2); + H5D_SPACE_STATUS_ERROR(-1), + H5D_SPACE_STATUS_NOT_ALLOCATED(0), + H5D_SPACE_STATUS_PART_ALLOCATED(1), + H5D_SPACE_STATUS_ALLOCATED(2); private static final Map<Integer, H5D_space_status> lookup = new HashMap<Integer, H5D_space_status>(); - static { + static + { for (H5D_space_status s : EnumSet.allOf(H5D_space_status.class)) lookup.put(s.getCode(), s); } private int code; - H5D_space_status(int space_status) { - this.code = space_status; - } + H5D_space_status(int space_status) { this.code = space_status; } - public int getCode() { - return this.code; - } + public int getCode() { return this.code; } - public static H5D_space_status get(int code) { - return lookup.get(code); - } + public static H5D_space_status get(int code) { return lookup.get(code); } } - private static void allocation() { - long file_id = HDF5Constants.H5I_INVALID_HID; + private static void allocation() + { + long file_id = HDF5Constants.H5I_INVALID_HID; long filespace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id1 = HDF5Constants.H5I_INVALID_HID; - long dataset_id2 = HDF5Constants.H5I_INVALID_HID; - long dcpl_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM_X, DIM_Y }; + long dataset_id1 = HDF5Constants.H5I_INVALID_HID; + long dataset_id2 = HDF5Constants.H5I_INVALID_HID; + long dcpl_id = HDF5Constants.H5I_INVALID_HID; + long[] dims = {DIM_X, DIM_Y}; int[][] dset_data = new int[DIM_X][DIM_Y]; - int space_status = 0; + int space_status = 0; long storage_size = 0; // Initialize the dataset. @@ -82,7 +80,7 @@ public class H5Ex_D_Alloc { // Create a 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(); @@ -125,7 +123,8 @@ public class H5Ex_D_Alloc { try { if ((file_id >= 0) && (filespace_id >= 0)) dataset_id1 = H5.H5Dcreate(file_id, DATASETNAME1, HDF5Constants.H5T_NATIVE_INT, filespace_id, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, + HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -135,7 +134,7 @@ public class H5Ex_D_Alloc { try { if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0)) dataset_id2 = H5.H5Dcreate(file_id, DATASETNAME2, HDF5Constants.H5T_NATIVE_INT, filespace_id, - HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT, dcpl_id, HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -190,16 +189,16 @@ public class H5Ex_D_Alloc { // Write the data to the datasets. try { if (dataset_id1 >= 0) - H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, dset_data[0]); + H5.H5Dwrite(dataset_id1, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, + HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]); } catch (Exception e) { e.printStackTrace(); } try { if (dataset_id2 >= 0) - H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, dset_data[0]); + H5.H5Dwrite(dataset_id2, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, + HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, dset_data[0]); } catch (Exception e) { e.printStackTrace(); @@ -291,8 +290,5 @@ public class H5Ex_D_Alloc { } } - public static void main(String[] args) { - H5Ex_D_Alloc.allocation(); - } - + public static void main(String[] args) { H5Ex_D_Alloc.allocation(); } } |