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/datatypes/H5Ex_T_IntegerAttribute.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/datatypes/H5Ex_T_IntegerAttribute.java')
-rw-r--r-- | java/examples/datatypes/H5Ex_T_IntegerAttribute.java | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/java/examples/datatypes/H5Ex_T_IntegerAttribute.java b/java/examples/datatypes/H5Ex_T_IntegerAttribute.java index b0df5e4..4ec98c4 100644 --- a/java/examples/datatypes/H5Ex_T_IntegerAttribute.java +++ b/java/examples/datatypes/H5Ex_T_IntegerAttribute.java @@ -26,19 +26,20 @@ import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; public class H5Ex_T_IntegerAttribute { - private static String FILENAME = "H5Ex_T_IntegerAttribute.h5"; - private static String DATASETNAME = "DS1"; + private static String FILENAME = "H5Ex_T_IntegerAttribute.h5"; + private static String DATASETNAME = "DS1"; private static String ATTRIBUTENAME = "A1"; - private static final int DIM0 = 4; - private static final int DIM1 = 7; - private static final int RANK = 2; + private static final int DIM0 = 4; + private static final int DIM1 = 7; + private static final int RANK = 2; - private static void CreateDataset() { - long file_id = HDF5Constants.H5I_INVALID_HID; + private static void CreateDataset() + { + long file_id = HDF5Constants.H5I_INVALID_HID; long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; + long dataset_id = HDF5Constants.H5I_INVALID_HID; long attribute_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM0, DIM1 }; + long[] dims = {DIM0, DIM1}; int[][] dset_data = new int[DIM0][DIM1]; // Initialize data. @@ -50,7 +51,7 @@ public class H5Ex_T_IntegerAttribute { // 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(); @@ -61,7 +62,8 @@ public class H5Ex_T_IntegerAttribute { dataspace_id = H5.H5Screate(HDF5Constants.H5S_SCALAR); if (dataspace_id >= 0) { dataset_id = H5.H5Dcreate(file_id, DATASETNAME, HDF5Constants.H5T_STD_I32LE, dataspace_id, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, + HDF5Constants.H5P_DEFAULT); H5.H5Sclose(dataspace_id); dataspace_id = HDF5Constants.H5I_INVALID_HID; } @@ -82,8 +84,9 @@ public class H5Ex_T_IntegerAttribute { // Create the attribute and write the array data to it. try { if ((dataset_id >= 0) && (dataspace_id >= 0)) - attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_I64BE, dataspace_id, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + attribute_id = + H5.H5Acreate(dataset_id, ATTRIBUTENAME, HDF5Constants.H5T_STD_I64BE, dataspace_id, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -132,15 +135,15 @@ public class H5Ex_T_IntegerAttribute { catch (Exception e) { e.printStackTrace(); } - } - private static void ReadDataset() { - long file_id = HDF5Constants.H5I_INVALID_HID; + private static void ReadDataset() + { + long file_id = HDF5Constants.H5I_INVALID_HID; long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; + long dataset_id = HDF5Constants.H5I_INVALID_HID; long attribute_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM0, DIM1 }; + long[] dims = {DIM0, DIM1}; int[][] dset_data; // Open an existing file. @@ -163,7 +166,7 @@ public class H5Ex_T_IntegerAttribute { try { if (dataset_id >= 0) attribute_id = H5.H5Aopen_by_name(dataset_id, ".", ATTRIBUTENAME, HDF5Constants.H5P_DEFAULT, - HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -188,7 +191,7 @@ public class H5Ex_T_IntegerAttribute { // Allocate array of pointers to two-dimensional arrays (the // elements of the dataset. - dset_data = new int[(int) dims[0]][(int) (dims[1])]; + dset_data = new int[(int)dims[0]][(int)(dims[1])]; // Read data. try { @@ -245,10 +248,10 @@ public class H5Ex_T_IntegerAttribute { catch (Exception e) { e.printStackTrace(); } - } - public static void main(String[] args) { + public static void main(String[] args) + { H5Ex_T_IntegerAttribute.CreateDataset(); // Now we begin the read section of this example. Here we assume // the dataset and array have the same name and rank, but can have @@ -256,5 +259,4 @@ public class H5Ex_T_IntegerAttribute { // data using malloc(). H5Ex_T_IntegerAttribute.ReadDataset(); } - } |