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
7   94   6   1.17
0   36   0.86   6
6     1  
1    
 
  MetaDataBlock       Line # 35 7 0% 6 4 69.2% 0.6923077
 
  (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 java.util.Collections;
23    import java.util.List;
24   
25    import org.xwiki.rendering.listener.Listener;
26    import org.xwiki.rendering.listener.MetaData;
27   
28    /**
29    * Represents any kind of MetaData in the XDOM (eg saving original blocks so that the XWiki Syntax Renderer can restore
30    * them after a transformation has been executed, source reference, etc).
31    *
32    * @version $Id$
33    * @since 3.0M2
34    */
 
35    public class MetaDataBlock extends AbstractBlock
36    {
37    /**
38    * Contains all MetaData for this Block and its children.
39    */
40    private MetaData metaData;
41   
42    /**
43    * @param childBlocks the list of children blocks of the block to construct
44    * @param metaData the metadata to set
45    * @see AbstractBlock#AbstractBlock(List)
46    */
 
47  2167 toggle public MetaDataBlock(List<Block> childBlocks, MetaData metaData)
48    {
49  2167 super(childBlocks);
50  2167 this.metaData = metaData;
51    }
52   
53    /**
54    * Helper constructor.
55    *
56    * @param childBlocks the list of children blocks of the block to construct
57    * @param key the metadata key to set
58    * @param value the metadata value to set
59    * @see AbstractBlock#AbstractBlock(List)
60    */
 
61  0 toggle public MetaDataBlock(List<Block> childBlocks, String key, Object value)
62    {
63  0 this(childBlocks, new MetaData(Collections.singletonMap(key, value)));
64    }
65   
66    /**
67    * @param childBlocks the list of children blocks of the block to construct
68    * @see AbstractBlock#AbstractBlock(List)
69    */
 
70  0 toggle public MetaDataBlock(List<Block> childBlocks)
71    {
72  0 this(childBlocks, new MetaData());
73    }
74   
75    /**
76    * @return the metadata for this block, see {@link MetaData}
77    */
 
78  3078 toggle public MetaData getMetaData()
79    {
80  3078 return this.metaData;
81    }
82   
 
83  5 toggle @Override
84    public void before(Listener listener)
85    {
86  5 listener.beginMetaData(getMetaData());
87    }
88   
 
89  5 toggle @Override
90    public void after(Listener listener)
91    {
92  5 listener.endMetaData(getMetaData());
93    }
94    }