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

File MetaData.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
11
9
1
143
53
10
0.91
1.22
9
1.11

Classes

Class Line # Actions
MetaData 32 11 0% 10 4
0.818181881.8%
 

Contributing tests

This file is covered by 1493 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.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: 81bcf7e2748b6216e81767217d01dbba71ae04c2 $
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. Note: we preserve the order of metadata elements as they
62    * are added as a service for the user so he can count on it.
63    */
64    private final Map<String, Object> metadata;
65   
66    /**
67    * Empty metaData.
68    */
 
69  24713 toggle public MetaData()
70    {
71  24712 this.metadata = new LinkedHashMap<String, Object>();
72    }
73   
74    /**
75    * @param metaData the metadata to set
76    */
 
77  44919 toggle public MetaData(Map<String, Object> metaData)
78    {
79  44918 this.metadata = new LinkedHashMap<String, Object>(metaData);
80    }
81   
82    /**
83    * @param key the key to the metadata element to add (e.g. "syntax")
84    * @param value the value of the metadata element to add (e.g. a Syntax object)
85    */
 
86  44676 toggle public void addMetaData(String key, Object value)
87    {
88  44681 this.metadata.put(key, value);
89    }
90   
91    /**
92    * @param metaData the metadata to add
93    */
 
94  1 toggle public void addMetaData(MetaData metaData)
95    {
96  1 this.metadata.putAll(metaData.getMetaData());
97    }
98   
99    /**
100    * @param key the key to the metadata element to retrieve (e.g. "syntax")
101    * @return the metadata corresponding to the passed key of null if no such metadata exist.
102    */
 
103  12652 toggle public Object getMetaData(String key)
104    {
105  12652 return this.metadata.get(key);
106    }
107   
108    /**
109    * @param key the key to the metadata element to check for
110    * @return true if there's a metadata with the passed key, false otherwise
111    * @since 3.0M3
112    */
 
113  10650 toggle public boolean contains(String key)
114    {
115  10651 return this.metadata.containsKey(key);
116    }
117   
118    /**
119    * @return all the metadata
120    */
 
121  45920 toggle public Map<String, Object> getMetaData()
122    {
123  45919 return Collections.unmodifiableMap(this.metadata);
124    }
125   
126    // Object
127   
 
128  1177 toggle @Override
129    public boolean equals(Object obj)
130    {
131  1177 if (obj == this) {
132  0 return true;
133    }
134   
135  1177 return obj instanceof MetaData && this.metadata.equals(((MetaData) obj).metadata);
136    }
137   
 
138  0 toggle @Override
139    public int hashCode()
140    {
141  0 return this.metadata.hashCode();
142    }
143    }