Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart7.png 76% of files have more coverage
10   124   9   1.11
0   51   0.9   9
9     1  
1    
 
  XDOM       Line # 35 10 0% 9 6 68.4% 0.68421054
 
  (988)
 
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.xwiki.rendering.listener.Listener;
23    import org.xwiki.rendering.listener.MetaData;
24    import org.xwiki.rendering.util.IdGenerator;
25   
26    import java.util.List;
27    import java.util.Collections;
28   
29    /**
30    * Contains the full tree of {@link Block} that represent a XWiki Document's content.
31    *
32    * @version $Id: ba4034f72f5733c687b2e83d3c47863c75d35af4 $
33    * @since 1.5M2
34    */
 
35    public class XDOM extends MetaDataBlock
36    {
37    /**
38    * Constructs an empty XDOM. Useful for example when calling a macro that doesn't use the XDOM parameter passed to
39    * it.
40    */
41    public static final XDOM EMPTY = new XDOM(Collections.<Block> emptyList());
42   
43    /**
44    * Stateful id generator for this document. We store it in the XDOM because it is the only object which remains the
45    * same between parsing, transformation and rendering, and we need to generate ids during parsing and during
46    * transformation.
47    */
48    private IdGenerator idGenerator;
49   
50    /**
51    * @param childBlocks the list of children blocks of the block to construct
52    * @see AbstractBlock#AbstractBlock(List)
53    */
 
54  89 toggle public XDOM(List<Block> childBlocks)
55    {
56  89 this(childBlocks, new IdGenerator(), MetaData.EMPTY);
57    }
58   
59    /**
60    * @param childBlocks the list of children blocks of the block to construct
61    * @param metaData the meta data to add for this block
62    * @see AbstractBlock#AbstractBlock(List)
63    */
 
64  2073 toggle public XDOM(List<Block> childBlocks, MetaData metaData)
65    {
66  2073 this(childBlocks, new IdGenerator(), metaData);
67    }
68   
69    /**
70    * @param childBlocks the list of children blocks of the block to construct
71    * @param idGenerator a stateful id generator for this document
72    */
 
73  0 toggle public XDOM(List<Block> childBlocks, IdGenerator idGenerator)
74    {
75  0 this(childBlocks, idGenerator, MetaData.EMPTY);
76    }
77   
78    /**
79    * @param childBlocks the list of children blocks of the block to construct
80    * @param metaData the meta data to add for this block
81    * @param idGenerator a stateful id generator for this document
82    * @see AbstractBlock#AbstractBlock(List)
83    */
 
84  2162 toggle public XDOM(List<Block> childBlocks, IdGenerator idGenerator, MetaData metaData)
85    {
86  2162 super(childBlocks, metaData);
87  2162 this.idGenerator = idGenerator;
88    }
89   
90    /**
91    * @return a stateful id generator for the whole document.
92    */
 
93  0 toggle public IdGenerator getIdGenerator()
94    {
95  0 return this.idGenerator;
96    }
97   
98    /**
99    * @param idGenerator a stateful id generator for the whole document.
100    * @since 2.1M1
101    */
 
102  1023 toggle public void setIdGenerator(IdGenerator idGenerator)
103    {
104  1023 this.idGenerator = idGenerator;
105    }
106   
 
107  1004 toggle @Override
108    public void before(Listener listener)
109    {
110  1004 listener.beginDocument(getMetaData());
111    }
112   
 
113  1004 toggle @Override
114    public void after(Listener listener)
115    {
116  1004 listener.endDocument(getMetaData());
117    }
118   
 
119  0 toggle @Override
120    public XDOM clone()
121    {
122  0 return (XDOM) super.clone();
123    }
124    }