1 | /* |
2 | * Copyright 2008 Eric Caspole |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
5 | * file except in compliance with the License. You may obtain a copy of the License at |
6 | * |
7 | * http://www.apache.org/licenses/LICENSE-2.0 |
8 | * |
9 | * Unless required by applicable law or agreed to in writing, software distributed under |
10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
11 | * KIND, either express or implied. See the License for the specific language governing |
12 | * permissions and limitations under the License. |
13 | */ |
14 | package net.sf.madmap; |
15 | |
16 | import java.io.*; |
17 | import java.util.*; |
18 | import java.awt.*; |
19 | import java.awt.event.*; |
20 | import javax.swing.*; |
21 | import javax.swing.filechooser.*; |
22 | |
23 | |
24 | public class FinalizerTableModel extends javax.swing.table.AbstractTableModel { |
25 | |
26 | java.util.List<HprofClassElement> heap; |
27 | long totalLiveSize; |
28 | |
29 | private String[] columnNames = { |
30 | "Type", |
31 | "Size", |
32 | "Count" |
33 | }; |
34 | |
35 | private Class[] columnType = { |
36 | (java.lang.Class)((new String("")).getClass()), |
37 | (java.lang.Class)((new Long(0)).getClass()), |
38 | (java.lang.Class)((new Long(0)).getClass()) |
39 | }; |
40 | |
41 | public FinalizerTableModel( java.util.List<HprofClassElement> fList ) { |
42 | heap = fList; |
43 | } |
44 | |
45 | public Class getColumnClass(int c) { |
46 | return columnType[c]; |
47 | } |
48 | |
49 | public String getColumnName(int col) { |
50 | return columnNames[col]; |
51 | } |
52 | |
53 | public int getColumnCount() { return columnNames.length; } |
54 | public int getRowCount() { return heap.size(); } |
55 | |
56 | public Object getValueAt(int row, int col) { |
57 | Iterator<HprofClassElement> ihoc3 = heap.iterator(); |
58 | int i = 0; |
59 | |
60 | while( ihoc3.hasNext() ) { |
61 | HprofClassElement hk = ihoc3.next(); |
62 | |
63 | if ( i == row ) { |
64 | if ( col == 0 ) { |
65 | return new String( hk.className() + "@" + Long.toHexString(hk.addr()) ); |
66 | } else if ( col == 1 ) { |
67 | return hk.getFinalizableSize(); |
68 | } else if ( col == 2 ) { |
69 | return hk.getFinalizableCount(); |
70 | } |
71 | } |
72 | |
73 | i += 1; |
74 | } |
75 | |
76 | assert true == false : "Should not reach here!" ; |
77 | return null; |
78 | } |
79 | }; |