Skip to content

Commit a8250a8

Browse files
committed
SonarQube cleanup - bugs cleanup
1 parent 77426e1 commit a8250a8

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

src/main/java/org/hdf5javalib/examples/hdf5examples/HDF5Debug.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ private void run() {
4949
// Path dirPath = Paths.get(Objects.requireNonNull(HDF5Debug.class.getClassLoader().getResource("HDF5Examples/h5ex_g_compact2.h5")).toURI());
5050
// Path dirPath = Paths.get("c:/users/karln/Downloads/ATL03_20250302235544_11742607_007_01.h5");
5151
// Path dirPath = Paths.get("c:/users/karln/Downloads/ATL03_20250302235544_11742607_006_01.h5");
52-
Path dirPath = Paths.get("c:/users/karln/Downloads/SMAP_L1B_TB_57204_D_20251016T224815_R19240_001.h5");
52+
// Path dirPath = Paths.get("c:/users/karln/Downloads/SMAP_L1B_TB_57204_D_20251016T224815_R19240_001.h5");
53+
// Path dirPath = Paths.get("c:/users/karln/Downloads/ATL08_20250610011615_13002704_007_01.h5");
54+
Path dirPath = Paths.get("c:/users/karln/Downloads/SMAP_L2_SM_P_55348_A_20250612T001323_R19240_001.h5");
55+
56+
5357
processFile(dirPath);
5458
} catch (Exception e) {
5559
throw new IllegalStateException(e);

src/main/java/org/hdf5javalib/hdffile/dataobjects/messages/HdfMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ protected static HdfMessage parseHeaderMessage(MessageType type, int flags, byte
244244
case OBJECT_MODIFICATION_TIME_MESSAGE -> ObjectModificationTimeMessage.parseHeaderMessage(flags, data, hdfDataFile);
245245
case BTREE_K_VALUES_MESSAGE -> BTreeKValuesMessage.parseHeaderMessage(flags, data, hdfDataFile);
246246
case ATTRIBUTE_INFO_MESSAGE -> AttributeInfoMessage.parseHeaderMessage(flags, data, hdfDataFile);
247+
case OBJECT_REFERENCE_COUNT_MESSAGE -> ObjectReferenceCountMessage.parseHeaderMessage(flags, data, hdfDataFile);
247248
default -> throw new IllegalArgumentException("Unknown message type: " + type);
248249
};
249250
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.hdf5javalib.hdffile.dataobjects.messages;
2+
3+
import org.hdf5javalib.hdfjava.HdfDataFile;
4+
5+
import java.nio.ByteBuffer;
6+
import java.nio.ByteOrder;
7+
import java.util.Arrays;
8+
9+
public class ObjectReferenceCountMessage extends HdfMessage {
10+
/**
11+
* The version of the fill value message format.
12+
*/
13+
private final int version;
14+
private final long referenceCount;
15+
16+
/**
17+
* Public constructor
18+
* @param version Message version
19+
* @param referenceCount referenceCount in Message
20+
* @param sizeMessageData size of message data
21+
* @param messageFlags messageflags
22+
*/
23+
public ObjectReferenceCountMessage(int version, long referenceCount, int sizeMessageData, int messageFlags) {
24+
super(MessageType.OBJECT_REFERENCE_COUNT_MESSAGE, sizeMessageData, messageFlags);
25+
this.version = version;
26+
this.referenceCount = referenceCount;
27+
}
28+
29+
/**
30+
* Parses a FillValueMessage from the provided data and file context.
31+
*
32+
* @param flags message flags
33+
* @param data the byte array containing the message data
34+
* @param hdfDataFile the HDF5 file context for additional resources
35+
* @return a new FillValueMessage instance parsed from the data
36+
*/
37+
public static HdfMessage parseHeaderMessage(int flags, byte[] data, HdfDataFile hdfDataFile) {
38+
ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
39+
40+
// Parse the first 4 bytes
41+
int version = Byte.toUnsignedInt(buffer.get());
42+
long referenceCount = Integer.toUnsignedLong(buffer.getInt());
43+
return new ObjectReferenceCountMessage(version, referenceCount, flags, data.length);
44+
}
45+
46+
/**
47+
* Returns a string representation of this FillValueMessage.
48+
*
49+
* @return a string describing the message size, version, allocation times, and fill value details
50+
*/
51+
@Override
52+
public String toString() {
53+
return "ObjectReferenceCountMessage(" + (getSizeMessageData() + HDF_MESSAGE_PREAMBLE_SIZE) + "){" +
54+
"version=" + version +
55+
", referenceCount=" + referenceCount +
56+
'}';
57+
}
58+
59+
60+
@Override
61+
public void writeMessageToByteBuffer(ByteBuffer buffer) {
62+
// not implemented
63+
}
64+
}

0 commit comments

Comments
 (0)