Autopsy  3.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.Exceptions;
25 import org.openide.util.NbBundle;
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
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  try {
180  return new DataSourcesNode(Case.getCurrentCase().getDataSources());
181  } catch (TskCoreException ex) {
182  return defaultVisit(i);
183  }
184  }
185 
186  @Override
187  public AbstractNode visit(Views v) {
188  return new ViewsNode(v.getSleuthkitCase());
189  }
190 
191  @Override
192  public AbstractNode visit(Results r) {
193  return new ResultsNode(r.getSleuthkitCase());
194  }
195 
196  @Override
197  public AbstractNode visit(Reports reportsItem) {
198  return new Reports.ReportsListNode();
199  }
200 
201  @Override
202  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
203  throw new UnsupportedOperationException(
204  NbBundle.getMessage(this.getClass(),
205  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
206  }
207  }
208 }
AbstractContentNode<?extends Content > defaultVisit(SleuthkitVisitableItem di)

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