1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal.filter.input

File PropertyClassEventGenerator.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

4
10
1
1
76
34
3
0.3
10
1
3

Classes

Class Line # Actions
PropertyClassEventGenerator 42 10 0% 3 1
0.9333333493.3%
 

Contributing tests

This file is covered by 4 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 com.xpn.xwiki.internal.filter.input;
21   
22    import java.util.Iterator;
23   
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.filter.FilterEventParameters;
28    import org.xwiki.filter.FilterException;
29    import org.xwiki.filter.instance.input.DocumentInstanceInputProperties;
30    import org.xwiki.filter.instance.internal.input.AbstractBeanEntityEventGenerator;
31   
32    import com.xpn.xwiki.internal.filter.PropertyClassFilter;
33    import com.xpn.xwiki.objects.BaseProperty;
34    import com.xpn.xwiki.objects.classes.PropertyClass;
35   
36    /**
37    * @version $Id: c46fe87892d64a865bffb5206e870253daa80e2c $
38    * @since 6.2M1
39    */
40    @Component
41    @Singleton
 
42    public class PropertyClassEventGenerator
43    extends AbstractBeanEntityEventGenerator<PropertyClass, PropertyClassFilter, DocumentInstanceInputProperties>
44    {
 
45  68343 toggle @Override
46    public void write(PropertyClass xclassProperty, Object filter, PropertyClassFilter propertyFilter,
47    DocumentInstanceInputProperties properties) throws FilterException
48    {
49    // > WikiClassProperty
50   
51  68343 FilterEventParameters propertyParameters = FilterEventParameters.EMPTY;
52   
53  68343 String classType = xclassProperty.getClassType();
54  68343 if (xclassProperty.getClass().getSimpleName().equals(classType + "Class")) {
55    // Keep exporting the full Java class name for old/default property types to avoid breaking the XAR format
56    // (to allow XClasses created with the current version of XWiki to be imported in an older version).
57  68343 classType = xclassProperty.getClass().getName();
58    }
59   
60  68343 propertyFilter.beginWikiClassProperty(xclassProperty.getName(), classType, propertyParameters);
61   
62    // * WikiClassPropertyField
63   
64    // Iterate over values sorted by field name so that the values are
65    // exported to XML in a consistent order.
66  68343 Iterator<BaseProperty<?>> it = xclassProperty.getSortedIterator();
67  663094 while (it.hasNext()) {
68  594751 BaseProperty<?> bprop = it.next();
69  594751 propertyFilter.onWikiClassPropertyField(bprop.getName(), bprop.toText(), FilterEventParameters.EMPTY);
70    }
71   
72    // < WikiClassProperty
73   
74  68343 propertyFilter.endWikiClassProperty(xclassProperty.getName(), classType, propertyParameters);
75    }
76    }