1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.transformation.linkchecker

File LinkState.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

6
16
7
1
127
60
10
0.62
2.29
7
1.43

Classes

Class Line # Actions
LinkState 34 16 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 11 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.transformation.linkchecker;
21   
22    import java.util.Map;
23   
24    import org.apache.commons.lang3.builder.EqualsBuilder;
25    import org.apache.commons.lang3.builder.HashCodeBuilder;
26   
27    /**
28    * Represents a Link State, ie the HTTP response code when the link was checked, the time when the link was last
29    * checked and context data.
30    *
31    * @version $Id: 74532a1e08cd47b3944308c508a7f4f0a42591fc $
32    * @since 3.3M1
33    */
 
34    public class LinkState
35    {
36    /**
37    * @see #getResponseCode()
38    */
39    private int responseCode;
40   
41    /**
42    * @see #getLastCheckedTime()
43    */
44    private long lastCheckedTime;
45   
46    /**
47    * @see #getContextData()
48    */
49    private Map<String, Object> contextData;
50   
51    /**
52    * @param responseCode see {@link #getResponseCode()}
53    * @param lastCheckedTime see {@link #getLastCheckedTime()}
54    * @param contextData see {@link #getContextData()}
55    */
 
56  13 toggle public LinkState(int responseCode, long lastCheckedTime, Map<String, Object> contextData)
57    {
58  13 this(responseCode, lastCheckedTime);
59  13 this.contextData = contextData;
60    }
61   
62    /**
63    * @param responseCode see {@link #getResponseCode()}
64    * @param lastCheckedTime see {@link #getLastCheckedTime()}
65    */
 
66  20 toggle public LinkState(int responseCode, long lastCheckedTime)
67    {
68  20 this.responseCode = responseCode;
69  20 this.lastCheckedTime = lastCheckedTime;
70    }
71   
72    /**
73    * @return the time when the link was last checked
74    */
 
75  8 toggle public long getLastCheckedTime()
76    {
77  8 return this.lastCheckedTime;
78    }
79   
80    /**
81    * @return the HTTP response code when the link was checked
82    */
 
83  10 toggle public int getResponseCode()
84    {
85  10 return this.responseCode;
86    }
87   
88    /**
89    * @return the context data associated with the content reference. What gets put in the Context Data Map depends
90    * purely on implementations of
91    * {@link org.xwiki.rendering.transformation.linkchecker.LinkContextDataProvider}
92    */
 
93  5 toggle public Map<String, Object> getContextData()
94    {
95  5 return this.contextData;
96    }
97   
 
98  4 toggle @Override
99    public boolean equals(Object object)
100    {
101  4 if (object == null) {
102  1 return false;
103    }
104  3 if (object == this) {
105  1 return true;
106    }
107  2 if (object.getClass() != getClass()) {
108  1 return false;
109    }
110  1 LinkState rhs = (LinkState) object;
111  1 return new EqualsBuilder()
112    .append(getResponseCode(), rhs.getResponseCode())
113    .append(getLastCheckedTime(), rhs.getLastCheckedTime())
114    .append(getContextData(), rhs.getContextData())
115    .isEquals();
116    }
117   
 
118  2 toggle @Override
119    public int hashCode()
120    {
121  2 return new HashCodeBuilder(9, 15)
122    .append(getResponseCode())
123    .append(getLastCheckedTime())
124    .append(getContextData())
125    .toHashCode();
126    }
127    }