1. Project Clover database Sat Feb 2 2019 06:45:20 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 46 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  41241 toggle public String getSectionId()
83    {
84  41246 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  35589 toggle public void setSectionId(String sectionId)
93    {
94  35589 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  276645 toggle public boolean isTitleDisplayed()
101    {
102  276659 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  231472 toggle public void setTitleDisplayed(boolean titleDisplayed)
111    {
112  231489 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  382321 toggle public boolean isExecutionContextIsolated()
120    {
121  382395 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  293775 toggle public void setExecutionContextIsolated(boolean executionContextIsolated)
131    {
132  293762 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  219945 toggle public boolean isTransformationContextIsolated()
140    {
141  219961 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  62288 toggle public void setTransformationContextIsolated(boolean transformationContextIsolated)
151    {
152  62277 this.transformationContextIsolated = transformationContextIsolated;
153    }
154   
155    /**
156    * @return {@code true} if the transformation context should be restricted, {@code false} otherwise.
157    */
 
158  27291 toggle public boolean isTransformationContextRestricted()
159    {
160  27294 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  39623 toggle public void setTransformationContextRestricted(boolean transformationContextRestricted)
170    {
171  39618 this.transformationContextRestricted = transformationContextRestricted;
172    }
173   
174    /**
175    * @return {@code true} if the content is transformed, {@code false} otherwise
176    */
 
177  348455 toggle public boolean isContentTransformed()
178    {
179  348488 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  35590 toggle public void setContentTransformed(boolean contentTransformed)
188    {
189  35585 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  40044 toggle public boolean isContentTranslated()
197    {
198  40048 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  62730 toggle public void setContentTranslated(boolean contentTranslated)
209    {
210  62717 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  248457 toggle public void setTargetSyntax(Syntax targetSyntax)
225    {
226  248444 this.targetSyntax = targetSyntax;
227    }
228   
 
229  22654 toggle @Override
230    public DocumentDisplayerParameters clone()
231    {
232  22657 DocumentDisplayerParameters clone;
233  22654 try {
234  22656 clone = (DocumentDisplayerParameters) super.clone();
235    } catch (CloneNotSupportedException e) {
236    // Should never happen.
237  0 throw new RuntimeException("Failed to clone object", e);
238    }
239  22657 clone.setContentTransformed(contentTransformed);
240  22657 clone.setContentTranslated(contentTranslated);
241  22655 clone.setExecutionContextIsolated(executionContextIsolated);
242  22651 clone.setSectionId(sectionId);
243  22653 clone.setTitleDisplayed(titleDisplayed);
244  22655 clone.setTransformationContextIsolated(transformationContextIsolated);
245  22658 return clone;
246    }
247    }