Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart8.png 68% of files have more coverage
7   128   7   1
0   41   1   7
7     1  
1    
 
  MetaData       Line # 32 7 0% 7 3 78.6% 0.78571427
 
  (990)
 
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.listener;
21   
22    import java.util.Collections;
23    import java.util.LinkedHashMap;
24    import java.util.Map;
25   
26    /**
27    * Represents a set of MetaData.
28    *
29    * @version $Id: f26fc01665a743cc5ddab1714688917dd64833b5 $
30    * @since 3.0M2
31    */
 
32    public class MetaData
33    {
34    /**
35    * Represents no MetaData.
36    */
37    public static final MetaData EMPTY = new MetaData();
38   
39    /**
40    * Represents a source metaData, which corresponds to the reference to the source entity containing the content to
41    * render. The reference is a free form text in a format that is understood by the Listeners supporting it.
42    */
43    public static final String SOURCE = "source";
44   
45    /**
46    * Represents the syntax of the content found in macro containing wiki content (like a box macro for example). The
47    * value has to be a {@link org.xwiki.rendering.syntax.Syntax} object.
48    *
49    * @since 3.0M3
50    */
51    public static final String SYNTAX = "syntax";
52   
53    /**
54    * Represent the base reference to resolve all the references in the blocks (links, images, macro parameters, etc.).
55    *
56    * @since 3.4M1
57    */
58    public static final String BASE = "base";
59   
60    /**
61    * Contains all MetaData for this Block and its children.
62    * Note: we preserve the order of metadata elements as they are added as a service for the user so he can count
63    * on it.
64    */
65    private Map<String, Object> metadata = new LinkedHashMap<String, Object>();
66   
67    /**
68    * Empty metaData.
69    */
 
70  1220 toggle public MetaData()
71    {
72    // Do nothing, the metaData map is empty.
73    }
74   
75    /**
76    * @param metaData the metadata to set
77    */
 
78  992 toggle public MetaData(Map<String, Object> metaData)
79    {
80  992 this.metadata.putAll(metaData);
81    }
82   
83    /**
84    * @param key the key to the metadata element to add (e.g. "syntax")
85    * @param value the value of the metadata element to add (e.g. a Syntax object)
86    */
 
87  1205 toggle public void addMetaData(String key, Object value)
88    {
89  1205 this.metadata.put(key, value);
90    }
91   
92    /**
93    * @param metaData the metadata to add
94    */
 
95  0 toggle public void addMetaData(MetaData metaData)
96    {
97  0 for (Map.Entry<String, Object> entry : metaData.getMetaData().entrySet()) {
98  0 addMetaData(entry.getKey(), entry.getValue());
99    }
100    }
101   
102    /**
103    * @param key the key to the metadata element to retrieve (e.g. "syntax")
104    * @return the metadata corresponding to the passed key of null if no such metadata exist.
105    */
 
106  192 toggle public Object getMetaData(String key)
107    {
108  192 return this.metadata.get(key);
109    }
110   
111    /**
112    * @param key the key to the metadata element to check for
113    * @return true if there's a metadata with the passed key, false otherwise
114    * @since 3.0M3
115    */
 
116  40 toggle public boolean contains(String key)
117    {
118  40 return this.metadata.containsKey(key);
119    }
120   
121    /**
122    * @return all the metadata
123    */
 
124  1858 toggle public Map<String, Object> getMetaData()
125    {
126  1858 return Collections.unmodifiableMap(this.metadata);
127    }
128    }