Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LinkcheckFile |
|
| 1.7647058823529411;1,765 |
1 | /* | |
2 | =================== DO NOT EDIT THIS FILE ==================== | |
3 | Generated by Modello 1.1 on 2010-11-13 15:27:48, | |
4 | any modifications will be overwritten. | |
5 | ============================================================== | |
6 | */ | |
7 | ||
8 | package org.apache.maven.doxia.linkcheck.model; | |
9 | ||
10 | /** | |
11 | * | |
12 | * The <code><file></code> to be checked. | |
13 | * | |
14 | * | |
15 | * @version $Revision$ $Date$ | |
16 | */ | |
17 | 22 | public class LinkcheckFile |
18 | implements java.io.Serializable | |
19 | { | |
20 | ||
21 | //--------------------------/ | |
22 | //- Class/Member Variables -/ | |
23 | //--------------------------/ | |
24 | ||
25 | /** | |
26 | * | |
27 | * The file to check as String Object. | |
28 | * | |
29 | */ | |
30 | private String absolutePath; | |
31 | ||
32 | /** | |
33 | * | |
34 | * The relative path of the file. | |
35 | * | |
36 | */ | |
37 | private String relativePath; | |
38 | ||
39 | /** | |
40 | * | |
41 | * The number of successful links in this file. | |
42 | * | |
43 | */ | |
44 | 22 | private int successful = -1; |
45 | ||
46 | /** | |
47 | * | |
48 | * The number of unsuccessful links in this file. | |
49 | * | |
50 | */ | |
51 | 22 | private int unsuccessful = -1; |
52 | ||
53 | /** | |
54 | * Field results. | |
55 | */ | |
56 | private java.util.List/*<LinkcheckFileResult>*/ results; | |
57 | ||
58 | ||
59 | //-----------/ | |
60 | //- Methods -/ | |
61 | //-----------/ | |
62 | ||
63 | /** | |
64 | * Method addResult. | |
65 | * | |
66 | * @param linkcheckFileResult | |
67 | */ | |
68 | public void addResult( LinkcheckFileResult linkcheckFileResult ) | |
69 | { | |
70 | 1632 | getResults().add( linkcheckFileResult ); |
71 | 1632 | } //-- void addResult( LinkcheckFileResult ) |
72 | ||
73 | /** | |
74 | * Method equals. | |
75 | * | |
76 | * @param other | |
77 | * @return boolean | |
78 | */ | |
79 | public boolean equals( Object other ) | |
80 | { | |
81 | 0 | if ( this == other ) |
82 | { | |
83 | 0 | return true; |
84 | } | |
85 | ||
86 | 0 | if ( !( other instanceof LinkcheckFile ) ) |
87 | { | |
88 | 0 | return false; |
89 | } | |
90 | ||
91 | 0 | LinkcheckFile that = (LinkcheckFile) other; |
92 | 0 | boolean result = true; |
93 | ||
94 | 0 | result = result && ( getAbsolutePath() == null ? that.getAbsolutePath() == null : getAbsolutePath().equals( that.getAbsolutePath() ) ); |
95 | 0 | result = result && ( getRelativePath() == null ? that.getRelativePath() == null : getRelativePath().equals( that.getRelativePath() ) ); |
96 | 0 | result = result && successful == that.successful; |
97 | 0 | result = result && unsuccessful == that.unsuccessful; |
98 | 0 | result = result && ( getResults() == null ? that.getResults() == null : getResults().equals( that.getResults() ) ); |
99 | ||
100 | 0 | return result; |
101 | } //-- boolean equals( Object ) | |
102 | ||
103 | /** | |
104 | * Get the file to check as String Object. | |
105 | * | |
106 | * @return String | |
107 | */ | |
108 | public String getAbsolutePath() | |
109 | { | |
110 | 1698 | return this.absolutePath; |
111 | } //-- String getAbsolutePath() | |
112 | ||
113 | /** | |
114 | * Get the relative path of the file. | |
115 | * | |
116 | * @return String | |
117 | */ | |
118 | public String getRelativePath() | |
119 | { | |
120 | 66 | return this.relativePath; |
121 | } //-- String getRelativePath() | |
122 | ||
123 | /** | |
124 | * Method getResults. | |
125 | * | |
126 | * @return List | |
127 | */ | |
128 | public java.util.List/*<LinkcheckFileResult>*/ getResults() | |
129 | { | |
130 | 1714 | if ( this.results == null ) |
131 | { | |
132 | 22 | this.results = new java.util.ArrayList/*<LinkcheckFileResult>*/(); |
133 | } | |
134 | ||
135 | 1714 | return this.results; |
136 | } //-- java.util.List/*<LinkcheckFileResult>*/ getResults() | |
137 | ||
138 | /** | |
139 | * Get the number of successful links in this file. | |
140 | * | |
141 | * @return int | |
142 | */ | |
143 | public int getSuccessful() | |
144 | { | |
145 | 108 | return this.successful; |
146 | } //-- int getSuccessful() | |
147 | ||
148 | /** | |
149 | * Get the number of unsuccessful links in this file. | |
150 | * | |
151 | * @return int | |
152 | */ | |
153 | public int getUnsuccessful() | |
154 | { | |
155 | 1618 | return this.unsuccessful; |
156 | } //-- int getUnsuccessful() | |
157 | ||
158 | /** | |
159 | * Method hashCode. | |
160 | * | |
161 | * @return int | |
162 | */ | |
163 | public int hashCode() | |
164 | { | |
165 | 0 | int result = 17; |
166 | ||
167 | 0 | result = 37 * result + ( absolutePath != null ? absolutePath.hashCode() : 0 ); |
168 | 0 | result = 37 * result + ( relativePath != null ? relativePath.hashCode() : 0 ); |
169 | 0 | result = 37 * result + (int) successful; |
170 | 0 | result = 37 * result + (int) unsuccessful; |
171 | 0 | result = 37 * result + ( results != null ? results.hashCode() : 0 ); |
172 | ||
173 | 0 | return result; |
174 | } //-- int hashCode() | |
175 | ||
176 | /** | |
177 | * Method removeResult. | |
178 | * | |
179 | * @param linkcheckFileResult | |
180 | */ | |
181 | public void removeResult( LinkcheckFileResult linkcheckFileResult ) | |
182 | { | |
183 | 0 | getResults().remove( linkcheckFileResult ); |
184 | 0 | } //-- void removeResult( LinkcheckFileResult ) |
185 | ||
186 | /** | |
187 | * Set the file to check as String Object. | |
188 | * | |
189 | * @param absolutePath | |
190 | */ | |
191 | public void setAbsolutePath( String absolutePath ) | |
192 | { | |
193 | 22 | this.absolutePath = absolutePath; |
194 | 22 | } //-- void setAbsolutePath( String ) |
195 | ||
196 | /** | |
197 | * Set the relative path of the file. | |
198 | * | |
199 | * @param relativePath | |
200 | */ | |
201 | public void setRelativePath( String relativePath ) | |
202 | { | |
203 | 22 | this.relativePath = relativePath; |
204 | 22 | } //-- void setRelativePath( String ) |
205 | ||
206 | /** | |
207 | * Set all error details in this file. | |
208 | * | |
209 | * @param results | |
210 | */ | |
211 | public void setResults( java.util.List/*<LinkcheckFileResult>*/ results ) | |
212 | { | |
213 | 0 | this.results = results; |
214 | 0 | } //-- void setResults( java.util.List ) |
215 | ||
216 | /** | |
217 | * Set the number of successful links in this file. | |
218 | * | |
219 | * @param successful | |
220 | */ | |
221 | public void setSuccessful( int successful ) | |
222 | { | |
223 | 82 | this.successful = successful; |
224 | 82 | } //-- void setSuccessful( int ) |
225 | ||
226 | /** | |
227 | * Set the number of unsuccessful links in this file. | |
228 | * | |
229 | * @param unsuccessful | |
230 | */ | |
231 | public void setUnsuccessful( int unsuccessful ) | |
232 | { | |
233 | 1594 | this.unsuccessful = unsuccessful; |
234 | 1594 | } //-- void setUnsuccessful( int ) |
235 | ||
236 | /** | |
237 | * Method toString. | |
238 | * | |
239 | * @return String | |
240 | */ | |
241 | public java.lang.String toString() | |
242 | { | |
243 | 0 | StringBuffer buf = new StringBuffer( 128 ); |
244 | ||
245 | 0 | buf.append( "absolutePath = '" ); |
246 | 0 | buf.append( getAbsolutePath() ); |
247 | 0 | buf.append( "'" ); |
248 | 0 | buf.append( "\n" ); |
249 | 0 | buf.append( "relativePath = '" ); |
250 | 0 | buf.append( getRelativePath() ); |
251 | 0 | buf.append( "'" ); |
252 | 0 | buf.append( "\n" ); |
253 | 0 | buf.append( "successful = '" ); |
254 | 0 | buf.append( getSuccessful() ); |
255 | 0 | buf.append( "'" ); |
256 | 0 | buf.append( "\n" ); |
257 | 0 | buf.append( "unsuccessful = '" ); |
258 | 0 | buf.append( getUnsuccessful() ); |
259 | 0 | buf.append( "'" ); |
260 | 0 | buf.append( "\n" ); |
261 | 0 | buf.append( "results = '" ); |
262 | 0 | buf.append( getResults() ); |
263 | 0 | buf.append( "'" ); |
264 | ||
265 | 0 | return buf.toString(); |
266 | } //-- java.lang.String toString() | |
267 | ||
268 | ||
269 | ||
270 | /** | |
271 | * Get the number of links for this file depending the level wanted. | |
272 | * | |
273 | * {@link LinkcheckFileResult#ERROR_LEVEL} | |
274 | * {@link LinkcheckFileResult#UNKNOWN_LEVEL} | |
275 | * {@link LinkcheckFileResult#VALID_LEVEL} | |
276 | * {@link LinkcheckFileResult#WARNING_LEVEL} | |
277 | * | |
278 | * @param level the restricted level | |
279 | * @return the number of links for the restrict level, -1 if the level is not a valid one | |
280 | * or no results was found. | |
281 | * @throws UnsupportedOperationException if the level is unsupported. | |
282 | */ | |
283 | public int getNumberOfLinks( int level ) | |
284 | { | |
285 | 0 | if ( results == null ) |
286 | { | |
287 | 0 | return -1; |
288 | } | |
289 | ||
290 | 0 | if ( !( level == LinkcheckFileResult.ERROR_LEVEL || level == LinkcheckFileResult.WARNING_LEVEL |
291 | || level == LinkcheckFileResult.VALID_LEVEL || level == LinkcheckFileResult.UNKNOWN_LEVEL ) ) | |
292 | { | |
293 | 0 | throw new UnsupportedOperationException( "This level [" + level + "] is unsupported." ); |
294 | } | |
295 | ||
296 | 0 | int number = 0; |
297 | 0 | for ( java.util.Iterator it = results.iterator(); it.hasNext(); ) |
298 | { | |
299 | 0 | LinkcheckFileResult linkcheckFileResult = (LinkcheckFileResult) it.next(); |
300 | ||
301 | 0 | if ( linkcheckFileResult.getStatusLevel() == level ) |
302 | { | |
303 | 0 | number++; |
304 | } | |
305 | 0 | } |
306 | ||
307 | 0 | return number; |
308 | } | |
309 | ||
310 | /** | |
311 | * Get the number of links for this file. | |
312 | * | |
313 | * @param level | |
314 | * @return | |
315 | */ | |
316 | public int getNumberOfLinks() | |
317 | { | |
318 | 0 | if ( results == null ) |
319 | { | |
320 | 0 | return -1; |
321 | } | |
322 | ||
323 | 0 | return results.size(); |
324 | } | |
325 | ||
326 | ||
327 | } |