30 package org.sleuthkit.autopsy.examples;
32 import java.awt.Component;
33 import org.openide.nodes.Node;
47 @SuppressWarnings(
"PMD.SingularField")
48 class SampleContentViewer
extends javax.swing.JPanel implements
DataContentViewer {
53 public SampleContentViewer() {
62 @SuppressWarnings(
"unchecked")
64 private void initComponents() {
66 jLabel1 =
new javax.swing.JLabel();
68 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(SampleContentViewer.class,
"SampleContentViewer.jLabel1.text"));
70 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
71 this.setLayout(layout);
72 layout.setHorizontalGroup(
73 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74 .addGroup(layout.createSequentialGroup()
76 .addComponent(jLabel1)
77 .addContainerGap(339, Short.MAX_VALUE))
79 layout.setVerticalGroup(
80 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
81 .addGroup(layout.createSequentialGroup()
83 .addComponent(jLabel1)
84 .addContainerGap(266, Short.MAX_VALUE))
88 private javax.swing.JLabel jLabel1;
92 public void setNode(Node selectedNode) {
95 if (selectedNode == null) {
100 Content content = selectedNode.getLookup().lookup(Content.class);
101 if (content == null) {
107 setText(
"Doing Analysis");
108 byte buffer[] =
new byte[1024];
109 int len = content.read(buffer, 0, 1024);
111 for (
int i = 0; i < len; i++) {
112 if (buffer[i] == 0x00) {
116 setText(count +
" out of " + len +
" bytes were 0x00");
117 }
catch (TskCoreException ex) {
118 setText(
"Error reading file: " + ex.getLocalizedMessage());
123 private void setText(String str) {
124 jLabel1.setText(str);
128 public String getTitle() {
133 public String getToolTip() {
134 return "Useless module";
139 return new SampleContentViewer();
143 public Component getComponent() {
149 public void resetComponent() {
154 public boolean isSupported(Node node) {
156 Content content = node.getLookup().lookup(Content.class);
157 if (content == null) {
162 if (content.getSize() < 1024) {
169 public int isPreferred(Node node) {