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

File XDOM.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
10
9
1
124
51
9
0.9
1.11
9
1

Classes

Class Line # Actions
XDOM 35 10 0% 9 4
0.789473778.9%
 

Contributing tests

This file is covered by 1230 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 java.util.Collections;
23    import java.util.List;
24   
25    import org.xwiki.rendering.listener.Listener;
26    import org.xwiki.rendering.listener.MetaData;
27    import org.xwiki.rendering.util.IdGenerator;
28   
29    /**
30    * Contains the full tree of {@link Block} that represent a XWiki Document's content.
31    *
32    * @version $Id: 39465d5d21957b8fe37efc54800e5038d6502b0e $
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 transient IdGenerator idGenerator;
49   
50    /**
51    * @param childBlocks the list of children blocks of the block to construct
52    * @see AbstractBlock#AbstractBlock(List)
53    */
 
54  1837 toggle public XDOM(List<? extends Block> childBlocks)
55    {
56  1837 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  55602 toggle public XDOM(List<? extends Block> childBlocks, MetaData metaData)
65    {
66  55603 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<? extends 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  57440 toggle public XDOM(List<? extends Block> childBlocks, IdGenerator idGenerator, MetaData metaData)
85    {
86  57440 super(childBlocks, metaData);
87  57437 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  22278 toggle public void setIdGenerator(IdGenerator idGenerator)
103    {
104  22278 this.idGenerator = idGenerator;
105    }
106   
 
107  28307 toggle @Override
108    public void before(Listener listener)
109    {
110  28305 listener.beginDocument(getMetaData());
111    }
112   
 
113  28304 toggle @Override
114    public void after(Listener listener)
115    {
116  28304 listener.endDocument(getMetaData());
117    }
118   
 
119  44026 toggle @Override
120    public XDOM clone()
121    {
122  44025 return (XDOM) super.clone();
123    }
124    }