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

File RawBlock.java

 

Coverage histogram

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

Code metrics

4
18
6
1
109
51
9
0.5
3
6
1.5

Classes

Class Line # Actions
RawBlock 35 18 0% 9 19
0.3214285732.1%
 

Contributing tests

This file is covered by 40 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    import org.xwiki.rendering.syntax.Syntax;
26   
27    /**
28    * Represents some raw content that shouldn't be parsed or modified and that should be injected as is in any output. The
29    * content depends on a syntax and listeners decide if they can handle that syntax or not. For example if it's in
30    * "xhtml/1.0" syntax then the XHTML Renderer can insert it directly in the XHTML output.
31    *
32    * @version $Id: f43998235ed54eb324416bbd919f88e91d0dd1c7 $
33    * @since 1.8.3
34    */
 
35    public class RawBlock extends AbstractBlock
36    {
37    /**
38    * @see #getRawContent()
39    */
40    private String rawContent;
41   
42    /**
43    * @see #getSyntax()
44    */
45    private Syntax syntax;
46   
47    /**
48    * @param rawContent the content to inject as is into the listener (it won't be modified)
49    * @param syntax the syntax in which the content is written
50    */
 
51  7569 toggle public RawBlock(String rawContent, Syntax syntax)
52    {
53  7569 this.rawContent = rawContent;
54  7569 this.syntax = syntax;
55    }
56   
 
57  6726 toggle @Override
58    public void traverse(Listener listener)
59    {
60  6726 listener.onRawText(getRawContent(), getSyntax());
61    }
62   
63    /**
64    * @return the content to inject as is into the listener (it won't be modified)
65    */
 
66  6727 toggle public String getRawContent()
67    {
68  6727 return this.rawContent;
69    }
70   
71    /**
72    * @return the syntax in which the content is written
73    */
 
74  6726 toggle public Syntax getSyntax()
75    {
76  6726 return this.syntax;
77    }
78   
 
79  0 toggle @Override
80    public boolean equals(Object obj)
81    {
82  0 if (obj == this) {
83  0 return true;
84    }
85   
86  0 if (obj instanceof RawBlock && super.equals(obj)) {
87  0 EqualsBuilder builder = new EqualsBuilder();
88   
89  0 builder.append(getRawContent(), ((RawBlock) obj).getRawContent());
90  0 builder.append(getSyntax(), ((RawBlock) obj).getSyntax());
91   
92  0 return builder.isEquals();
93    }
94   
95  0 return false;
96    }
97   
 
98  0 toggle @Override
99    public int hashCode()
100    {
101  0 HashCodeBuilder builder = new HashCodeBuilder();
102   
103  0 builder.appendSuper(super.hashCode());
104  0 builder.append(getRawContent());
105  0 builder.append(getSyntax());
106   
107  0 return builder.toHashCode();
108    }
109    }