View Javadoc

1   package org.apache.maven.plugin.linkcheck;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import org.apache.commons.lang.StringEscapeUtils;
22  
23  /**
24   * An class containing the results of a single check of a link.
25   * 
26   * @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
27   * @author <a href="mailto:aheritier@apache.org">Arnaud Heritier</a>
28   * @version $Id: LinkCheckResult.java 532339 2007-04-25 12:28:56Z ltheussl $
29   */
30  public final class LinkCheckResult
31  {
32      private String status;
33  
34      private String target;
35  
36      private String errorMessage;
37  
38      /**
39       * Returns the status.
40       * 
41       * @return String
42       */
43      public String getStatus()
44      {
45          return this.status;
46      }
47  
48      /**
49       * Sets the status.
50       * 
51       * @param status
52       *            The status to set
53       */
54      public void setStatus( String status )
55      {
56          this.status = status;
57      }
58  
59      /**
60       * Returns the target.
61       * 
62       * @return String
63       */
64      public String getTarget()
65      {
66          return this.target;
67      }
68  
69      /**
70       * Sets the target.
71       * 
72       * @param target
73       *            The target to set
74       */
75      public void setTarget( String target )
76      {
77          this.target = target;
78      }
79  
80      /**
81       * @return Returns the errorMessage.
82       */
83      public String getErrorMessage()
84      {
85          return this.errorMessage;
86      }
87  
88      /**
89       * @param errorMessage
90       *            The errorMessage to set.
91       */
92      public void setErrorMessage( String errorMessage )
93      {
94          this.errorMessage = errorMessage;
95      }
96  
97      /**
98       * Creates an XML representation of this link check result
99       * 
100      * @return xml fragment representation of this result
101      */
102     public String toXML()
103     {
104         StringBuffer buf = new StringBuffer();
105         buf.append( "    <result>\n" );
106         buf.append( "      <target>" + StringEscapeUtils.escapeXml( getTarget() ) + "</target>\n" );
107         buf.append( "      <status>" + getStatus() + "</status>\n" );
108         buf.append( "      <errorMessage>" + StringEscapeUtils.escapeXml( getErrorMessage() ) + "</errorMessage>\n" );
109         buf.append( "    </result>\n" );
110         return buf.toString();
111     }
112 
113 }