001 package org.shiftone.jrat.provider.tree.ui.hierarchy.nodes;
002
003 import org.shiftone.jrat.provider.tree.ui.summary.MethodSummaryModel;
004
005 import java.util.ArrayList;
006 import java.util.Iterator;
007 import java.util.List;
008
009 /**
010 * @author jeff@shiftone.org (Jeff Drost)
011 */
012 public class ClassHierarchyNode extends HierarchyNode {
013
014 private final List childMethods = new ArrayList();
015
016 private int executedMethods;
017 private long totalDurationMs;
018 private long totalMethodDuration;
019 private long totalErrors;
020 private long totalExists;
021
022 public ClassHierarchyNode(String name, MethodSummaryModel methodSummaryModel) {
023 super(name, methodSummaryModel);
024 }
025
026 public void finalizeStatistics() {
027
028 for (Iterator i = childMethods.iterator(); i.hasNext();) {
029 MethodHierarchyNode method = (MethodHierarchyNode) i.next();
030 totalDurationMs += method.getTotalDuration();
031 totalErrors += method.getTotalErrors();
032 totalExists += method.getTotalExits();
033
034 if (method.isExecuted()) {
035 executedMethods++;
036 }
037
038 Long tmd = method.getTotalMethodDuration();
039 if (tmd != null) {
040 totalMethodDuration += tmd.longValue();
041 }
042 }
043 }
044
045 public void addMethod(MethodHierarchyNode methodNode) {
046 childMethods.add(methodNode);
047 }
048
049 public List getChildren() {
050 return childMethods;
051 }
052
053 public int getTotalMethods() {
054 return childMethods.size();
055 }
056
057 public int getExecutedMethods() {
058 return executedMethods;
059 }
060
061 public long getTotalDuration() {
062 return totalDurationMs;
063 }
064
065
066 public long getTotalExits() {
067 return totalExists;
068 }
069
070 public long getTotalErrors() {
071 return totalErrors;
072 }
073
074 public Long getTotalMethodDuration() {
075 return new Long(totalMethodDuration);
076 }
077 }