1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.block

File VerbatimBlock.java

 

Coverage histogram

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

Code metrics

4
22
8
1
132
62
11
0.5
2.75
8
1.38

Classes

Class Line # Actions
VerbatimBlock 34 22 0% 11 21
0.3823529538.2%
 

Contributing tests

This file is covered by 76 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.Map;
23   
24    import org.apache.commons.lang3.builder.EqualsBuilder;
25    import org.apache.commons.lang3.builder.HashCodeBuilder;
26    import org.xwiki.rendering.listener.Listener;
27   
28    /**
29    * A Verbatim block.
30    *
31    * @version $Id: 22056513a919039095ba7c732d17042acc19a8d8 $
32    * @since 1.8M2
33    */
 
34    public class VerbatimBlock extends AbstractBlock
35    {
36    /**
37    * The string to protect from rendering.
38    */
39    private String protectedString;
40   
41    /**
42    * If true the macro is located in a inline content (like paragraph, etc.).
43    */
44    private boolean inline;
45   
46    /**
47    * @param protectedString the string to protect from rendering.
48    * @param isInline if true the macro is located in a inline content (like paragraph, etc.).
49    */
 
50  281 toggle public VerbatimBlock(String protectedString, boolean isInline)
51    {
52  281 this.protectedString = protectedString;
53  281 this.inline = isInline;
54    }
55   
56    /**
57    * @param protectedString the string to protect from rendering.
58    * @param parameters the custom parameters
59    * @param isInline if true the macro is located in a inline content (like paragraph, etc.).
60    */
 
61  8767 toggle public VerbatimBlock(String protectedString, Map<String, String> parameters, boolean isInline)
62    {
63  8767 super(parameters);
64   
65  8767 this.protectedString = protectedString;
66  8767 this.inline = isInline;
67    }
68   
69    /**
70    * @return the string to protect from rendering
71    */
 
72  22438 toggle public String getProtectedString()
73    {
74  22439 return this.protectedString;
75    }
76   
77    /**
78    * @return if true the macro is located in a inline content (like paragraph, etc.).
79    */
 
80  22438 toggle public boolean isInline()
81    {
82  22439 return this.inline;
83    }
84   
 
85  22438 toggle @Override
86    public void traverse(Listener listener)
87    {
88  22439 listener.onVerbatim(getProtectedString(), isInline(), getParameters());
89    }
90   
91    /**
92    * {@inheritDoc}
93    *
94    * @since 1.8RC2
95    */
 
96  0 toggle @Override
97    public String toString()
98    {
99  0 return getProtectedString();
100    }
101   
 
102  0 toggle @Override
103    public boolean equals(Object obj)
104    {
105  0 if (obj == this) {
106  0 return true;
107    }
108   
109  0 if (obj instanceof VerbatimBlock && super.equals(obj)) {
110  0 EqualsBuilder builder = new EqualsBuilder();
111   
112  0 builder.append(isInline(), ((VerbatimBlock) obj).isInline());
113  0 builder.append(getProtectedString(), ((VerbatimBlock) obj).getProtectedString());
114   
115  0 return builder.isEquals();
116    }
117   
118  0 return false;
119    }
120   
 
121  0 toggle @Override
122    public int hashCode()
123    {
124  0 HashCodeBuilder builder = new HashCodeBuilder();
125   
126  0 builder.appendSuper(super.hashCode());
127  0 builder.append(isInline());
128  0 builder.append(getProtectedString());
129   
130  0 return builder.toHashCode();
131    }
132    }