1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sf.madmap;
16
17 import java.io.*;
18 import java.util.*;
19 import java.awt.*;
20 import java.awt.event.*;
21 import javax.swing.*;
22 import javax.swing.filechooser.*;
23
24
25 public class ThreadTableModel extends javax.swing.table.AbstractTableModel {
26 TreeSet threads;
27
28 private String[] columnNames = {
29 "Object Address",
30 "Thread Name",
31 "Hprof ID"
32 };
33
34 private Class[] columnType = {
35 (java.lang.Class)((new String("")).getClass()),
36 (java.lang.Class)((new String("")).getClass()),
37 (java.lang.Class)((new Long(0)).getClass())
38 };
39
40 public ThreadTableModel( TreeSet thdTable ) {
41 threads = thdTable;
42 }
43
44 public Class getColumnClass(int c) {
45 return columnType[c];
46 }
47
48 public String getColumnName(int col) {
49 return columnNames[col];
50 }
51
52 public int getColumnCount() { return columnNames.length; }
53 public int getRowCount() { return threads.size(); }
54
55 public Object getValueAt(int row, int col) {
56 Iterator<HprofThreadData> ihoc3 = threads.iterator();
57 int i = 0;
58
59 while( ihoc3.hasNext() ) {
60 HprofThreadData hk = ihoc3.next();
61
62 if ( i == row ) {
63 if ( col == 0 ) {
64 return Long.toHexString(hk.addr());
65 } else if ( col == 1 ) {
66 return hk.name();
67 } else if ( col == 2 ) {
68 return new Long(hk.id());
69 }
70 }
71
72 i += 1;
73 }
74
75 assert true == false : "Should not reach here!" ;
76 return null;
77 }
78 };