EMMA Coverage Report (generated Sat Jun 02 16:47:50 EDT 2012)
[all classes][net.sf.madmap]

COVERAGE SUMMARY FOR SOURCE FILE [CumulativeRetainedHeapTableModel.java]

nameclass, %method, %block, %line, %
CumulativeRetainedHeapTableModel.java0%   (0/1)0%   (0/9)0%   (0/233)0%   (0/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CumulativeRetainedHeapTableModel0%   (0/1)0%   (0/9)0%   (0/233)0%   (0/42)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
CumulativeRetainedHeapTableModel (Madmap, ArrayList, long): void 0%   (0/1)0%   (0/106)0%   (0/10)
childrenSummary (int): String 0%   (0/1)0%   (0/9)0%   (0/2)
getColumnClass (int): Class 0%   (0/1)0%   (0/5)0%   (0/1)
getColumnCount (): int 0%   (0/1)0%   (0/4)0%   (0/1)
getColumnName (int): String 0%   (0/1)0%   (0/5)0%   (0/1)
getRowCount (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getStack (int): Vector 0%   (0/1)0%   (0/15)0%   (0/4)
getValueAt (int, int): Object 0%   (0/1)0%   (0/78)0%   (0/21)

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 
15package net.sf.madmap;
16 
17import java.io.*;
18import java.util.*;
19import javax.swing.*;
20 
21/**
22 *
23 *  This class holds the model for the cumulative retained size for all instances of a type
24 *
25 */
26public class CumulativeRetainedHeapTableModel extends MadmapTableModel {
27 
28  ArrayList   _classes;
29  long        _retSizes[];
30  long        _totalLiveSize;
31  int         _rows;
32  
33  private String[] columnNames = {
34    "Type Name",
35    "Type Address",
36    "Instance Count",
37    "Cumulative Retained Size",
38    "Pct of Cum Retained Size"
39  };
40  
41  private Class[] columnType = {
42    (java.lang.Class)((new String("")).getClass()),
43    (java.lang.Class)((new String("")).getClass()),
44    (java.lang.Class)((new Long(0)).getClass()),
45    (java.lang.Class)((new Long(0)).getClass()),
46    (java.lang.Class)((new Double(0.0)).getClass())
47  };
48    
49  public CumulativeRetainedHeapTableModel( Madmap m, ArrayList classes, long liveSize ) {
50          super(m);
51    _classes  = classes;
52    _rows     = _classes.size();
53    _retSizes = new long[_rows];    
54    for( int i = 0; i < _rows; i++ ) {      
55      _retSizes[i] = ((HprofHeapCollectable)_classes.get(i)).getRetainedSize();        
56    }
57    
58    _totalLiveSize  = liveSize;
59  }
60 
61  public Class getColumnClass(int c) {
62    return columnType[c];
63  }
64  
65  public String getColumnName(int col) {
66      return columnNames[col];
67  }
68 
69  public int getColumnCount() { return columnNames.length; }
70  public int getRowCount() { return _rows; }
71 
72  /**
73  * Returns the vector containing the strings of the allocation stack trace recorded in the hprof file.
74  * <p>
75  * Retrieves the object from the list of objects shown in the table, then retrieve the stack trace 
76  * vector from the object.
77  *
78  * @param  row   the row selected by the user in the retained heap table
79  *
80  */
81  public Vector getStack(int row) {
82    String s = new String( "  <no stack trace available>" + "\n" );
83    Vector stk = new Vector();
84    stk.add(s);
85    return stk;
86/*    
87    HprofHeapCollectable hk = (HprofHeapCollectable)_classes.get(row);
88    int stackId = hk.getStackTrace();
89    if ( stackId != 0 ) {
90      HprofStackTraceData std = (HprofStackTraceData) getController().getStackTraces().get(stackId);
91      Vector stk = null;
92      if ( std != null ) { 
93        stk = std.getStackVector();
94      }
95      return stk;
96    } else {
97      return null;
98    }
99*/
100      
101  }
102 
103  /**
104  * Retrieves the object from the list of objects shown in the table 
105  *
106  * @param  row   the row selected by the user in the retained heap table
107  *
108  */
109  public String childrenSummary(int row) {
110    HprofHeapCollectable hk = (HprofHeapCollectable)_classes.get(row);
111    return hk.toString();    
112  }
113 
114  
115  public Object getValueAt(int row, int col) { 
116    Iterator<HprofClassElement>   ihoc3 = _classes.iterator();
117    int i = 0;
118 
119    while( ihoc3.hasNext() ) {
120      HprofClassElement hk = ihoc3.next();
121      long  rs            = _retSizes[i];        
122      double pctLiveSize  = ((double) rs / (double) _totalLiveSize)  *  (double)100.0;
123      
124      if ( i == row ) {
125        if ( col == 0 ) {
126          return new String( hk.className() );
127        } else if ( col == 1 ) {
128          return new String( Long.toHexString(hk.addr()) );
129        } else if ( col == 2 ) {
130          return hk.getInstanceCount();
131        } else if ( col == 3 ) {
132          return rs;
133        } else if ( col == 4 ) {
134          return pctLiveSize;
135        }
136      }
137      i += 1;
138    }
139  
140    assert  true == false : "Should not reach here!" ;
141    return null;
142  }    
143};

[all classes][net.sf.madmap]
EMMA 2.0.5312 (C) Vladimir Roubtsov