1 package org.apache.maven.jcoveragereport;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import java.util.Collection;
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.Map;
24
25 /**
26 * @author Emmanuel Venisse
27 * @version $Id: Clazz.java 377541 2006-02-13 23:54:56Z aheritier $
28 */
29 public class Clazz
30 {
31 private String packageName = "";
32 private String name;
33 private String file;
34 private String lineRate;
35 private String branchRate;
36 private Map lines;
37
38 public Clazz()
39 {
40 lines = new HashMap();
41 }
42
43 public Clazz(String longName)
44 {
45 this();
46 int pos = longName.lastIndexOf(".");
47 if (pos > 0)
48 {
49 packageName = longName.substring(0, pos);
50 name = longName.substring(pos + 1);
51 }
52 else
53 {
54 name = longName;
55 }
56 }
57
58 public void setPackageName(String packageName)
59 {
60 this.packageName = packageName;
61 }
62
63 public String getPackageName()
64 {
65 return packageName;
66 }
67
68 public void setName(String name)
69 {
70 this.name = name;
71 }
72
73 public String getName()
74 {
75 return name;
76 }
77
78 public void setFile(String file)
79 {
80 this.file = file;
81 }
82
83 public String getFile()
84 {
85 return file;
86 }
87
88 public void setLineRate(String lineRate)
89 {
90 this.lineRate = lineRate;
91 }
92
93 public String getLineRate()
94 {
95 return lineRate;
96 }
97
98 public void setBranchRate(String branchRate)
99 {
100 this.branchRate = branchRate;
101 }
102
103 public String getBranchRate()
104 {
105 try
106 {
107 if (new Double(lineRate).doubleValue() == 0.0d)
108 {
109 return new String("0.0");
110 }
111 } catch (NumberFormatException nfe)
112 {
113
114 return new String("0");
115 }
116
117 return branchRate;
118 }
119
120 public void setLines(Collection lines)
121 {
122 for (Iterator iter = lines.iterator(); iter.hasNext(); )
123 {
124 Line line = (Line) iter.next();
125 this.lines.put(new Integer(line.getNumLine()), line);
126 }
127 }
128
129 public Collection getLines()
130 {
131 return lines.values();
132 }
133
134 public void addLine(Line line)
135 {
136 lines.put(new Integer(line.getNumLine()), line);
137 }
138
139 public Map getLinesMap()
140 {
141 return lines;
142 }
143 }