Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
HTTPLinkValidationResult |
|
| 1.0;1 |
1 | package org.apache.maven.doxia.linkcheck.validation; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | /** | |
23 | * This class is used to return HTTP status responses from the validation handlers. | |
24 | * | |
25 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
26 | * @version $Id: HTTPLinkValidationResult.java 638289 2008-03-18 09:44:10Z bentmann $ | |
27 | */ | |
28 | public class HTTPLinkValidationResult | |
29 | extends LinkValidationResult | |
30 | { | |
31 | /** serialVersionUID. */ | |
32 | static final long serialVersionUID = 3541710617127916373L; | |
33 | ||
34 | /** The httpStatusCode. */ | |
35 | private final int httpStatusCode; | |
36 | ||
37 | /** | |
38 | * Constructor: initializes status, persistent and errorMessage. | |
39 | * Using this constructor, the HTTP status code is by default <code>-1</code>. | |
40 | * | |
41 | * @param stat The status. | |
42 | * @param persistent The persistent. | |
43 | * @param message The errorMessage. | |
44 | */ | |
45 | public HTTPLinkValidationResult( int stat, boolean persistent, String message ) | |
46 | { | |
47 | 0 | super( stat, persistent, message ); |
48 | ||
49 | 0 | this.httpStatusCode = -1; |
50 | 0 | } |
51 | ||
52 | /** | |
53 | * Constructor: initializes status, persistent, httpStatusCode and errorMessage. | |
54 | * | |
55 | * @param stat The status. | |
56 | * @param persistent The persistent. | |
57 | * @param httpStatusCode The httpStatusCode returned. | |
58 | * @param message The errorMessage. | |
59 | */ | |
60 | public HTTPLinkValidationResult( int stat, boolean persistent, int httpStatusCode, String message ) | |
61 | { | |
62 | 2 | super( stat, persistent, message ); |
63 | ||
64 | 2 | this.httpStatusCode = httpStatusCode; |
65 | 2 | } |
66 | ||
67 | /** {@inheritDoc} */ | |
68 | public String getErrorMessage() | |
69 | { | |
70 | 2 | return this.httpStatusCode + " " + super.getErrorMessage(); |
71 | } | |
72 | ||
73 | /** | |
74 | * Returns the httpStatusCode. | |
75 | * | |
76 | * @return int | |
77 | */ | |
78 | public int getHttpStatusCode() | |
79 | { | |
80 | 0 | return this.httpStatusCode; |
81 | } | |
82 | ||
83 | /** {@inheritDoc} */ | |
84 | public String toString() | |
85 | { | |
86 | 0 | StringBuffer sb = new StringBuffer( super.toString() ); |
87 | ||
88 | 0 | sb.append( '\n' ); |
89 | 0 | sb.append( "httpStatusCode=" ).append( this.httpStatusCode ); |
90 | ||
91 | 0 | return sb.toString(); |
92 | } | |
93 | } |