1 | /** |
2 | * BSD-style license; for more info see http://xradar.sourceforge.net/license.html |
3 | */ |
4 | package org.sourceforge.xradar.statics; |
5 | |
6 | import java.util.HashMap; |
7 | import java.util.Map; |
8 | |
9 | /** |
10 | * <p>This class is basic bean designed to contained data |
11 | * describing a Report files coming from PMD, Checkstyle...</p> |
12 | * |
13 | * <p>It basicly contains the filename, the proper xslt to use</p> |
14 | * |
15 | * <p>Use of the other constructor is not compulsory. One |
16 | * may want to create an empty instance and then |
17 | * set it using the appropriate getter/setters.</p> |
18 | * |
19 | * @author rpelisse, belaran@gmail.com |
20 | * |
21 | */ |
22 | public class Report implements Comparable<Report> |
23 | { |
24 | private String file; |
25 | private String mergingFile; |
26 | private String type; |
27 | private int orderId; |
28 | private Map<String,Param> params = new HashMap<String,Param>(0); |
29 | |
30 | public Report(){ |
31 | // Ant need this empty constructor, and as there is an other one, |
32 | // this will not be generated by the compiler. |
33 | } |
34 | /** |
35 | * <p>In order to identify a report, it is handy to be able to construct |
36 | * a report instance with only the orderId.</p> |
37 | * |
38 | * @param orderId, the appropriate orderId. |
39 | */ |
40 | public Report(int orderId) { |
41 | this.orderId = orderId; |
42 | } |
43 | |
44 | /** |
45 | * <p>Most common constructor for a report.</p> |
46 | * <p>Includes a type for the report, and a filename.</p> |
47 | * |
48 | * @param type |
49 | * @param file |
50 | */ |
51 | public Report(String type, String file) { |
52 | this.type = type; |
53 | this.file = file; |
54 | } |
55 | |
56 | /** |
57 | * <p>Basic overides of toString. FIXME: Enhance to output the params.</p> |
58 | */ |
59 | @Override |
60 | public String toString() { |
61 | return "File : " + this.file + ", merging into : " + this.mergingFile + "[orderId:" + this.orderId + ",type:" + this.type + "]"; |
62 | } |
63 | |
64 | /** |
65 | * @return the filename |
66 | */ |
67 | public String getFile() { |
68 | return file; |
69 | } |
70 | /** |
71 | * @param filename the filename to set |
72 | */ |
73 | public void setFile(String filename) { |
74 | this.file = filename; |
75 | } |
76 | /** |
77 | * @return the mergingFile |
78 | */ |
79 | public String getMergingFile() { |
80 | return mergingFile; |
81 | } |
82 | /** |
83 | * @param mergingFile the mergingFile to set |
84 | */ |
85 | public void setMergingFile(String mergingFile) { |
86 | this.mergingFile = mergingFile; |
87 | } |
88 | /** |
89 | * @return the orderId |
90 | */ |
91 | public int getOrderId() { |
92 | return orderId; |
93 | } |
94 | /** |
95 | * @param orderId the orderId to set |
96 | */ |
97 | public void setOrderId(int orderId) { |
98 | this.orderId = orderId; |
99 | } |
100 | |
101 | /** |
102 | * Report are compared solely on their order id |
103 | */ |
104 | public int compareTo(Report o) { |
105 | if ( this.getOrderId() > o.getOrderId() ){ |
106 | return 1; |
107 | } |
108 | else if ( this.getOrderId() < o.getOrderId() ){ |
109 | return -1; |
110 | } |
111 | return 0; |
112 | } |
113 | |
114 | /** |
115 | * Report are considered equals if the have the same orderId. |
116 | * This ensures consistent checking of the order id. |
117 | */ |
118 | @Override |
119 | public boolean equals(Object o) |
120 | { |
121 | boolean result = false; |
122 | if ( o instanceof Report ) { |
123 | Report otherReport = (Report)o; |
124 | if ( this.getOrderId() == otherReport.getOrderId() ) |
125 | result = true; |
126 | } |
127 | return result; |
128 | } |
129 | /** |
130 | * @return the params |
131 | */ |
132 | public Map<String,Param> getParams() { |
133 | return params; |
134 | } |
135 | /** |
136 | * @param params the params to set |
137 | */ |
138 | public void setParams(Map<String,Param> params) { |
139 | this.params = params; |
140 | } |
141 | /** |
142 | * @return the type |
143 | */ |
144 | public String getType() { |
145 | return type; |
146 | } |
147 | /** |
148 | * @param type the type to set |
149 | */ |
150 | public void setType(String type) { |
151 | this.type = type; |
152 | } |
153 | |
154 | } |