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
20   188   13   1.82
4   82   0.65   11
11     1.18  
1    
 
  AbstractMacroDescriptor       Line # 36 20 0% 13 13 62.9% 0.62857145
 
  (104)
 
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.macro.descriptor;
21   
22    import java.util.Collections;
23    import java.util.LinkedHashMap;
24    import java.util.Map;
25   
26    import org.xwiki.properties.BeanDescriptor;
27    import org.xwiki.properties.PropertyDescriptor;
28    import org.xwiki.rendering.macro.MacroId;
29   
30    /**
31    * Describe a macro.
32    *
33    * @version $Id: 5568b6418c14407b41960801fd13993bf7ed5094 $
34    * @since 1.6M1
35    */
 
36    public abstract class AbstractMacroDescriptor implements MacroDescriptor
37    {
38    /**
39    * @see #getId()
40    */
41    private MacroId id;
42   
43    /**
44    * @see #getName()
45    */
46    private String name;
47   
48    /**
49    * The description of the macro.
50    */
51    private String description;
52   
53    /**
54    * Define a macro content.
55    */
56    private ContentDescriptor contentDescriptor;
57   
58    /**
59    * The description of the parameters bean.
60    */
61    private BeanDescriptor parametersBeanDescriptor;
62   
63    /**
64    * Default macro category.
65    */
66    private String defaultCategory;
67   
68    /**
69    * A map containing the {@link ParameterDescriptor} for each parameters supported for this macro.
70    * <p>
71    * The {@link Map} keys are lower cased for easier case insensitive search, to get the "real" name of the property
72    * use {@link ParameterDescriptor#getName()}.
73    */
74    private Map<String, ParameterDescriptor> parameterDescriptorMap = new LinkedHashMap<String, ParameterDescriptor>();
75   
76    /**
77    * @param id the id of the macro
78    * @param name the name of the macro (eg "Table Of Contents" for the TOC macro)
79    * @param description the description of the macro.
80    * @param contentDescriptor the description of the macro content. null indicate macro does not support content.
81    * @param parametersBeanDescriptor the description of the parameters bean or null if there are no parameters for
82    * this macro.
83    * @since 2.3M1
84    */
 
85  162 toggle public AbstractMacroDescriptor(MacroId id, String name, String description, ContentDescriptor contentDescriptor,
86    BeanDescriptor parametersBeanDescriptor)
87    {
88  162 this.id = id;
89  162 this.name = name;
90  162 this.description = description;
91  162 this.contentDescriptor = contentDescriptor;
92  162 this.parametersBeanDescriptor = parametersBeanDescriptor;
93    }
94   
95    /**
96    * @param name the name of the macro (eg "Table Of Contents" for the TOC macro)
97    * @param description the description of the macro.
98    * @param contentDescriptor the description of the macro content. null indicate macro does not support content.
99    * @param parametersBeanDescriptor the description of the parameters bean or null if there are no parameters for
100    * this macro.
101    * @since 2.0M3
102    * @deprecated since 2.3M1 use
103    * {@link #AbstractMacroDescriptor(MacroId, String, String, ContentDescriptor, BeanDescriptor)} instead
104    */
 
105  0 toggle @Deprecated
106    public AbstractMacroDescriptor(String name, String description, ContentDescriptor contentDescriptor,
107    BeanDescriptor parametersBeanDescriptor)
108    {
109  0 this.name = name;
110  0 this.description = description;
111  0 this.contentDescriptor = contentDescriptor;
112  0 this.parametersBeanDescriptor = parametersBeanDescriptor;
113    }
114   
115    /**
116    * Extract parameters informations from {@link #parametersBeanDescriptor} and insert it in
117    * {@link #parameterDescriptorMap}.
118    *
119    * @since 1.7M2
120    */
 
121  159 toggle protected void extractParameterDescriptorMap()
122    {
123  159 for (PropertyDescriptor propertyDescriptor : parametersBeanDescriptor.getProperties()) {
124  211 DefaultParameterDescriptor desc = new DefaultParameterDescriptor(propertyDescriptor);
125  211 this.parameterDescriptorMap.put(desc.getId().toLowerCase(), desc);
126    }
127    }
128   
129    /**
130    * {@inheritDoc}
131    * @since 2.3M1
132    */
 
133  0 toggle @Override
134    public MacroId getId()
135    {
136  0 return this.id;
137    }
138   
139    /**
140    * {@inheritDoc}
141    * @since 2.0M3
142    */
 
143  0 toggle @Override
144    public String getName()
145    {
146  0 return this.name;
147    }
148   
 
149  4 toggle @Override
150    public ContentDescriptor getContentDescriptor()
151    {
152  4 return this.contentDescriptor;
153    }
154   
 
155  0 toggle @Override
156    public String getDescription()
157    {
158  0 return this.description;
159    }
160   
 
161  1135 toggle @Override
162    public Class< ? > getParametersBeanClass()
163    {
164  1135 return (null != parametersBeanDescriptor) ? this.parametersBeanDescriptor.getBeanClass() : Object.class;
165    }
166   
 
167  6 toggle @Override
168    public Map<String, ParameterDescriptor> getParameterDescriptorMap()
169    {
170  6 return (null != parametersBeanDescriptor) ? Collections.unmodifiableMap(this.parameterDescriptorMap)
171    : Collections.<String, ParameterDescriptor> emptyMap();
172    }
173   
 
174  46 toggle @Override
175    public String getDefaultCategory()
176    {
177  46 return this.defaultCategory;
178    }
179   
180    /**
181    * @param defaultCategory default category under which this macro should be listed.
182    * @see MacroDescriptor#getDefaultCategory()
183    */
 
184  154 toggle public void setDefaultCategory(String defaultCategory)
185    {
186  154 this.defaultCategory = defaultCategory;
187    }
188    }