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

File DocumentDisplayerParameters.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
27
17
1
247
94
18
0.67
1.59
17
1.06

Classes

Class Line # Actions
DocumentDisplayerParameters 30 27 0% 18 1
0.9772727597.7%
 

Contributing tests

This file is covered by 45 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.display.internal;
21   
22    import org.xwiki.rendering.syntax.Syntax;
23   
24    /**
25    * {@link DocumentDisplayer} parameters.
26    *
27    * @version $Id: 891d4d2f3abf4a6a84bdcee5288d70559d9e84be $
28    * @since 3.2M3
29    */
 
30    public class DocumentDisplayerParameters implements Cloneable
31    {
32    /**
33    * The id of the document section to display. E.g. "HSectionTitle".
34    */
35    private String sectionId;
36   
37    /**
38    * Flag indicating if the title should be displayed instead of the content.
39    */
40    private boolean titleDisplayed;
41   
42    /**
43    * Flag indicating if the document should be displayed in an isolated execution context rather than in the current
44    * execution context. When {@code true}, the current execution context is cloned and the displayed document is set
45    * as the context document.
46    */
47    private boolean executionContextIsolated;
48   
49    /**
50    * Flag indicating if the XDOM transformations should be executed in an isolated context or not. Set this to
51    * {@code false} if you expect transformations to have side effects. This flag controls for instance if the Velocity
52    * macros defined by the Velocity transformations are added to the current name-space or to a new one (isolated).
53    */
54    private boolean transformationContextIsolated = true;
55   
56    /**
57    * Flag indicating if the transformation context should be restricted so that potentially harmful transformations
58    * are not executed.
59    */
60    private boolean transformationContextRestricted;
61   
62    /**
63    * Flag indicating if the content should be transformed or not. When this flag is set the rendering transformations
64    * are performed on the content XDOM.
65    */
66    private boolean contentTransformed = true;
67   
68    /**
69    * When this flag is set the displayer should look for a document translation matching the current language on the
70    * execution context. Otherwise the displayer should simply display the content of the provided document.
71    */
72    private boolean contentTranslated;
73   
74    /**
75    * The target syntax to put in the transformation context.
76    */
77    private Syntax targetSyntax;
78   
79    /**
80    * @return the id of the document section to display
81    */
 
82  7320 toggle public String getSectionId()
83    {
84  7320 return sectionId;
85    }
86   
87    /**
88    * Sets the id of the document section to display.
89    *
90    * @param sectionId the id of the document section to display
91    */
 
92  2191 toggle public void setSectionId(String sectionId)
93    {
94  2191 this.sectionId = sectionId;
95    }
96   
97    /**
98    * @return {@code true} if the title should be displayed instead of the content, {@code false} otherwise
99    */
 
100  29204 toggle public boolean isTitleDisplayed()
101    {
102  29201 return titleDisplayed;
103    }
104   
105    /**
106    * Sets whether the title should be displayed instead of the content.
107    *
108    * @param titleDisplayed {@code true} to display the title, {@code false} to display the content
109    */
 
110  21276 toggle public void setTitleDisplayed(boolean titleDisplayed)
111    {
112  21276 this.titleDisplayed = titleDisplayed;
113    }
114   
115    /**
116    * @return {@code true} if the execution context should be isolated while the document is displayed, {@code false}
117    * otherwise
118    */
 
119  38362 toggle public boolean isExecutionContextIsolated()
120    {
121  38362 return executionContextIsolated;
122    }
123   
124    /**
125    * Sets whether the execution context should be isolated while the document is displayed.
126    *
127    * @param executionContextIsolated {@code true} to isolate the execution context while the document is displayed,
128    * {@code false} to display the document in the current execution context
129    */
 
130  29662 toggle public void setExecutionContextIsolated(boolean executionContextIsolated)
131    {
132  29664 this.executionContextIsolated = executionContextIsolated;
133    }
134   
135    /**
136    * @return {@code true} if the transformation context should be isolated while the document is displayed,
137    * {@code false} otherwise
138    */
 
139  26036 toggle public boolean isTransformationContextIsolated()
140    {
141  26035 return transformationContextIsolated;
142    }
143   
144    /**
145    * Sets whether the transformation context should be isolated while the document is displayed.
146    *
147    * @param transformationContextIsolated {@code true} to isolate the transformation context while the document is
148    * displayed, {@code false} to use a transformation context based on the current context document
149    */
 
150  8385 toggle public void setTransformationContextIsolated(boolean transformationContextIsolated)
151    {
152  8384 this.transformationContextIsolated = transformationContextIsolated;
153    }
154   
155    /**
156    * @return {@code true} if the transformation context should be restricted, {@code false} otherwise.
157    */
 
158  6372 toggle public boolean isTransformationContextRestricted()
159    {
160  6372 return transformationContextRestricted;
161    }
162   
163    /**
164    * Set the flag indicating whether the transformation context should be restricted or not.
165    *
166    * @param transformationContextRestricted {@code true} to indicate that potentially harmful transformations should
167    * not be executed.
168    */
 
169  7155 toggle public void setTransformationContextRestricted(boolean transformationContextRestricted)
170    {
171  7155 this.transformationContextRestricted = transformationContextRestricted;
172    }
173   
174    /**
175    * @return {@code true} if the content is transformed, {@code false} otherwise
176    */
 
177  43538 toggle public boolean isContentTransformed()
178    {
179  43539 return contentTransformed;
180    }
181   
182    /**
183    * Sets whether the content is transformed.
184    *
185    * @param contentTransformed {@code true} to transform the content, {@code false} otherwise
186    */
 
187  2191 toggle public void setContentTransformed(boolean contentTransformed)
188    {
189  2191 this.contentTransformed = contentTransformed;
190    }
191   
192    /**
193    * @return {@code true} if the displayer should look for a document translation matching the current language,
194    * {@code false} if the displayer should simply display the content of the provided document
195    */
 
196  7320 toggle public boolean isContentTranslated()
197    {
198  7320 return contentTranslated;
199    }
200   
201    /**
202    * Sets whether the displayer should display the translated content or not.
203    *
204    * @param contentTranslated {@code true} to force the display to look for a document translation matching the
205    * current language, {@code false} to tell the displayer to simply display the content of the provided
206    * document
207    */
 
208  7593 toggle public void setContentTranslated(boolean contentTranslated)
209    {
210  7593 this.contentTranslated = contentTranslated;
211    }
212   
213    /**
214    * @return the target syntax to put in the transformation context.
215    */
 
216  8 toggle public Syntax getTargetSyntax()
217    {
218  8 return this.targetSyntax;
219    }
220   
221    /**
222    * @param targetSyntax the target syntax to put in the transformation context.
223    */
 
224  27222 toggle public void setTargetSyntax(Syntax targetSyntax)
225    {
226  27222 this.targetSyntax = targetSyntax;
227    }
228   
 
229  1225 toggle @Override
230    public DocumentDisplayerParameters clone()
231    {
232  1225 DocumentDisplayerParameters clone;
233  1225 try {
234  1225 clone = (DocumentDisplayerParameters) super.clone();
235    } catch (CloneNotSupportedException e) {
236    // Should never happen.
237  0 throw new RuntimeException("Failed to clone object", e);
238    }
239  1225 clone.setContentTransformed(contentTransformed);
240  1225 clone.setContentTranslated(contentTranslated);
241  1225 clone.setExecutionContextIsolated(executionContextIsolated);
242  1225 clone.setSectionId(sectionId);
243  1225 clone.setTitleDisplayed(titleDisplayed);
244  1225 clone.setTransformationContextIsolated(transformationContextIsolated);
245  1225 return clone;
246    }
247    }