Remove ContentNode.read()

This commit is contained in:
Peter J. Martel 2011-12-08 16:03:45 -05:00
parent cdfe9f00b1
commit 483e5cddf5
7 changed files with 22 additions and 52 deletions

View File

@ -37,7 +37,7 @@ class ThumbnailViewChildren extends FilterNode.Children {
@Override
protected Node copyNode(Node arg0) {
return new ThumbnailViewNode((ContentNode) arg0);
return new ThumbnailViewNode(arg0);
}
@Override

View File

@ -30,8 +30,8 @@ import javax.swing.ImageIcon;
import javax.swing.JFrame;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.logging.Log;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskException;
/**
@ -40,15 +40,13 @@ import org.sleuthkit.datamodel.TskException;
*/
class ThumbnailViewNode extends FilterNode {
private ContentNode currentNode;
// for error handling
private SoftReference<Image> iconCache;
private static Image defaultIcon = new ImageIcon("/org/sleuthkit/autopsy/images/file-icon.png").getImage();
private static final Image defaultIcon = new ImageIcon("/org/sleuthkit/autopsy/images/file-icon.png").getImage();
/** the constructor */
ThumbnailViewNode(ContentNode arg) {
super((Node) arg, Children.LEAF);
this.currentNode = arg;
ThumbnailViewNode(Node arg) {
super(arg, Children.LEAF);
}
@Override
@ -63,24 +61,30 @@ class ThumbnailViewNode extends FilterNode {
if (iconCache != null) {
icon = iconCache.get();
}
if (icon == null) {
try {
System.out.println("generate");
icon = generateIcon();
iconCache = new SoftReference<Image>(icon);
} catch (TskException ex) {
Content content = this.getLookup().lookup(Content.class);
if (content != null) {
try {
System.out.println("generate");
icon = generateIcon(content);
} catch (TskException ex) {
icon = ThumbnailViewNode.defaultIcon;
}
} else {
icon = ThumbnailViewNode.defaultIcon;
}
iconCache = new SoftReference<Image>(icon);
}
return icon;
}
private Image generateIcon() throws TskException {
ContentNode temp = currentNode;
byte[] content = temp.read(0, temp.getContent().getSize());
Image result = Toolkit.getDefaultToolkit().createImage(content);
static private Image generateIcon(Content content) throws TskException {
byte[] data = content.read(0, content.getSize());
Image result = Toolkit.getDefaultToolkit().createImage(data);
// scale the image
MediaTracker mTracker = new MediaTracker(new JFrame());

View File

@ -39,8 +39,6 @@ public class ContentFilterNode extends FilterNode implements ContentNode {
super((Node) original, children, lookup);
}
@Override
public long getID() {
return ((ContentNode) super.getOriginal()).getID();
@ -51,11 +49,6 @@ public class ContentFilterNode extends FilterNode implements ContentNode {
return ((ContentNode) super.getOriginal()).getRowValues(rows);
}
@Override
public byte[] read(long offset, long len) throws TskException {
return ((ContentNode) super.getOriginal()).read(offset, len);
}
@Override
public Content getContent() {
return ((ContentNode) super.getOriginal()).getContent();

View File

@ -55,16 +55,6 @@ public interface ContentNode {
*/
public Object[][] getRowValues(int rows) throws SQLException;
/**
* Reads the content of this node.
*
* @param offset the starting offset
* @param len the length
* @return the bytes
* @throws TskException
*/
public byte[] read(long offset, long len) throws TskException;
/**
* Returns the content of this node.
*

View File

@ -200,11 +200,6 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
return ((ContentNode) currentNode).getRowValues(rows);
}
@Override
public byte[] read(long offset, long len) throws TskException {
return ((ContentNode) currentNode).read(offset, len);
}
@Override
public Content getContent() {
return ((ContentNode) currentNode).getContent();

View File

@ -106,11 +106,6 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
return ((ContentNode) currentNode).getRowValues(rows);
}
@Override
public byte[] read(long offset, long len) throws TskException {
return ((ContentNode) currentNode).read(offset, len);
}
@Override
public Content getContent() {
return ((ContentNode) currentNode).getContent();

View File

@ -83,13 +83,6 @@ class SearchNode extends AbstractNode implements ContentNode {
return objs;
}
@Override
public byte[] read(long offset, long len) throws TskException {
// change this in the future when needed
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Content getContent() {
return null;