30 package org.sleuthkit.autopsy.examples;
32 import java.awt.Component;
33 import org.openide.nodes.Node;
48 @SuppressWarnings(
"PMD.SingularField")
49 class SampleContentViewer
extends javax.swing.JPanel implements
DataContentViewer {
54 public SampleContentViewer() {
63 @SuppressWarnings(
"unchecked")
65 private void initComponents() {
67 jLabel1 =
new javax.swing.JLabel();
69 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(SampleContentViewer.class,
"SampleContentViewer.jLabel1.text"));
71 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
72 this.setLayout(layout);
73 layout.setHorizontalGroup(
74 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
75 .addGroup(layout.createSequentialGroup()
77 .addComponent(jLabel1)
78 .addContainerGap(339, Short.MAX_VALUE))
80 layout.setVerticalGroup(
81 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
82 .addGroup(layout.createSequentialGroup()
84 .addComponent(jLabel1)
85 .addContainerGap(266, Short.MAX_VALUE))
89 private javax.swing.JLabel jLabel1;
93 public void setNode(Node selectedNode) {
96 if (selectedNode == null) {
101 Content content = selectedNode.getLookup().lookup(Content.class);
102 if (content == null) {
108 setText(
"Doing Analysis");
109 byte buffer[] =
new byte[1024];
110 int len = content.read(buffer, 0, 1024);
112 for (
int i = 0; i < len; i++) {
113 if (buffer[i] == 0x00) {
117 setText(count +
" out of " + len +
" bytes were 0x00");
118 }
catch (TskCoreException ex) {
119 setText(
"Error reading file: " + ex.getLocalizedMessage());
124 private void setText(String str) {
125 jLabel1.setText(str);
129 public String getTitle() {
134 public String getToolTip() {
135 return "Useless module";
140 return new SampleContentViewer();
144 public Component getComponent() {
150 public void resetComponent() {
155 public boolean isSupported(Node node) {
157 Content content = node.getLookup().lookup(Content.class);
158 if (content == null) {
163 if (content.getSize() < 1024) {
170 public int isPreferred(Node node) {