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

File AbstractWikiObjectPropertyReader.java

 

Coverage histogram

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

Code metrics

4
15
2
2
87
49
5
0.33
7.5
1
2.5

Classes

Class Line # Actions
AbstractWikiObjectPropertyReader 39 14 0% 4 1
0.9473684494.7%
AbstractWikiObjectPropertyReader.WikiObjectProperty 44 1 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 32 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.filter.xar.internal.input;
21   
22    import javax.inject.Inject;
23    import javax.xml.stream.XMLStreamException;
24    import javax.xml.stream.XMLStreamReader;
25   
26    import org.xwiki.component.manager.ComponentLookupException;
27    import org.xwiki.filter.FilterEventParameters;
28    import org.xwiki.filter.FilterException;
29    import org.xwiki.filter.event.model.WikiObjectPropertyFilter;
30    import org.xwiki.filter.xar.input.XARInputProperties;
31    import org.xwiki.filter.xar.internal.input.ClassPropertyReader.WikiClassProperty;
32    import org.xwiki.filter.xar.internal.input.ClassReader.WikiClass;
33    import org.xwiki.xar.internal.XarObjectPropertySerializerManager;
34   
35    /**
36    * @version $Id: 468eaaf48396e396ab4214dee96fa8c2ab8af160 $
37    * @since 9.0RC1
38    */
 
39    public class AbstractWikiObjectPropertyReader extends AbstractReader
40    {
41    @Inject
42    private XarObjectPropertySerializerManager propertySerializerManager;
43   
 
44    public class WikiObjectProperty
45    {
46    public String name;
47   
48    public Object value;
49   
50    public FilterEventParameters parameters = new FilterEventParameters();
51   
 
52  12325 toggle public void send(XARInputFilter proxyFilter) throws FilterException
53    {
54  12325 proxyFilter.onWikiObjectProperty(this.name, this.value, this.parameters);
55    }
56    }
57   
 
58  12325 toggle public WikiObjectProperty readObjectProperty(XMLStreamReader xmlReader, XARInputProperties properties,
59    WikiClass wikiClass) throws XMLStreamException, FilterException
60    {
61  12325 xmlReader.nextTag();
62   
63  12325 WikiObjectProperty property = new WikiObjectProperty();
64   
65  12325 property.name = xmlReader.getLocalName();
66   
67  12325 String type;
68  12325 if (wikiClass != null) {
69  12323 WikiClassProperty classProperty = wikiClass.properties.get(property.name);
70  12323 type = classProperty != null ? classProperty.type : null;
71    } else {
72  2 type = properties.getObjectPropertyType();
73    }
74   
75  12325 try {
76  12325 property.value = this.propertySerializerManager.getPropertySerializer(type).read(xmlReader);
77    } catch (ComponentLookupException e) {
78  0 throw new FilterException("Failed to get a property parser", e);
79    }
80   
81  12325 property.parameters.put(WikiObjectPropertyFilter.PARAMETER_TYPE, type);
82   
83  12325 xmlReader.nextTag();
84   
85  12325 return property;
86    }
87    }