Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
InstanceCountNode.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.commonfilesearch;
21 
22 import java.util.HashMap;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Map;
26 import org.openide.nodes.ChildFactory;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Node;
29 import org.openide.nodes.Sheet;
30 import org.openide.util.NbBundle;
35 
40 final public class InstanceCountNode extends DisplayableItemNode {
41 
42  private static final Logger logger = Logger.getLogger(InstanceCountNode.class.getName());
43 
44  final private int instanceCount;
46 
54  @NbBundle.Messages({
55  "InstanceCountNode.displayName=Files with %s instances (%s)"
56  })
57  public InstanceCountNode(int instanceCount, CommonAttributeValueList attributeValues) {
58  super(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true));
59 
60  this.instanceCount = instanceCount;
61  this.attributeValues = attributeValues;
62 
63  this.setDisplayName(String.format(Bundle.InstanceCountNode_displayName(), Integer.toString(instanceCount), attributeValues.getCommonAttributeListSize()));
64  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
65  }
66 
72  int getInstanceCount() {
73  return this.instanceCount;
74  }
75 
81  public void refresh() {
82  attributeValues.displayDelayedMetadata();
83  setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true));
84  }
85 
91  CommonAttributeValueList getAttributeValues() {
92  return this.attributeValues;
93  }
94 
95  @Override
96  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
97  return visitor.visit(this);
98  }
99 
100  @Override
101  public boolean isLeafTypeNode() {
102  return false;
103  }
104 
105  @Override
106  public String getItemType() {
107  return getClass().getName();
108  }
109 
110  @NbBundle.Messages({"InstanceCountNode.createSheet.noDescription= "})
111  @Override
112  protected Sheet createSheet() {
113  Sheet sheet = new Sheet();
114  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
115  if (sheetSet == null) {
116  sheetSet = Sheet.createPropertiesSet();
117  sheet.put(sheetSet);
118  }
119 
120  final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
121  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), NO_DESCR, ""));
122  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), NO_DESCR, this.getInstanceCount()));
123  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
124  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_caseColLbl1(), Bundle.CommonFilesSearchResultsViewerTable_caseColLbl1(), NO_DESCR, ""));
125  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, ""));
126  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), NO_DESCR, ""));
127  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_mimeTypeColLbl(), Bundle.CommonFilesSearchResultsViewerTable_mimeTypeColLbl(), NO_DESCR, ""));
128  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), NO_DESCR, ""));
129 
130  return sheet;
131  }
132 
137  static class CommonAttributeValueNodeFactory extends ChildFactory<String> {
138 
143  // maps sting version of value to value Object (??)
144  private final Map<String, CommonAttributeValue> metadata;
145 
146  CommonAttributeValueNodeFactory(List<CommonAttributeValue> attributeValues) {
147  this.metadata = new HashMap<>();
148 
149  Iterator<CommonAttributeValue> iterator = attributeValues.iterator();
150  while (iterator.hasNext()) {
151  CommonAttributeValue attributeValue = iterator.next();
152  this.metadata.put(attributeValue.getValue(), attributeValue);
153  }
154  }
155 
156  @Override
157  protected boolean createKeys(List<String> list) {
158  // @@@ We should just use CommonAttributeValue as the key...
159  list.addAll(this.metadata.keySet());
160  return true;
161  }
162 
163  @Override
164  protected Node createNodeForKey(String attributeValue) {
165  CommonAttributeValue md5Metadata = this.metadata.get(attributeValue);
166  return new CommonAttributeValueNode(md5Metadata);
167  }
168  }
169 }
InstanceCountNode(int instanceCount, CommonAttributeValueList attributeValues)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.