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

File AbstractBeanInputFilterStream.java

 

Coverage histogram

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

Code metrics

0
7
5
1
83
43
5
0.71
1.4
5
1

Classes

Class Line # Actions
AbstractBeanInputFilterStream 39 7 0% 5 3
0.7575%
 

Contributing tests

This file is covered by 63 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   
21    package org.xwiki.filter.input;
22   
23    import java.lang.reflect.ParameterizedType;
24   
25    import javax.inject.Inject;
26   
27    import org.xwiki.component.phase.Initializable;
28    import org.xwiki.component.phase.InitializationException;
29    import org.xwiki.component.util.ReflectionUtils;
30    import org.xwiki.filter.FilterDescriptorManager;
31    import org.xwiki.filter.FilterException;
32   
33    /**
34    * @param <F> the type of the filter supported by this {@link InputFilterStream}
35    * @param <P> the type of the properties bean
36    * @version $Id: 3b806608849189449e45b8ec63fd2efb4f2a2e29 $
37    * @since 6.2M1
38    */
 
39    public abstract class AbstractBeanInputFilterStream<P, F> implements BeanInputFilterStream<P>, Initializable
40    {
41    @Inject
42    private FilterDescriptorManager filterDescriptorManager;
43   
44    protected Class<F> filterType;
45   
46    protected P properties;
47   
 
48  12669 toggle public AbstractBeanInputFilterStream()
49    {
50    }
51   
 
52  0 toggle public AbstractBeanInputFilterStream(FilterDescriptorManager filterDescriptorManager, P properties)
53    throws FilterException
54    {
55  0 this.filterDescriptorManager = filterDescriptorManager;
56  0 setProperties(properties);
57    }
58   
 
59  12669 toggle @Override
60    public void setProperties(P properties) throws FilterException
61    {
62  12669 this.properties = properties;
63    }
64   
 
65  12669 toggle @Override
66    public void initialize() throws InitializationException
67    {
68    // Get the type of the internal filter
69  12669 ParameterizedType genericType =
70    (ParameterizedType) ReflectionUtils.resolveType(AbstractBeanInputFilterStream.class, getClass());
71  12669 this.filterType = ReflectionUtils.getTypeClass(genericType.getActualTypeArguments()[1]);
72    }
73   
 
74  12669 toggle @Override
75    public void read(Object filter) throws FilterException
76    {
77  12669 F proxyFilter = this.filterDescriptorManager.createFilterProxy(filter, this.filterType);
78   
79  12669 read(filter, proxyFilter);
80    }
81   
82    protected abstract void read(Object filter, F proxyFilter) throws FilterException;
83    }