1 package org.codehaus.mojo.dashboard.report.plugin.beans;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import java.util.Date;
21 import java.util.HashMap;
22 import java.util.Iterator;
23 import java.util.Map;
24
25
26
27
28
29 public class TagListReportBean extends AbstractReportBean
30 {
31
32
33
34 private Map tags = new HashMap();
35
36
37
38 private int nbTotal = 0;
39
40
41
42
43 private int nbClasses;
44
45
46
47
48 public TagListReportBean()
49 {
50
51 }
52
53
54
55
56
57 public TagListReportBean( Date dateGeneration )
58 {
59 super( dateGeneration );
60 }
61
62 public Map getTags()
63 {
64 return tags;
65 }
66
67 public void setTag( String name, Integer count )
68 {
69 tags.put( name, count );
70 this.nbTotal = this.nbTotal + count.intValue();
71 }
72
73
74
75
76 public void addAllEntries( Map entries )
77 {
78 if ( this.tags.isEmpty() )
79 {
80 this.tags.putAll( entries );
81 }
82 else
83 {
84 Iterator iter = entries.keySet().iterator();
85 while ( iter.hasNext() )
86 {
87 String key = (String) iter.next();
88 Integer newValuetoAdd = ( (Integer) ( entries.get( key ) ) );
89 if ( ( this.tags.containsKey( key ) ) )
90 {
91 Integer oldCount = (Integer) tags.get( key );
92 this.tags.put( key, new Integer( oldCount.intValue() + newValuetoAdd.intValue() ) );
93 }
94 else
95 {
96 tags.put( key, newValuetoAdd );
97 }
98 }
99 }
100 }
101
102
103
104
105
106 public void merge( IDashBoardReportBean dashboardReport )
107 {
108
109 if ( dashboardReport != null && dashboardReport instanceof TagListReportBean )
110 {
111 this.nbTotal = this.nbTotal + ( (TagListReportBean) dashboardReport ).getNbTotal();
112 this.nbClasses = this.nbClasses + ( (TagListReportBean) dashboardReport ).getNbClasses();
113 this.addAllEntries(((TagListReportBean)dashboardReport).getTags());
114 }
115
116
117 }
118
119
120
121
122 protected Object clone()
123 {
124 TagListReportBean clone = new TagListReportBean( this.getDateGeneration() );
125 clone.setNbTotal(this.nbTotal);
126 clone.setNbClasses(this.nbClasses);
127 clone.addAllEntries( this.tags );
128 return clone;
129 }
130
131 public int getNbTotal() {
132 return nbTotal;
133 }
134
135 public void setNbTotal(int nbTotal) {
136 this.nbTotal = nbTotal;
137 }
138
139 public int getNbClasses() {
140 return nbClasses;
141 }
142
143 public void setNbClasses(int nbClasses) {
144 this.nbClasses = nbClasses;
145 }
146 }