Autopsy  4.9.1
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;
37 
42 public final class InstanceCountNode extends DisplayableItemNode {
43 
44  private static final Logger logger = Logger.getLogger(InstanceCountNode.class.getName());
45 
46  final private int instanceCount;
48 
56  @NbBundle.Messages({
57  "InstanceCountNode.displayName=Files with %s instances (%s)"
58  })
59  public InstanceCountNode(int instanceCount, CommonAttributeValueList attributeValues) {
60  super(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true));
61 
62  this.instanceCount = instanceCount;
63  this.attributeValues = attributeValues;
64 
65  this.setDisplayName(String.format(Bundle.InstanceCountNode_displayName(), Integer.toString(instanceCount), attributeValues.getCommonAttributeListSize()));
66  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
67  }
68 
74  int getInstanceCount() {
75  return this.instanceCount;
76  }
77 
82  void createChildren() {
83  attributeValues.displayDelayedMetadata();
84  setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true));
85  }
86 
92  CommonAttributeValueList getAttributeValues() {
93  return this.attributeValues;
94  }
95 
96  @Override
97  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
98  return visitor.visit(this);
99  }
100 
101  @Override
102  public boolean isLeafTypeNode() {
103  return false;
104  }
105 
106  @Override
107  public String getItemType() {
108  return getClass().getName();
109  }
110 
111  @NbBundle.Messages({"InstanceCountNode.createSheet.noDescription= "})
112  @Override
113  protected Sheet createSheet() {
114  Sheet sheet = new Sheet();
115  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
116  if (sheetSet == null) {
117  sheetSet = Sheet.createPropertiesSet();
118  sheet.put(sheetSet);
119  }
120 
121  final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
122  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
123  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), NO_DESCR, ""));
124  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), NO_DESCR, ""));
126  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), NO_DESCR, ""));
127  }
128  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), NO_DESCR, this.getInstanceCount()));
129  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
130  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_caseColLbl(), Bundle.CommonFilesSearchResultsViewerTable_caseColLbl(), NO_DESCR, ""));
131  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, ""));
132  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NO_DESCR, ""));
133 
134  return sheet;
135  }
136 
141  static class CommonAttributeValueNodeFactory extends ChildFactory<String> {
142 
147  // maps sting version of value to value Object (??)
148  private final Map<String, CommonAttributeValue> metadata;
149 
150  CommonAttributeValueNodeFactory(List<CommonAttributeValue> attributeValues) {
151  this.metadata = new HashMap<>();
152 
153  Iterator<CommonAttributeValue> iterator = attributeValues.iterator();
154  while (iterator.hasNext()) {
155  CommonAttributeValue attributeValue = iterator.next();
156  this.metadata.put(attributeValue.getValue(), attributeValue);
157  }
158  }
159 
160  @Override
161  protected boolean createKeys(List<String> list) {
162  // @@@ We should just use CommonAttributeValue as the key...
163  list.addAll(this.metadata.keySet());
164  return true;
165  }
166 
167  @Override
168  protected Node createNodeForKey(String attributeValue) {
169  CommonAttributeValue md5Metadata = this.metadata.get(attributeValue);
170  return new CommonAttributeValueNode(md5Metadata);
171  }
172  }
173 }
InstanceCountNode(int instanceCount, CommonAttributeValueList attributeValues)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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