Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
13   134   10   1.44
0   52   0.77   9
9     1.11  
1    
 
  TransformationContext       Line # 31 13 0% 10 1 95.5% 0.95454544
 
  (115)
 
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.transformation;
21   
22    import org.xwiki.rendering.block.XDOM;
23    import org.xwiki.rendering.syntax.Syntax;
24   
25    /**
26    * The context of the transformation process. Contains information such as the current XWiki DOM for the parsed content.
27    *
28    * @version $Id: 74043d1f48e3cbdda1ba2f0e30e1e7c0882e73d0 $
29    * @since 2.4M1
30    */
 
31    public class TransformationContext implements Cloneable
32    {
33    /**
34    * The complete {@link XDOM} of the content currently being transformed.
35    */
36    private XDOM xdom;
37   
38    /**
39    * The current syntax.
40    */
41    private Syntax syntax;
42   
43    /**
44    * @see #getId(). Note that the id is optional.
45    */
46    private String id;
47   
48    /**
49    * Default constructor that doesn't set the XDOM or the Syntax. This is because setting the XDOM and the Syntax is
50    * optional and only required by some Macros to behave as expected.
51    */
 
52  14 toggle public TransformationContext()
53    {
54    // Voluntarily empty.
55    }
56   
57    /**
58    * Some macros require the XDOM and the Syntax to be set.
59    *
60    * @param xdom see {@link #setXDOM(org.xwiki.rendering.block.XDOM)}
61    * @param syntax see {@link #setSyntax(org.xwiki.rendering.syntax.Syntax)}
62    */
 
63  121 toggle public TransformationContext(XDOM xdom, Syntax syntax)
64    {
65  121 setXDOM(xdom);
66  121 setSyntax(syntax);
67    }
68   
69    /**
70    * @return an id representing the transformation being evaluated. It's a free form name that Transformations can
71    * use, for example if they need to perform some caching based on a key. For example the Velocity Macro
72    * is using this id to pass it to the underlying Velocity Engine so that it caches macros using this key.
73    * @since 2.4M2
74    */
 
75  2 toggle public String getId()
76    {
77  2 return this.id;
78    }
79   
80    /**
81    * @param id see {@link #getId()}
82    * @since 2.4M2
83    */
 
84  2 toggle public void setId(String id)
85    {
86  2 this.id = id;
87    }
88   
89    /**
90    * @param xdom the complete {@link XDOM} of the content currently being transformed.
91    */
 
92  124 toggle public void setXDOM(XDOM xdom)
93    {
94  124 this.xdom = xdom;
95    }
96   
97    /**
98    * @return the complete {@link XDOM} of the content currently being transformed.
99    */
 
100  62 toggle public XDOM getXDOM()
101    {
102  62 return this.xdom;
103    }
104   
105    /**
106    * @param syntax the current syntax.
107    */
 
108  123 toggle public void setSyntax(Syntax syntax)
109    {
110  123 this.syntax = syntax;
111    }
112   
113    /**
114    * @return the current syntax.
115    */
 
116  1180 toggle public Syntax getSyntax()
117    {
118  1180 return syntax;
119    }
120   
 
121  2 toggle @Override
122    public TransformationContext clone()
123    {
124  2 TransformationContext newContext;
125  2 try {
126  2 newContext = (TransformationContext) super.clone();
127    } catch (CloneNotSupportedException e) {
128    // Should never happen
129  0 throw new RuntimeException("Failed to clone object", e);
130    }
131   
132  2 return newContext;
133    }
134    }