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

File WordBlock.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

4
15
6
1
96
47
9
0.6
2.5
6
1.5

Classes

Class Line # Actions
WordBlock 32 15 0% 9 7
0.7272%
 

Contributing tests

This file is covered by 966 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    * Represents a word.
28    *
29    * @version $Id: ad2e8151f62ddd4d66b60b30b307186569f1fe21 $
30    * @since 1.5M2
31    */
 
32    public class WordBlock extends AbstractBlock
33    {
34    /**
35    * @see #getWord()
36    */
37    private String word;
38   
39    /**
40    * @param word the word wrapped by this block. Note that this is supposed to be a single word and space or special
41    * symbols should be represented by other blocks
42    */
 
43  581558 toggle public WordBlock(String word)
44    {
45  581555 this.word = word;
46    }
47   
 
48  463452 toggle @Override
49    public void traverse(Listener listener)
50    {
51  463452 listener.onWord(getWord());
52    }
53   
54    /**
55    * @return the word wrapped by this block
56    */
 
57  475698 toggle public String getWord()
58    {
59  475697 return this.word;
60    }
61   
 
62  0 toggle @Override
63    public String toString()
64    {
65  0 return getWord();
66    }
67   
 
68  9250 toggle @Override
69    public boolean equals(Object obj)
70    {
71  9250 if (obj == this) {
72  12 return true;
73    }
74   
75  9238 if (obj instanceof WordBlock && super.equals(obj)) {
76  14 EqualsBuilder builder = new EqualsBuilder();
77   
78  14 builder.append(getWord(), ((WordBlock) obj).getWord());
79   
80  14 return builder.isEquals();
81    }
82   
83  9224 return false;
84    }
85   
 
86  0 toggle @Override
87    public int hashCode()
88    {
89  0 HashCodeBuilder builder = new HashCodeBuilder();
90   
91  0 builder.appendSuper(super.hashCode());
92  0 builder.append(getWord());
93   
94  0 return builder.toHashCode();
95    }
96    }