1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.parser.xhtml.wikimodel

File XWikiWikiReference.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart3.png
82% of files have more coverage

Code metrics

4
19
5
1
93
50
7
0.37
3.8
5
1.4

Classes

Class Line # Actions
XWikiWikiReference 35 19 0% 7 20
0.285714328.6%
 

Contributing tests

This file is covered by 57 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.internal.parser.xhtml.wikimodel;
21   
22    import org.apache.commons.lang3.builder.EqualsBuilder;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24    import org.xwiki.rendering.listener.reference.ResourceReference;
25    import org.xwiki.rendering.wikimodel.WikiParameters;
26    import org.xwiki.rendering.wikimodel.WikiReference;
27   
28    /**
29    * WikiModel extension in order to add additional XWiki Link information so that the XWiki Generator Listener for the
30    * XHTML syntax doesn't have to do any link parsing.
31    *
32    * @version $Id: 8103400dbfe5b5f6812fa5ca21c471ae00c5ea9c $
33    * @since 2.5RC1
34    */
 
35    public class XWikiWikiReference extends WikiReference
36    {
37    private ResourceReference reference;
38   
39    private boolean freeStanding;
40   
 
41  80 toggle public XWikiWikiReference(ResourceReference reference, String label, WikiParameters linkParameters,
42    boolean freeStanding)
43    {
44  80 super(reference.getReference(), label, linkParameters);
45  80 this.reference = reference;
46  80 this.freeStanding = freeStanding;
47    }
48   
 
49  80 toggle public boolean isFreeStanding()
50    {
51  80 return this.freeStanding;
52    }
53   
 
54  80 toggle public ResourceReference getReference()
55    {
56  80 return this.reference;
57    }
58   
59    // TODO: Ensure there's no sync issue between reference object and getLink() from WikiReference
60    // TODO: implement totring
61   
 
62  0 toggle @Override
63    public boolean equals(Object obj)
64    {
65  0 if (this == obj) {
66  0 return true;
67    }
68   
69  0 if (!(obj instanceof XWikiWikiReference)) {
70  0 return false;
71    }
72   
73  0 EqualsBuilder builder = new EqualsBuilder();
74   
75  0 builder.appendSuper(super.equals(obj));
76  0 builder.append(this.reference, ((XWikiWikiReference) obj).reference);
77  0 builder.append(this.freeStanding, ((XWikiWikiReference) obj).freeStanding);
78   
79  0 return builder.isEquals();
80    }
81   
 
82  0 toggle @Override
83    public int hashCode()
84    {
85  0 HashCodeBuilder builder = new HashCodeBuilder();
86   
87  0 builder.appendSuper(super.hashCode());
88  0 builder.append(reference);
89  0 builder.append(freeStanding);
90   
91  0 return builder.toHashCode();
92    }
93    }