Autopsy  4.8.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CommonAttributeValueNode.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.List;
23 import org.openide.nodes.ChildFactory;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Node;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
31 
37 
38  private final String value;
39  private final int commonFileCount;
40  private final String cases;
41  private final String dataSources;
42 
43  @NbBundle.Messages({
44  "CommonAttributeValueNode.CommonAttributeValueNode.format=Value: %s"
45  })
51  super(Children.create(
52  new FileInstanceNodeFactory(data), true));
53 
54  this.commonFileCount = data.getInstanceCount();
55  this.cases = data.getCases();
56  // @@ We seem to be doing this string concat twice. We also do it in getDataSources()
57  this.dataSources = String.join(", ", data.getDataSources());
58  this.value = data.getValue();
59 
60  this.setDisplayName(String.format(Bundle.CommonAttributeValueNode_CommonAttributeValueNode_format(), this.value));
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
62  }
63 
68  int getCommonFileCount() {
69  return this.commonFileCount;
70  }
71 
72  String getCases(){
73  return this.cases;
74  }
75 
80  String getDataSources() {
81  return this.dataSources;
82  }
83 
88  public String getValue() {
89  return this.value;
90  }
91 
92  @NbBundle.Messages({"Md5Node.createSheet.noDescription= "})
93  @Override
94  protected Sheet createSheet() {
95  Sheet sheet = new Sheet();
96  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
97  if (sheetSet == null) {
98  sheetSet = Sheet.createPropertiesSet();
99  sheet.put(sheetSet);
100  }
101 
102  final String NO_DESCR = Bundle.Md5Node_createSheet_noDescription();
103  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_filesColLbl(), NO_DESCR, ""));
104  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
105  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), NO_DESCR, ""));
106  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, this.getDataSources()));
107 
108  return sheet;
109  }
110 
111 
112  @Override
113  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
114  return visitor.visit(this);
115  }
116 
117  @Override
118  public boolean isLeafTypeNode() {
119  return false;
120  }
121 
122  @Override
123  public String getItemType() {
124  return getClass().getName();
125  }
126 
131  static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
132 
133  private final CommonAttributeValue descendants;
134 
135  FileInstanceNodeFactory(CommonAttributeValue descendants) {
136  this.descendants = descendants;
137  }
138 
139  @Override
140  protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
141  list.addAll(this.descendants.getInstances());
142  return true;
143  }
144 
145  @Override
146  protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
147  return searchResult.generateNodes();
148  }
149 
150 
151  }
152 }
Collection< AbstractCommonAttributeInstance > getInstances()

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.