Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit 7de60ff

Browse files
committed
Rename base class
1 parent a309604 commit 7de60ff

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/main/java/org/idmef/Analyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Current implementation does not check property keys in put method. Property keys and values are checked
99
* when calling validate() method.
1010
*/
11-
public class Analyzer extends BaseObject {
11+
public class Analyzer extends IDMEFObject {
1212

1313
/**
1414
* Constructs an empty Analyzer.

src/main/java/org/idmef/BaseObject.java renamed to src/main/java/org/idmef/IDMEFObject.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
import java.util.HashMap;
66
import java.util.List;
77

8-
class BaseObject extends HashMap<String, Object> {
8+
class IDMEFObject extends HashMap<String, Object> {
99

1010
/**
11-
* Set a property of the Message.
11+
* Set a property of the Message. If value is an array, transform it to a List.
12+
*
1213
* @param key the property key
1314
* @param value the property value
1415
* @return the value that was set
1516
*/
1617
public Object put(String key, Object value) {
1718
Object adaptedValue = value;
19+
1820
if (value.getClass().isArray()) {
1921
List<Object> l = new ArrayList<>();
2022

src/main/java/org/idmef/Message.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Current implementation does not check property keys in put method. Property keys and values are checked
1818
* when calling validate() method.
1919
*/
20-
public class Message extends BaseObject {
20+
public class Message extends IDMEFObject {
2121
private static final String SCHEMA_RESOURCE_PATH = "/IDMEFv2.schema";
2222

2323
/**
@@ -79,6 +79,11 @@ public byte[] serialize() throws IDMEFException, IOException {
7979
public static Map<String, Object> unserialize(byte[] json) throws IOException {
8080
ObjectMapper objectMapper = new ObjectMapper();
8181

82-
return objectMapper.readValue(json, new TypeReference<Map<String,Object>>(){});
82+
Map<String, Object> map = objectMapper.readValue(json, new TypeReference<Map<String,Object>>(){});
83+
84+
for (Map.Entry<String,Object> entry : map.entrySet()) {
85+
System.out.println("Item: " + entry.getKey() + ", Price: " + entry.getValue());
86+
}
87+
return map;
8388
}
8489
}

0 commit comments

Comments
 (0)