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_ArrayAttribute.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_ArrayAttribute.java')
-rw-r--r-- | java/examples/datatypes/H5Ex_T_ArrayAttribute.java | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/java/examples/datatypes/H5Ex_T_ArrayAttribute.java b/java/examples/datatypes/H5Ex_T_ArrayAttribute.java index c4c4bc4..45b44c1 100644 --- a/java/examples/datatypes/H5Ex_T_ArrayAttribute.java +++ b/java/examples/datatypes/H5Ex_T_ArrayAttribute.java @@ -24,24 +24,25 @@ import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; public class H5Ex_T_ArrayAttribute { - private static String FILENAME = "H5Ex_T_ArrayAttribute.h5"; - private static String DATASETNAME = "DS1"; + private static String FILENAME = "H5Ex_T_ArrayAttribute.h5"; + private static String DATASETNAME = "DS1"; private static String ATTRIBUTENAME = "A1"; - private static final int DIM0 = 4; - private static final int ADIM0 = 3; - private static final int ADIM1 = 5; - private static final int RANK = 1; - private static final int NDIMS = 2; - - private static void CreateDataset() { - long file_id = HDF5Constants.H5I_INVALID_HID; - long filetype_id = HDF5Constants.H5I_INVALID_HID; - long memtype_id = HDF5Constants.H5I_INVALID_HID; - long dataspace_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; - long attribute_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM0 }; - long[] adims = { ADIM0, ADIM1 }; + private static final int DIM0 = 4; + private static final int ADIM0 = 3; + private static final int ADIM1 = 5; + private static final int RANK = 1; + private static final int NDIMS = 2; + + private static void CreateDataset() + { + long file_id = HDF5Constants.H5I_INVALID_HID; + long filetype_id = HDF5Constants.H5I_INVALID_HID; + long memtype_id = HDF5Constants.H5I_INVALID_HID; + long dataspace_id = HDF5Constants.H5I_INVALID_HID; + long dataset_id = HDF5Constants.H5I_INVALID_HID; + long attribute_id = HDF5Constants.H5I_INVALID_HID; + long[] dims = {DIM0}; + long[] adims = {ADIM0, ADIM1}; int[][][] dset_data = new int[DIM0][ADIM0][ADIM1]; // Initialize data. indx is the element in the dataspace, jndx and kndx the @@ -54,7 +55,7 @@ public class H5Ex_T_ArrayAttribute { // 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(); @@ -81,7 +82,8 @@ public class H5Ex_T_ArrayAttribute { 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; } @@ -103,7 +105,7 @@ public class H5Ex_T_ArrayAttribute { try { if ((dataset_id >= 0) && (dataspace_id >= 0) && (filetype_id >= 0)) attribute_id = H5.H5Acreate(dataset_id, ATTRIBUTENAME, filetype_id, dataspace_id, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); } catch (Exception e) { e.printStackTrace(); @@ -170,17 +172,17 @@ public class H5Ex_T_ArrayAttribute { catch (Exception e) { e.printStackTrace(); } - } - private static void ReadDataset() { - long file_id = HDF5Constants.H5I_INVALID_HID; - long filetype_id = HDF5Constants.H5I_INVALID_HID; - long memtype_id = HDF5Constants.H5I_INVALID_HID; - long dataset_id = HDF5Constants.H5I_INVALID_HID; + private static void ReadDataset() + { + long file_id = HDF5Constants.H5I_INVALID_HID; + long filetype_id = HDF5Constants.H5I_INVALID_HID; + long memtype_id = HDF5Constants.H5I_INVALID_HID; + long dataset_id = HDF5Constants.H5I_INVALID_HID; long attribute_id = HDF5Constants.H5I_INVALID_HID; - long[] dims = { DIM0 }; - long[] adims = { ADIM0, ADIM1 }; + long[] dims = {DIM0}; + long[] adims = {ADIM0, ADIM1}; int[][][] dset_data; // Open an existing file. @@ -203,7 +205,7 @@ public class H5Ex_T_ArrayAttribute { 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(); @@ -229,7 +231,7 @@ public class H5Ex_T_ArrayAttribute { // Allocate array of pointers to two-dimensional arrays (the // elements of the dataset. - dset_data = new int[(int) dims[0]][(int) (adims[0])][(int) (adims[1])]; + dset_data = new int[(int)dims[0]][(int)(adims[0])][(int)(adims[1])]; // Create array datatypes for memory. try { @@ -304,10 +306,10 @@ public class H5Ex_T_ArrayAttribute { catch (Exception e) { e.printStackTrace(); } - } - public static void main(String[] args) { + public static void main(String[] args) + { H5Ex_T_ArrayAttribute.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 @@ -315,5 +317,4 @@ public class H5Ex_T_ArrayAttribute { // data using malloc(). H5Ex_T_ArrayAttribute.ReadDataset(); } - } |