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

File IdBlock.java

 

Coverage histogram

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

Code metrics

4
15
5
1
92
43
7
0.47
3
5
1.4

Classes

Class Line # Actions
IdBlock 34 15 0% 7 18
0.2525%
 

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.block;
21   
22    import org.apache.commons.lang3.builder.EqualsBuilder;
23    import org.apache.commons.lang3.builder.HashCodeBuilder;
24    import org.xwiki.rendering.listener.Listener;
25   
26    /**
27    * A reference/location in a page. In HTML for example this is called an Anchor. It allows pointing to that location,
28    * for example in links.
29    *
30    * @version $Id: 774ad6bcf5531d6530d570414d054ea86a2f48f8 $
31    * @since 1.6M1
32    * @see Listener#onId(String)
33    */
 
34    public class IdBlock extends AbstractBlock
35    {
36    /**
37    * The unique name for the reference/location.
38    */
39    private String name;
40   
41    /**
42    * @param name the unique name for the reference/location.
43    */
 
44  13 toggle public IdBlock(String name)
45    {
46  13 this.name = name;
47    }
48   
49    /**
50    * @return the reference/location name
51    */
 
52  13 toggle public String getName()
53    {
54  13 return this.name;
55    }
56   
 
57  12 toggle @Override
58    public void traverse(Listener listener)
59    {
60  12 listener.onId(getName());
61    }
62   
 
63  0 toggle @Override
64    public boolean equals(Object obj)
65    {
66  0 if (obj == this) {
67  0 return true;
68    }
69   
70  0 if (obj instanceof IdBlock) {
71  0 EqualsBuilder builder = new EqualsBuilder();
72   
73  0 builder.appendSuper(super.equals(obj));
74  0 builder.append(getName(), ((IdBlock) obj).getName());
75   
76  0 return builder.isEquals();
77    }
78   
79  0 return false;
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(getName());
89   
90  0 return builder.toHashCode();
91    }
92    }