Autopsy  4.9.1
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;
32 
38 
39  private final String value;
40  private final int commonFileCount;
41  private final String cases;
42  private final String dataSources;
43 
44  @NbBundle.Messages({
45  "CommonAttributeValueNode.CommonAttributeValueNode.format=Value: %s"
46  })
53  super(Children.create(
54  new FileInstanceNodeFactory(data), true));
55  this.commonFileCount = data.getInstanceCount();
56  this.cases = data.getCases();
57  // @@ We seem to be doing this string concat twice. We also do it in getDataSources()
58  this.dataSources = String.join(", ", data.getDataSources());
59  this.value = data.getValue();
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 
69  int getCommonFileCount() {
70  return this.commonFileCount;
71  }
72 
73  String getCases() {
74  return this.cases;
75  }
76 
82  String getDataSources() {
83  return this.dataSources;
84  }
85 
91  public String getValue() {
92  return this.value;
93  }
94 
95  @NbBundle.Messages({
96  "ValueNode.createSheet.noDescription= "
97  })
98  @Override
99  protected Sheet createSheet() {
100  Sheet sheet = new Sheet();
101  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
102  if (sheetSet == null) {
103  sheetSet = Sheet.createPropertiesSet();
104  sheet.put(sheetSet);
105  }
106 
107  final String NO_DESCR = Bundle.ValueNode_createSheet_noDescription();
108  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
109  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
110  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, this.getDataSources()));
111 
112  return sheet;
113  }
114 
115  @Override
116  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
117  return visitor.visit(this);
118  }
119 
120  @Override
121  public boolean isLeafTypeNode() {
122  return false;
123  }
124 
125  @Override
126  public String getItemType() {
127  return getClass().getName();
128  }
129 
134  static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
135 
136  private final CommonAttributeValue descendants;
137 
138  FileInstanceNodeFactory(CommonAttributeValue descendants) {
139  this.descendants = descendants;
140  }
141 
142  @Override
143  protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
144  list.addAll(this.descendants.getInstances());
145  return true;
146  }
147 
148  @Override
149  protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
150  return searchResult.generateNodes();
151  }
152 
153  }
154 }
Collection< AbstractCommonAttributeInstance > getInstances()

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.