Autopsy  3.1
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;
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 
62  public T getContent() {
63  return content;
64  }
65 
66  @Override
67  public void setName(String name) {
68  throw new UnsupportedOperationException(
69  NbBundle.getMessage(this.getClass(), "AbstractContentNode.exception.cannotChangeSysName.msg"));
70  }
71 
72  @Override
73  public String getName() {
74  return super.getName();
75  }
76 
83  public boolean hasContentChildren() {
84  boolean hasChildren = false;
85 
86  if (content != null) {
87  try {
88  hasChildren = content.hasChildren();
89  } catch (TskCoreException ex) {
90  logger.log(Level.SEVERE, "Error checking if the node has children, for content: " + content, ex); //NON-NLS
91  }
92  }
93 
94  return hasChildren;
95  }
96 
103  public List<Long> getContentChildrenIds() {
104  List<Long> childrenIds = null;
105 
106  if (content != null) {
107  try {
108  childrenIds = content.getChildrenIds();
109  } catch (TskCoreException ex) {
110  logger.log(Level.SEVERE, "Error getting children ids, for content: " + content, ex); //NON-NLS
111  }
112  }
113 
114  return childrenIds;
115 
116  }
117 
123  public List<Content> getContentChildren() {
124  List<Content> children = null;
125 
126  if (content != null) {
127  try {
128  children = content.getChildren();
129  } catch (TskCoreException ex) {
130  logger.log(Level.SEVERE, "Error getting children, for content: " + content, ex); //NON-NLS
131  }
132  }
133 
134  return children;
135 
136  }
137 
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 
160 
170  public int read(byte[] buf, long offset, long len) throws TskException {
171  return content.read(buf, offset, len);
172  }
173 }
static Logger getLogger(String name)
Definition: Logger.java:131

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.