Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
InstanceCaseNode.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2018 Basis Technology Corp.
6  * Contact: carrier <at> sleuthkit <dot> org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.sleuthkit.autopsy.commonpropertiessearch;
21 
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import org.openide.nodes.ChildFactory;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Node;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.NbBundle;
35 
39 public final class InstanceCaseNode extends DisplayableItemNode {
40 
41  private static final Logger logger = Logger.getLogger(InstanceCaseNode.class.getName());
42 
43  final private String caseName;
44  final private Map<String, CommonAttributeValueList> dataSourceToValueList;
45 
54  public InstanceCaseNode(String caseName, Map<String, CommonAttributeValueList> attributeValues) {
55  super(Children.create(new CommonAttributeDataSourceNodeFactory(attributeValues), true));
56  this.caseName = caseName;
57  this.dataSourceToValueList = attributeValues;
58  this.setDisplayName(this.caseName);
59  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/briefcase.png"); //NON-NLS
60  }
61 
67  String getCaseName() {
68  return this.caseName;
69  }
70 
75  void createChildren() {
76  setChildren(Children.create(new CommonAttributeDataSourceNodeFactory(dataSourceToValueList), true));
77  }
78 
85  Map<String, CommonAttributeValueList> getDataSourceToValueList() {
86  return this.dataSourceToValueList;
87  }
88 
89  @Override
90  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
91  return visitor.visit(this);
92  }
93 
94  @Override
95  public boolean isLeafTypeNode() {
96  return false;
97  }
98 
99  @Override
100  public String getItemType() {
101  return getClass().getName();
102  }
103 
104  @Override
105  protected Sheet createSheet() {
106  Sheet sheet = new Sheet();
107  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
108  if (sheetSet == null) {
109  sheetSet = Sheet.createPropertiesSet();
110  sheet.put(sheetSet);
111  }
112  final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
113  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
114  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_localPath(), Bundle.CommonFilesSearchResultsViewerTable_localPath(), NO_DESCR, ""));
115  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NO_DESCR, ""));
116  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), NO_DESCR, ""));
117  return sheet;
118  }
119 
124  static class CommonAttributeDataSourceNodeFactory extends ChildFactory<String> {
125 
130  private final Map<String, CommonAttributeValueList> metadata;
131 
132  CommonAttributeDataSourceNodeFactory(Map<String, CommonAttributeValueList> attributeValues) {
133  this.metadata = new HashMap<>();
134  this.metadata.putAll(attributeValues);
135  }
136 
137  @Override
138  protected boolean createKeys(List<String> list) {
139  list.addAll(this.metadata.keySet());
140  return true;
141  }
142 
143  @Override
144  protected Node createNodeForKey(String dataSourceName) {
145  return new InstanceDataSourceNode(dataSourceName, this.metadata.get(dataSourceName));
146  }
147  }
148 
149 }
final Map< String, CommonAttributeValueList > dataSourceToValueList
InstanceCaseNode(String caseName, Map< String, CommonAttributeValueList > attributeValues)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Wed Sep 28 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.