View Javadoc

1   package org.apache.maven.jcoveragereport;
2   
3   /* ====================================================================
4    *   Copyright 2001-2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
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             // could happen if the coverage.xml format changes.
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 }