Autopsy  4.1
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;
29 import org.sleuthkit.datamodel.Content;
30 import org.sleuthkit.datamodel.DerivedFile;
31 import org.sleuthkit.datamodel.Directory;
32 import org.sleuthkit.datamodel.File;
33 import org.sleuthkit.datamodel.Image;
34 import org.sleuthkit.datamodel.LayoutFile;
35 import org.sleuthkit.datamodel.LocalFile;
36 import org.sleuthkit.datamodel.SleuthkitItemVisitor;
37 import org.sleuthkit.datamodel.SleuthkitVisitableItem;
38 import org.sleuthkit.datamodel.VirtualDirectory;
39 import org.sleuthkit.datamodel.Volume;
40 
45 abstract class AbstractContentChildren<T> extends Keys<T> {
46 
47  private final CreateSleuthkitNodeVisitor createSleuthkitNodeVisitor = new CreateSleuthkitNodeVisitor();
48  private final CreateAutopsyNodeVisitor createAutopsyNodeVisitor = new CreateAutopsyNodeVisitor();
49 
53  AbstractContentChildren() {
54  super(true); // use lazy behavior
55  }
56 
57  @Override
58  protected Node[] createNodes(T key) {
59  if (key instanceof SleuthkitVisitableItem) {
60  return new Node[]{((SleuthkitVisitableItem) key).accept(createSleuthkitNodeVisitor)};
61  } else {
62  return new Node[]{((AutopsyVisitableItem) key).accept(createAutopsyNodeVisitor)};
63  }
64  }
65 
69  public static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default<AbstractContentNode<? extends Content>> {
70 
71  @Override
73  return new DirectoryNode(drctr);
74  }
75 
76  @Override
78  return new FileNode(file);
79  }
80 
81  @Override
83  return new ImageNode(image);
84  }
85 
86  @Override
88  return new VolumeNode(volume);
89  }
90 
91  @Override
93  return new LayoutFileNode(lf);
94  }
95 
96  @Override
98  return new LocalFileNode(df);
99  }
100 
101  @Override
103  return new LocalFileNode(lf);
104  }
105 
106  @Override
107  public AbstractContentNode<? extends Content> visit(VirtualDirectory ld) {
108  return new VirtualDirectoryNode(ld);
109  }
110 
111  @Override
112  protected AbstractContentNode<? extends Content> defaultVisit(SleuthkitVisitableItem di) {
113  throw new UnsupportedOperationException(NbBundle.getMessage(this.getClass(),
114  "AbstractContentChildren.CreateTSKNodeVisitor.exception.noNodeMsg"));
115  }
116  }
117 
125  static class CreateAutopsyNodeVisitor extends AutopsyItemVisitor.Default<AbstractNode> {
126 
127  @Override
128  public ExtractedContent.RootNode visit(ExtractedContent ec) {
129  return ec.new RootNode(ec.getSleuthkitCase());
130  }
131 
132  @Override
133  public AbstractNode visit(FileTypeExtensionFilters sf) {
134  return new FileTypesNode(sf.getSleuthkitCase(), null);
135  }
136 
137  @Override
138  public AbstractNode visit(RecentFiles rf) {
139  return new RecentFilesNode(rf.getSleuthkitCase());
140  }
141 
142  @Override
143  public AbstractNode visit(DeletedContent dc) {
144  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase());
145  }
146 
147  @Override
148  public AbstractNode visit(FileSize dc) {
149  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase());
150  }
151 
152  @Override
153  public AbstractNode visit(KeywordHits kh) {
154  return kh.new RootNode();
155  }
156 
157  @Override
158  public AbstractNode visit(HashsetHits hh) {
159  return hh.new RootNode();
160  }
161 
162  @Override
163  public AbstractNode visit(InterestingHits ih) {
164  return ih.new RootNode();
165  }
166 
167  @Override
168  public AbstractNode visit(EmailExtracted ee) {
169  return ee.new RootNode();
170  }
171 
172  @Override
173  public AbstractNode visit(Tags tagsNodeKey) {
174  return tagsNodeKey.new RootNode();
175  }
176 
177  @Override
178  public AbstractNode visit(DataSources i) {
179  return new DataSourcesNode();
180  }
181 
182  @Override
183  public AbstractNode visit(Views v) {
184  return new ViewsNode(v.getSleuthkitCase());
185  }
186 
187  @Override
188  public AbstractNode visit(Results r) {
189  return new ResultsNode(r.getSleuthkitCase());
190  }
191 
192  @Override
193  public AbstractNode visit(Reports reportsItem) {
194  return new Reports.ReportsListNode();
195  }
196 
197  @Override
198  public AbstractNode visit(Accounts accountsItem) {
199  return accountsItem.new AccountsRootNode();
200  }
201 
202  @Override
203  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
204  throw new UnsupportedOperationException(
205  NbBundle.getMessage(this.getClass(),
206  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
207  }
208  }
209 }
AbstractContentNode<?extends Content > defaultVisit(SleuthkitVisitableItem di)

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.