Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
InstanceDataSourceNode.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 
34 
38 public final class InstanceDataSourceNode extends DisplayableItemNode {
39 
40  private static final Logger logger = Logger.getLogger(InstanceDataSourceNode.class.getName());
41 
42  final private String dataSourceName;
44 
53  public InstanceDataSourceNode(String dataSourceName, CommonAttributeValueList attributeValues) {
54  super(Children.create(new FileInstanceNodeFactory(attributeValues), true));
55 
56  this.dataSourceName = dataSourceName;
57  this.dataSourceToValueList = attributeValues;
58 
59  this.setDisplayName(this.dataSourceName);
60  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/image.png"); //NON-NLS
61  }
62 
68  String getDatasourceName() {
69  return this.dataSourceName;
70  }
71 
76  void createChildren() {
77  dataSourceToValueList.displayDelayedMetadata();
78  setChildren(Children.create(new FileInstanceNodeFactory(dataSourceToValueList), true));
79  }
80 
81  @Override
82  public boolean isLeafTypeNode() {
83  return false;
84  }
85 
86  @Override
87  public String getItemType() {
88  return getClass().getName();
89  }
90 
91  @Override
92  protected Sheet createSheet() {
93  Sheet sheet = new Sheet();
94  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
95  if (sheetSet == null) {
96  sheetSet = Sheet.createPropertiesSet();
97  sheet.put(sheetSet);
98  }
99  final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
100  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
101  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_localPath(), Bundle.CommonFilesSearchResultsViewerTable_localPath(), NO_DESCR, ""));
102  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NO_DESCR, ""));
103  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), NO_DESCR, ""));
104  return sheet;
105  }
106 
107  @Override
108  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
109  return visitor.visit(this);
110  }
111 
116  static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
117 
118  private final CommonAttributeValueList descendants;
119 
120  FileInstanceNodeFactory(CommonAttributeValueList descendants) {
121  this.descendants = descendants;
122  }
123 
124  @Override
125  protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
126  for (CommonAttributeValue value : descendants.getDelayedMetadataList()) {
127  list.addAll(value.getInstances());
128  }
129  return true;
130  }
131 
132  @Override
133  protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
134  return searchResult.generateNodes();
135  }
136 
137  }
138 }
InstanceDataSourceNode(String dataSourceName, 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.