1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.listener.chaining

File EventType.java

 

Coverage histogram

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

Code metrics

4
71
67
1
693
474
69
0.97
1.06
67
1.03

Classes

Class Line # Actions
EventType 38 71 0% 69 18
0.8732394687.3%
 

Contributing tests

This file is covered by 499 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.chaining;
21   
22    import java.util.Map;
23   
24    import org.xwiki.rendering.listener.Format;
25    import org.xwiki.rendering.listener.HeaderLevel;
26    import org.xwiki.rendering.listener.ListType;
27    import org.xwiki.rendering.listener.Listener;
28    import org.xwiki.rendering.listener.MetaData;
29    import org.xwiki.rendering.listener.reference.ResourceReference;
30    import org.xwiki.rendering.syntax.Syntax;
31   
32    /**
33    * Stores event types and offers a way to call a stored event.
34    *
35    * @version $Id: 62bd6afe5c404e0c7e1aa2e6da4ea252d8855304 $
36    * @since 1.8RC1
37    */
 
38    public enum EventType
39    {
40    /**
41    * @see Listener#beginDocument(org.xwiki.rendering.listener.MetaData)
42    */
43    BEGIN_DOCUMENT {
 
44  481 toggle @Override
45    public void fireEvent(Listener listener, Object... eventParameters)
46    {
47  481 listener.beginDocument((MetaData) eventParameters[0]);
48    }
49    },
50    /**
51    * @see Listener#endDocument(org.xwiki.rendering.listener.MetaData)
52    */
53    END_DOCUMENT {
 
54  771 toggle @Override
55    public void fireEvent(Listener listener, Object... eventParameters)
56    {
57  771 listener.endDocument((MetaData) eventParameters[0]);
58    }
59    },
60    /**
61    * @see Listener#beginGroup(java.util.Map)
62    */
63    BEGIN_GROUP {
 
64  79 toggle @Override
65    public void fireEvent(Listener listener, Object... eventParameters)
66    {
67  79 listener.beginGroup((Map<String, String>) eventParameters[0]);
68    }
69    },
70    /**
71    * @see Listener#endGroup(java.util.Map)
72    */
73    END_GROUP {
 
74  79 toggle @Override
75    public void fireEvent(Listener listener, Object... eventParameters)
76    {
77  79 listener.endGroup((Map<String, String>) eventParameters[0]);
78    }
79   
 
80  0 toggle @Override
81    public boolean isInlineEnd()
82    {
83  0 return true;
84    }
85    },
86    /**
87    * @see Listener#beginParagraph(java.util.Map)
88    */
89    BEGIN_PARAGRAPH {
 
90  472 toggle @Override
91    public void fireEvent(Listener listener, Object... eventParameters)
92    {
93  472 listener.beginParagraph((Map<String, String>) eventParameters[0]);
94    }
95    },
96    /**
97    * @see Listener#endParagraph(java.util.Map)
98    */
99    END_PARAGRAPH {
 
100  471 toggle @Override
101    public void fireEvent(Listener listener, Object... eventParameters)
102    {
103  471 listener.endParagraph((Map<String, String>) eventParameters[0]);
104    }
105   
 
106  1 toggle @Override
107    public boolean isInlineEnd()
108    {
109  1 return true;
110    }
111    },
112    /**
113    * @see Listener#beginDefinitionList(java.util.Map)
114    */
115    BEGIN_DEFINITION_LIST {
 
116  29 toggle @Override
117    public void fireEvent(Listener listener, Object... eventParameters)
118    {
119  29 listener.beginDefinitionList((Map<String, String>) eventParameters[0]);
120    }
121   
 
122  0 toggle @Override
123    public boolean isInlineEnd()
124    {
125    // This is because for nested definition lists, the event after a definition list item content is a new
126    // definition list
127  0 return true;
128    }
129    },
130    /**
131    * @see Listener#endDefinitionList(java.util.Map)
132    */
133    END_DEFINITION_LIST {
 
134  29 toggle @Override
135    public void fireEvent(Listener listener, Object... eventParameters)
136    {
137  29 listener.endDefinitionList((Map<String, String>) eventParameters[0]);
138    }
139    },
140    /**
141    * @see Listener#beginDefinitionTerm()
142    */
143    BEGIN_DEFINITION_TERM {
 
144  24 toggle @Override
145    public void fireEvent(Listener listener, Object... eventParameters)
146    {
147  24 listener.beginDefinitionTerm();
148    }
149    },
150    /**
151    * @see Listener#endDefinitionTerm()
152    */
153    END_DEFINITION_TERM {
 
154  24 toggle @Override
155    public void fireEvent(Listener listener, Object... eventParameters)
156    {
157  24 listener.endDefinitionTerm();
158    }
159   
 
160  1 toggle @Override
161    public boolean isInlineEnd()
162    {
163  1 return true;
164    }
165    },
166    /**
167    * @see Listener#beginDefinitionDescription()
168    */
169    BEGIN_DEFINITION_DESCRIPTION {
 
170  28 toggle @Override
171    public void fireEvent(Listener listener, Object... eventParameters)
172    {
173  28 listener.beginDefinitionDescription();
174    }
175    },
176    /**
177    * @see Listener#endDefinitionDescription()
178    */
179    END_DEFINITION_DESCRIPTION {
 
180  28 toggle @Override
181    public void fireEvent(Listener listener, Object... eventParameters)
182    {
183  28 listener.endDefinitionDescription();
184    }
185   
 
186  1 toggle @Override
187    public boolean isInlineEnd()
188    {
189  1 return true;
190    }
191    },
192    /**
193    * @see Listener#beginFormat(org.xwiki.rendering.listener.Format, java.util.Map)
194    */
195    BEGIN_FORMAT {
 
196  278 toggle @Override
197    public void fireEvent(Listener listener, Object... eventParameters)
198    {
199  278 listener.beginFormat((Format) eventParameters[0], (Map<String, String>) eventParameters[1]);
200    }
201    },
202    /**
203    * @see Listener#endFormat(org.xwiki.rendering.listener.Format, java.util.Map)
204    */
205    END_FORMAT {
 
206  278 toggle @Override
207    public void fireEvent(Listener listener, Object... eventParameters)
208    {
209  278 listener.endFormat((Format) eventParameters[0], (Map<String, String>) eventParameters[1]);
210    }
211    },
212    /**
213    * @see Listener#beginHeader(org.xwiki.rendering.listener.HeaderLevel, String, java.util.Map)
214    */
215    BEGIN_HEADER {
 
216  90 toggle @Override
217    public void fireEvent(Listener listener, Object... eventParameters)
218    {
219  90 listener.beginHeader((HeaderLevel) eventParameters[0], (String) eventParameters[1],
220    (Map<String, String>) eventParameters[2]);
221    }
222    },
223    /**
224    * @see Listener#endHeader(org.xwiki.rendering.listener.HeaderLevel, String, java.util.Map)
225    */
226    END_HEADER {
 
227  90 toggle @Override
228    public void fireEvent(Listener listener, Object... eventParameters)
229    {
230  90 listener.endHeader((HeaderLevel) eventParameters[0], (String) eventParameters[1],
231    (Map<String, String>) eventParameters[2]);
232    }
233    },
234    /**
235    * @see Listener#beginLink(org.xwiki.rendering.listener.reference.ResourceReference, boolean, java.util.Map)
236    */
237    BEGIN_LINK {
 
238  732 toggle @Override
239    public void fireEvent(Listener listener, Object... eventParameters)
240    {
241  732 listener.beginLink((ResourceReference) eventParameters[0], (Boolean) eventParameters[1],
242    (Map<String, String>) eventParameters[2]);
243    }
244    },
245    /**
246    * @see Listener#endLink(org.xwiki.rendering.listener.reference.ResourceReference, boolean, java.util.Map)
247    */
248    END_LINK {
 
249  732 toggle @Override
250    public void fireEvent(Listener listener, Object... eventParameters)
251    {
252  732 listener.endLink((ResourceReference) eventParameters[0], (Boolean) eventParameters[1],
253    (Map<String, String>) eventParameters[2]);
254    }
255    },
256    /**
257    * @see Listener#beginList(org.xwiki.rendering.listener.ListType, java.util.Map)
258    */
259    BEGIN_LIST {
 
260  191 toggle @Override
261    public void fireEvent(Listener listener, Object... eventParameters)
262    {
263  191 listener.beginList((ListType) eventParameters[0], (Map<String, String>) eventParameters[1]);
264    }
265   
 
266  1 toggle @Override
267    public boolean isInlineEnd()
268    {
269    // This is because for nested lists, the event after list item content is a new list
270  1 return true;
271    }
272    },
273    /**
274    * @see Listener#endList(org.xwiki.rendering.listener.ListType, java.util.Map)
275    */
276    END_LIST {
 
277  191 toggle @Override
278    public void fireEvent(Listener listener, Object... eventParameters)
279    {
280  191 listener.endList((ListType) eventParameters[0], (Map<String, String>) eventParameters[1]);
281    }
282    },
283    /**
284    * @see org.xwiki.rendering.listener.Listener#beginListItem()
285    */
286    BEGIN_LIST_ITEM {
 
287  271 toggle @Override
288    public void fireEvent(Listener listener, Object... eventParameters)
289    {
290  271 if (eventParameters.length > 0) {
291  271 listener.beginListItem((Map<String, String>) eventParameters[0]);
292    } else {
293  0 listener.beginListItem();
294    }
295    }
296    },
297    /**
298    * @see org.xwiki.rendering.listener.Listener#endListItem()
299    */
300    END_LIST_ITEM {
 
301  426 toggle @Override
302    public void fireEvent(Listener listener, Object... eventParameters)
303    {
304  426 if (eventParameters.length > 0) {
305  0 listener.endListItem((Map<String, String>) eventParameters[0]);
306    } else {
307  426 listener.endListItem();
308    }
309    }
310   
 
311  2 toggle @Override
312    public boolean isInlineEnd()
313    {
314  2 return true;
315    }
316    },
317    /**
318    * @see Listener#beginMacroMarker(String, java.util.Map, String, boolean)
319    */
320    BEGIN_MACRO_MARKER {
 
321  71 toggle @Override
322    public void fireEvent(Listener listener, Object... eventParameters)
323    {
324  71 listener.beginMacroMarker((String) eventParameters[0], (Map<String, String>) eventParameters[1],
325    (String) eventParameters[2], (Boolean) eventParameters[3]);
326    }
327    },
328    /**
329    * @see Listener#endMacroMarker(String, java.util.Map, String, boolean)