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

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.