Skip to content

Commit 60e5e97

Browse files
committed
sonarqube cleanup.
1 parent 62d1d17 commit 60e5e97

14 files changed

Lines changed: 133 additions & 139 deletions

File tree

src/main/java/org/hdf5javalib/examples/FileByteComparator.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class FileByteComparator {
3434
public static void main(String[] args) {
3535
// Check if two file paths are provided as command-line arguments
3636
if (args.length != 2) {
37-
System.out.println("Usage: java FileByteComparator <file1> <file2>");
37+
log.info("Usage: java FileByteComparator <file1> <file2>");
3838
System.exit(1);
3939
}
4040

@@ -51,36 +51,36 @@ public static void main(String[] args) {
5151

5252
// Compare bytes and track differences
5353
boolean differencesFound = false;
54-
System.out.println("Offset File1 Value File2 Value");
55-
System.out.println("------------------------------------");
54+
log.info("Offset File1 Value File2 Value");
55+
log.info("------------------------------------");
5656

5757
for (int i = 0; i < minLength; i++) {
5858
if (file1Bytes[i] != file2Bytes[i]) {
5959
differencesFound = true;
6060
// Print offset and byte values in hex
61-
System.out.printf("0x%-8X 0x%02X 0x%02X%n",
61+
log.info(String.format("0x%-8X 0x%02X 0x%02X",
6262
i,
6363
file1Bytes[i] & 0xFF,
64-
file2Bytes[i] & 0xFF);
64+
file2Bytes[i] & 0xFF));
6565
}
6666
}
6767

6868
// Check for length differences
6969
if (file1Bytes.length != file2Bytes.length) {
7070
differencesFound = true;
71-
System.out.printf("Files differ in length: File1 = %d bytes, File2 = %d bytes%n",
72-
file1Bytes.length, file2Bytes.length);
71+
log.info(String.format("Files differ in length: File1 = %d bytes, File2 = %d bytes",
72+
file1Bytes.length, file2Bytes.length));
7373
if (file1Bytes.length > file2Bytes.length) {
74-
System.out.println("Extra bytes in File1 after offset 0x" +
74+
log.info("Extra bytes in File1 after offset 0x" +
7575
Integer.toHexString(minLength - 1).toUpperCase() + ":");
7676
for (int i = minLength; i < file1Bytes.length; i++) {
77-
System.out.printf("0x%-8X 0x%02X%n", i, file1Bytes[i] & 0xFF);
77+
log.info(String.format("0x%-8X 0x%02X", i, file1Bytes[i] & 0xFF));
7878
}
7979
} else {
80-
System.out.println("Extra bytes in File2 after offset 0x" +
80+
log.info("Extra bytes in File2 after offset 0x" +
8181
Integer.toHexString(minLength - 1).toUpperCase() + ":");
8282
for (int i = minLength; i < file2Bytes.length; i++) {
83-
System.out.printf("0x%-8X 0x%02X%n", i, file2Bytes[i] & 0xFF);
83+
log.info(String.format("0x%-8X 0x%02X", i, file2Bytes[i] & 0xFF));
8484
}
8585
}
8686
}

src/main/java/org/hdf5javalib/examples/HDF5Examples/ExamplesRead.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void run() {
4242
Files.list(dirPath)
4343
.filter(p -> p.toString().endsWith(".h5"))
4444
.forEach(p -> {
45-
System.out.println("Running " + p.getFileName());
45+
log.info("Running {}", p.getFileName());
4646
displayFile(p);
4747
});
4848
} catch (URISyntaxException | IOException e) {

src/main/java/org/hdf5javalib/examples/HDF5Examples/ReferenceRead.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void run() {
5959
try {
6060
// Path filePath = getResourcePath("HDF5Examples/h5ex_t_cpxcmpd.h5");
6161
Path filePath = getResourcePath("h5ex_tutr/SDScompound.h5");
62-
System.out.println(filePath.toFile().getAbsolutePath());
62+
log.info("{}", filePath.toFile().getAbsolutePath());
6363
try (SeekableByteChannel channel = Files.newByteChannel(filePath, StandardOpenOption.READ)) {
6464
HdfFileReader reader = new HdfFileReader(channel).readFile();
6565
// try (HdfDataset dataSet = reader.getRootGroup().getDataset("/DS1").orElseThrow()) {
@@ -78,7 +78,7 @@ private void run() {
7878

7979
private void displayReference(SeekableByteChannel channel, HdfDataset dataSet, HdfFileReader reader) {
8080
dataSet.getReferenceInstances().forEach(referenceInstance -> {
81-
System.out.println("referenceInstance=" + referenceInstance);
81+
log.info("referenceInstance={}", referenceInstance);
8282
});
8383
}
8484

src/main/java/org/hdf5javalib/examples/h5ex_d/h5ex_d_read.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.hdf5javalib.examples.h5ex_d;
22

33
import org.hdf5javalib.datasource.TypedDataSource;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.io.IOException;
68
import java.net.URISyntaxException;
@@ -22,6 +24,7 @@
2224
* </p>
2325
*/
2426
public class h5ex_d_read {
27+
private static final Logger log = LoggerFactory.getLogger(h5ex_d_read.class);
2528
/**
2629
* Entry point for the application.
2730
*
@@ -41,7 +44,7 @@ private void run() {
4144
try ( Stream<Path> streamList = Files.list(dirPath) ) {
4245
streamList.filter(p -> p.toString().endsWith(".h5"))
4346
.forEach(p -> {
44-
System.out.println("Running " + p.getFileName());
47+
log.info("Running {}", p.getFileName());
4548
displayFile(p);
4649
});
4750

src/main/java/org/hdf5javalib/examples/h5ex_t/att/h5ex_t_att_read.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.hdf5javalib.examples.h5ex_t.att;
22

33
import org.hdf5javalib.datasource.TypedDataSource;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.io.IOException;
68
import java.net.URISyntaxException;
@@ -22,6 +24,7 @@
2224
* </p>
2325
*/
2426
public class h5ex_t_att_read {
27+
private static final Logger log = LoggerFactory.getLogger(h5ex_t_att_read.class);
2528
/**
2629
* Entry point for the application.
2730
*
@@ -41,7 +44,7 @@ private void run() {
4144
try ( Stream<Path> streamList = Files.list(dirPath) ) {
4245
streamList.filter(p -> p.toString().endsWith(".h5"))
4346
.forEach(p -> {
44-
System.out.println("Running " + p.getFileName());
47+
log.info("Running {}", p.getFileName());
4548
displayFileAttr(p);
4649
});
4750

src/main/java/org/hdf5javalib/examples/h5ex_t/h5ex_t_read.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.hdf5javalib.examples.h5ex_t;
22

33
import org.hdf5javalib.datasource.TypedDataSource;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.io.IOException;
68
import java.net.URISyntaxException;
@@ -22,6 +24,7 @@
2224
* </p>
2325
*/
2426
public class h5ex_t_read {
27+
private static final Logger log = LoggerFactory.getLogger(h5ex_t_read.class);
2528
/**
2629
* Entry point for the application.
2730
*
@@ -41,7 +44,7 @@ private void run() {
4144
try ( Stream<Path> streamList = Files.list(dirPath) ) {
4245
streamList.filter(p -> p.toString().endsWith(".h5"))
4346
.forEach(p -> {
44-
System.out.println("Running " + p.getFileName());
47+
log.info("Running {}", p.getFileName());
4548
displayFile(p);
4649
});
4750

src/main/java/org/hdf5javalib/examples/h5ex_tutr/att/h5ex_tutr_att_read.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.hdf5javalib.examples.h5ex_tutr.att;
22

33
import org.hdf5javalib.datasource.TypedDataSource;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.io.IOException;
68
import java.net.URISyntaxException;
@@ -22,6 +24,7 @@
2224
* </p>
2325
*/
2426
public class h5ex_tutr_att_read {
27+
private static final Logger log = LoggerFactory.getLogger(h5ex_tutr_att_read.class);
2528
/**
2629
* Entry point for the application.
2730
*
@@ -41,7 +44,7 @@ private void run() {
4144
try ( Stream<Path> streamList = Files.list(dirPath) ) {
4245
streamList.filter(p -> p.toString().endsWith(".h5"))
4346
.forEach(p -> {
44-
System.out.println("Running " + p.getFileName());
47+
log.info("Running {}", p.getFileName());
4548
displayFileAttr(p);
4649
});
4750

src/main/java/org/hdf5javalib/examples/h5ex_tutr/h5ex_tutr_read.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.hdf5javalib.examples.h5ex_tutr;
22

33
import org.hdf5javalib.datasource.TypedDataSource;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.io.IOException;
68
import java.net.URISyntaxException;
@@ -22,6 +24,7 @@
2224
* </p>
2325
*/
2426
public class h5ex_tutr_read {
27+
private static final Logger log = LoggerFactory.getLogger(h5ex_tutr_read.class);
2528
/**
2629
* Entry point for the application.
2730
*
@@ -41,7 +44,7 @@ private void run() {
4144
try ( Stream<Path> streamList = Files.list(dirPath) ) {
4245
streamList.filter(p -> p.toString().endsWith(".h5"))
4346
.forEach(p -> {
44-
System.out.println("Running " + p.getFileName());
47+
log.info("Running {}", p.getFileName());
4548
displayFile(p);
4649
});
4750

src/main/java/org/hdf5javalib/examples/read/CompoundRead.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.hdf5javalib.hdfjava.HdfDataFile;
66
import org.hdf5javalib.hdfjava.HdfDataset;
77
import org.hdf5javalib.hdfjava.HdfFileReader;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
810

911
import java.io.IOException;
1012
import java.lang.reflect.InvocationTargetException;
@@ -26,7 +28,7 @@
2628
* </p>
2729
*/
2830
public class CompoundRead {
29-
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CompoundRead.class);
31+
private static final Logger log = LoggerFactory.getLogger(CompoundRead.class);
3032

3133
/**
3234
* Entry point for the application.
@@ -49,7 +51,7 @@ private void run() {
4951
displayData(channel, dataSet, reader);
5052
}
5153
log.debug("File BTree: {} ", reader.getBTree());
52-
}
54+
}
5355

5456
} catch (Exception e) {
5557
throw new IllegalStateException(e);
@@ -136,28 +138,19 @@ public int getValue() {
136138
* @throws IOException if an I/O error occurs
137139
*/
138140
public void displayData(SeekableByteChannel seekableByteChannel, HdfDataset dataSet, HdfDataFile hdfDataFile) throws IOException, InvocationTargetException, InstantiationException, IllegalAccessException {
139-
System.out.println("Ten Rows:");
141+
log.info("Ten Rows:");
140142
new TypedDataSource<>(seekableByteChannel, hdfDataFile, dataSet, HdfCompound.class)
141143
.streamVector()
142144
.limit(10)
143-
.forEach(c -> System.out.println("Row: " + c.getMembers()));
145+
.forEach(c -> log.info("Row: {}", c.getMembers()));
144146

145-
// System.out.println("Ten BigDecimals = " + new TypedDataSource<>(seekableByteChannel, hdfDataFile, dataSet, HdfCompound.class).streamVector()
146-
// .filter(c -> c.getMembers().get(0).getInstance(Long.class) < 1010)
147-
// .map(c -> c.getMembers().get(13).getInstance(BigDecimal.class)).toList());
148-
//
149-
// System.out.println("Custom record class:");
150-
// new TypedDataSource<>(seekableByteChannel, hdfDataFile, dataSet, Record.class)
151-
// .streamVector()
152-
// .forEach(c -> System.out.println("Row: " + c));
153-
// System.out.println("DONE");
154147
AtomicInteger atomicInteger = new AtomicInteger(0);
155148
new TypedDataSource<>(seekableByteChannel, hdfDataFile, dataSet, HdfCompound.class)
156149
.streamVector()
157150
.forEach(c-> {
158151
c.getMembers().toString();
159152
atomicInteger.incrementAndGet();
160153
});
161-
System.out.println("DONE: " + atomicInteger.get());
154+
log.info("DONE: {}", atomicInteger.get());
162155
}
163156
}

0 commit comments

Comments
 (0)