1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.internal.filter.output

File BasePropertyOutputFilterStream.java

 

Coverage histogram

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

Code metrics

6
7
2
1
72
34
5
0.71
3.5
2
2.5

Classes

Class Line # Actions
BasePropertyOutputFilterStream 38 7 0% 5 2
0.866666786.7%
 

Contributing tests

This file is covered by 27 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.output;
21   
22    import org.xwiki.component.annotation.Component;
23    import org.xwiki.component.annotation.InstantiationStrategy;
24    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
25    import org.xwiki.filter.FilterEventParameters;
26    import org.xwiki.filter.FilterException;
27   
28    import com.xpn.xwiki.objects.BaseProperty;
29    import com.xpn.xwiki.objects.classes.BaseClass;
30    import com.xpn.xwiki.objects.classes.PropertyClassInterface;
31   
32    /**
33    * @version $Id: 2caff8286c9ae0425feb5fa3a752fac0ab3e0506 $
34    * @since 9.0RC1
35    */
36    @Component
37    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
38    public class BasePropertyOutputFilterStream extends AbstractEntityOutputFilterStream<BaseProperty>
39    {
40    private BaseClass currentXClass;
41   
42    /**
43    * @param currentXClass the current class
44    */
 
45  14736 toggle public void setCurrentXClass(BaseClass currentXClass)
46    {
47  14736 this.currentXClass = currentXClass;
48    }
49   
50    // Events
51   
 
52  39866 toggle @Override
53    public void onWikiObjectProperty(String name, Object value, FilterEventParameters parameters) throws FilterException
54    {
55  39866 PropertyClassInterface propertyclass = (PropertyClassInterface) this.currentXClass.safeget(name);
56   
57  39866 if (propertyclass != null) {
58  39815 BaseProperty property =
59  39815 value instanceof String ? propertyclass.fromString((String) value) : propertyclass.fromValue(value);
60   
61  39815 if (this.entity == null) {
62    // Bulletproofing using PropertyClassInterface#fromString when a String is passed (in case it's not
63    // really a String property)
64  39815 this.entity = property;
65    } else {
66  0 this.entity.apply(property, true);
67    }
68    } else {
69    // TODO: Log something ?
70    }
71    }
72    }