Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractContentNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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 java.util.List;
22 import java.util.logging.Level;
23 
24 import org.openide.util.NbBundle;
25 import org.openide.util.lookup.Lookups;
27 import org.sleuthkit.datamodel.Content;
28 import org.sleuthkit.datamodel.TskCoreException;
29 import org.sleuthkit.datamodel.TskException;
30 
37 public abstract class AbstractContentNode<T extends Content> extends ContentNode {
38 
42  T content;
43  private static final Logger logger = Logger.getLogger(AbstractContentNode.class.getName());
44 
50  AbstractContentNode(T content) {
51  //TODO consider child factory for the content children
52  super(new ContentChildren(content), Lookups.singleton(content));
53  this.content = content;
54  //super.setName(ContentUtils.getSystemName(content));
55  super.setName("content_" + Long.toString(content.getId())); //NON-NLS
56  }
57 
63  public T getContent() {
64  return content;
65  }
66 
67  @Override
68  public void setName(String name) {
69  throw new UnsupportedOperationException(
70  NbBundle.getMessage(this.getClass(), "AbstractContentNode.exception.cannotChangeSysName.msg"));
71  }
72 
73  @Override
74  public String getName() {
75  return super.getName();
76  }
77 
84  public boolean hasContentChildren() {
85  boolean hasChildren = false;
86 
87  if (content != null) {
88  try {
89  hasChildren = content.hasChildren();
90  } catch (TskCoreException ex) {
91  logger.log(Level.SEVERE, "Error checking if the node has children, for content: " + content, ex); //NON-NLS
92  }
93  }
94 
95  return hasChildren;
96  }
97 
104  public List<Long> getContentChildrenIds() {
105  List<Long> childrenIds = null;
106 
107  if (content != null) {
108  try {
109  childrenIds = content.getChildrenIds();
110  } catch (TskCoreException ex) {
111  logger.log(Level.SEVERE, "Error getting children ids, for content: " + content, ex); //NON-NLS
112  }
113  }
114 
115  return childrenIds;
116 
117  }
118 
124  public List<Content> getContentChildren() {
125  List<Content> children = null;
126 
127  if (content != null) {
128  try {
129  children = content.getChildren();
130  } catch (TskCoreException ex) {
131  logger.log(Level.SEVERE, "Error getting children, for content: " + content, ex); //NON-NLS
132  }
133  }
134 
135  return children;
136 
137  }
138 
146  public int getContentChildrenCount() {
147  int childrenCount = -1;
148 
149  if (content != null) {
150  try {
151  childrenCount = content.getChildrenCount();
152  } catch (TskCoreException ex) {
153  logger.log(Level.SEVERE, "Error checking node content children count, for content: " + content, ex); //NON-NLS
154  }
155  }
156 
157  return childrenCount;
158  }
159 
172  public int read(byte[] buf, long offset, long len) throws TskException {
173  return content.read(buf, offset, len);
174  }
175 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

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.