KeyValue classes added to DataModel

This commit is contained in:
Peter J. Martel 2011-12-13 13:14:59 -05:00
parent f6e029935d
commit 2bad9d1603
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package org.sleuthkit.autopsy.datamodel;
import java.util.Map;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Sheet;
public class KeyValueNode extends AbstractNode {
KeyValueThing thing;
public KeyValueNode(KeyValueThing thing, Children children) {
super(children);
this.setName(thing.getName());
this.thing = thing;
}
@Override
protected Sheet createSheet() {
Sheet s = super.createSheet();
Sheet.Set ss = s.get(Sheet.PROPERTIES);
if (ss == null) {
ss = Sheet.createPropertiesSet();
s.put(ss);
}
for (Map.Entry<String, Object> entry : thing.getMap().entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
ss.put(new NodeProperty(key, key, "n/a", value));
}
return s;
}
}

View File

@ -0,0 +1,33 @@
package org.sleuthkit.autopsy.datamodel;
import java.util.Map;
public class KeyValueThing {
Map<String, Object> map;
int id;
String name;
/**
*
* @param map must iterate it keys and values in a consistent order
* (use of LinkedHashMap is recommended)
* @param id an arbitrary id representing the type of the thing
*/
public KeyValueThing(String name, Map<String, Object> map, int id) {
this.name = name;
this.map = map;
this.id = id;
}
public int getId() {
return id;
}
public Map<String, Object> getMap() {
return map;
}
public String getName() {
return name;
}
}