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

File FormatBlock.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

4
15
7
1
107
53
10
0.67
2.14
7
1.43

Classes

Class Line # Actions
FormatBlock 36 15 0% 10 15
0.4230769342.3%
 

Contributing tests

This file is covered by 177 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 java.util.Collections;
23    import java.util.List;
24    import java.util.Map;
25   
26    import org.apache.commons.lang3.builder.HashCodeBuilder;
27    import org.xwiki.rendering.listener.Format;
28    import org.xwiki.rendering.listener.Listener;
29   
30    /**
31    * Represents a text formatting block (bold, italic, etc).
32    *
33    * @version $Id: 9cd1a298d65f984e7512493aa52ac925bf69e56d $
34    * @since 1.6M1
35    */
 
36    public class FormatBlock extends AbstractBlock
37    {
38    /**
39    * The formatting to apply to the children blocks.
40    */
41    private Format format;
42   
43    /**
44    * @param childrenBlocks the nested children blocks
45    * @param format the formatting to apply to the children blocks
46    */
 
47  235 toggle public FormatBlock(List<Block> childrenBlocks, Format format)
48    {
49  235 this(childrenBlocks, format, Collections.<String, String>emptyMap());
50    }
51   
52    /**
53    * @param childrenBlocks the nested children blocks
54    * @param format the formatting to apply to the children blocks
55    * @param parameters the custom parameters
56    */
 
57  5778 toggle public FormatBlock(List<Block> childrenBlocks, Format format, Map<String, String> parameters)
58    {
59  5778 super(childrenBlocks, parameters);
60  5778 this.format = format;
61    }
62   
63    /**
64    * @return the formatting to apply to the children blocks
65    */
 
66  10584 toggle public Format getFormat()
67    {
68  10584 return this.format;
69    }
70   
 
71  5292 toggle @Override
72    public void before(Listener listener)
73    {
74  5292 listener.beginFormat(getFormat(), getParameters());
75    }
76   
 
77  5292 toggle @Override
78    public void after(Listener listener)
79    {
80  5292 listener.endFormat(getFormat(), getParameters());
81    }
82   
 
83  0 toggle @Override
84    public boolean equals(Object obj)
85    {
86  0 if (obj == this) {
87  0 return true;
88    }
89   
90  0 if (obj instanceof FormatBlock && super.equals(obj)) {
91  0 return getFormat() == ((FormatBlock) obj).getFormat();
92    }
93   
94  0 return false;
95    }
96   
 
97  0 toggle @Override
98    public int hashCode()
99    {
100  0 HashCodeBuilder builder = new HashCodeBuilder();
101   
102  0 builder.appendSuper(super.hashCode());
103  0 builder.append(getFormat());
104   
105  0 return builder.toHashCode();
106    }
107    }