1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.filter.xml.internal.parameter

File XMLTreeUnmarshaller.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
56% of files have more coverage

Code metrics

2
6
2
1
66
28
3
0.5
3
2
1.5

Classes

Class Line # Actions
XMLTreeUnmarshaller 39 6 0% 3 2
0.880%
 

Contributing tests

This file is covered by 576 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.xml.internal.parameter;
21   
22    import java.lang.reflect.Type;
23   
24    import org.xwiki.component.util.ReflectionUtils;
25   
26    import com.thoughtworks.xstream.converters.ConversionException;
27    import com.thoughtworks.xstream.converters.ConverterLookup;
28    import com.thoughtworks.xstream.converters.DataHolder;
29    import com.thoughtworks.xstream.core.TreeUnmarshaller;
30    import com.thoughtworks.xstream.io.HierarchicalStreamReader;
31    import com.thoughtworks.xstream.mapper.Mapper;
32   
33    /**
34    * Customize {@link TreeUnmarshaller}.
35    *
36    * @version $Id: 2312234e1fc91b7e83d10088896ad61df3569bd6 $
37    * @since 5.2M1
38    */
 
39    public class XMLTreeUnmarshaller extends TreeUnmarshaller
40    {
41    /**
42    * @param root the root object
43    * @param reader the reader
44    * @param converterLookup the converter provider
45    * @param mapper the mapper
46    */
 
47  951 toggle public XMLTreeUnmarshaller(Object root, HierarchicalStreamReader reader, ConverterLookup converterLookup,
48    Mapper mapper)
49    {
50  951 super(root, reader, converterLookup, mapper);
51    }
52   
 
53  951 toggle @Override
54    public Object start(DataHolder dataHolder)
55    {
56  951 Type type = (Type) dataHolder.get(XStreamParameterManager.DDEFAULTTYPE_NAME);
57   
58  951 Class<?> typeClass = ReflectionUtils.getTypeClass(type);
59   
60  951 if (typeClass != null) {
61  951 return convertAnother(null, typeClass);
62    } else {
63  0 throw new ConversionException("Can't find any converter for the type [" + type + "]");
64    }
65    }
66    }