Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractContentChildren.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import org.openide.nodes.AbstractNode;
22 import org.openide.nodes.Children.Keys;
23 import org.openide.nodes.Node;
24 import org.openide.util.NbBundle;
25 import org.sleuthkit.datamodel.Content;
26 import org.sleuthkit.datamodel.DerivedFile;
27 import org.sleuthkit.datamodel.Directory;
28 import org.sleuthkit.datamodel.File;
29 import org.sleuthkit.datamodel.Image;
30 import org.sleuthkit.datamodel.LayoutFile;
31 import org.sleuthkit.datamodel.LocalFile;
32 import org.sleuthkit.datamodel.SleuthkitItemVisitor;
33 import org.sleuthkit.datamodel.SleuthkitVisitableItem;
34 import org.sleuthkit.datamodel.VirtualDirectory;
35 import org.sleuthkit.datamodel.Volume;
36 
41 abstract class AbstractContentChildren<T> extends Keys<T> {
42 
43  private final CreateSleuthkitNodeVisitor createSleuthkitNodeVisitor = new CreateSleuthkitNodeVisitor();
44  private final CreateAutopsyNodeVisitor createAutopsyNodeVisitor = new CreateAutopsyNodeVisitor();
45 
49  AbstractContentChildren() {
50  super(true); // use lazy behavior
51  }
52 
53  @Override
54  protected Node[] createNodes(T key) {
55  if (key instanceof SleuthkitVisitableItem) {
56  return new Node[]{((SleuthkitVisitableItem) key).accept(createSleuthkitNodeVisitor)};
57  } else {
58  return new Node[]{((AutopsyVisitableItem) key).accept(createAutopsyNodeVisitor)};
59  }
60  }
61 
65  public static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default<AbstractContentNode<? extends Content>> {
66 
67  @Override
69  return new DirectoryNode(drctr);
70  }
71 
72  @Override
74  return new FileNode(file);
75  }
76 
77  @Override
79  return new ImageNode(image);
80  }
81 
82  @Override
84  return new VolumeNode(volume);
85  }
86 
87  @Override
89  return new LayoutFileNode(lf);
90  }
91 
92  @Override
94  return new LocalFileNode(df);
95  }
96 
97  @Override
99  return new LocalFileNode(lf);
100  }
101 
102  @Override
103  public AbstractContentNode<? extends Content> visit(VirtualDirectory ld) {
104  return new VirtualDirectoryNode(ld);
105  }
106 
107  @Override
108  protected AbstractContentNode<? extends Content> defaultVisit(SleuthkitVisitableItem di) {
109  throw new UnsupportedOperationException(NbBundle.getMessage(this.getClass(),
110  "AbstractContentChildren.CreateTSKNodeVisitor.exception.noNodeMsg"));
111  }
112  }
113 
121  static class CreateAutopsyNodeVisitor extends AutopsyItemVisitor.Default<AbstractNode> {
122 
123  @Override
124  public ExtractedContent.RootNode visit(ExtractedContent ec) {
125  return ec.new RootNode(ec.getSleuthkitCase());
126  }
127 
128  @Override
129  public AbstractNode visit(FileTypeExtensionFilters sf) {
130  return new FileTypesNode(sf.getSleuthkitCase(), null);
131  }
132 
133  @Override
134  public AbstractNode visit(RecentFiles rf) {
135  return new RecentFilesNode(rf.getSleuthkitCase());
136  }
137 
138  @Override
139  public AbstractNode visit(DeletedContent dc) {
140  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase());
141  }
142 
143  @Override
144  public AbstractNode visit(FileSize dc) {
145  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase());
146  }
147 
148  @Override
149  public AbstractNode visit(KeywordHits kh) {
150  return kh.new RootNode();
151  }
152 
153  @Override
154  public AbstractNode visit(HashsetHits hh) {
155  return hh.new RootNode();
156  }
157 
158  @Override
159  public AbstractNode visit(InterestingHits ih) {
160  return ih.new RootNode();
161  }
162 
163  @Override
164  public AbstractNode visit(EmailExtracted ee) {
165  return ee.new RootNode();
166  }
167 
168  @Override
169  public AbstractNode visit(Tags tagsNodeKey) {
170  return tagsNodeKey.new RootNode();
171  }
172 
173  @Override
174  public AbstractNode visit(DataSources i) {
175  return new DataSourcesNode();
176  }
177 
178  @Override
179  public AbstractNode visit(Views v) {
180  return new ViewsNode(v.getSleuthkitCase());
181  }
182 
183  @Override
184  public AbstractNode visit(Results r) {
185  return new ResultsNode(r.getSleuthkitCase());
186  }
187 
188  @Override
189  public AbstractNode visit(Reports reportsItem) {
190  return new Reports.ReportsListNode();
191  }
192 
193  @Override
194  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
195  throw new UnsupportedOperationException(
196  NbBundle.getMessage(this.getClass(),
197  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
198  }
199  }
200 }
AbstractContentNode<?extends Content > defaultVisit(SleuthkitVisitableItem di)

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.