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

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.