1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.filter.filterxml.internal.output; |
21 |
|
|
22 |
|
import java.util.Collection; |
23 |
|
import java.util.HashSet; |
24 |
|
import java.util.List; |
25 |
|
import java.util.Set; |
26 |
|
|
27 |
|
import javax.inject.Inject; |
28 |
|
import javax.inject.Named; |
29 |
|
import javax.inject.Provider; |
30 |
|
import javax.inject.Singleton; |
31 |
|
import javax.xml.stream.FactoryConfigurationError; |
32 |
|
import javax.xml.stream.XMLStreamException; |
33 |
|
import javax.xml.transform.Result; |
34 |
|
|
35 |
|
import org.apache.commons.lang3.ArrayUtils; |
36 |
|
import org.xwiki.component.annotation.Component; |
37 |
|
import org.xwiki.component.manager.ComponentLookupException; |
38 |
|
import org.xwiki.component.manager.ComponentManager; |
39 |
|
import org.xwiki.filter.FilterException; |
40 |
|
import org.xwiki.filter.UnknownFilter; |
41 |
|
import org.xwiki.filter.filterxml.internal.input.XMLInputFilterFactory; |
42 |
|
import org.xwiki.filter.filterxml.output.FilterXMLOutputProperties; |
43 |
|
import org.xwiki.filter.input.InputFilterStreamFactory; |
44 |
|
import org.xwiki.filter.type.FilterStreamType; |
45 |
|
import org.xwiki.filter.xml.internal.output.AbstractXMLBeanOutputFilterStreamFactory; |
46 |
|
import org.xwiki.filter.xml.serializer.XMLSerializerFactory; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@version |
53 |
|
@since |
54 |
|
|
55 |
|
@Component |
56 |
|
@Named("filter+xml") |
57 |
|
@Singleton |
|
|
| 94.7% |
Uncovered Elements: 1 (19) |
Complexity: 5 |
Complexity Density: 0.36 |
|
58 |
|
public class XMLOutputFilterFactory extends |
59 |
|
AbstractXMLBeanOutputFilterStreamFactory<FilterXMLOutputProperties, Object> |
60 |
|
{ |
61 |
|
@Inject |
62 |
|
private XMLSerializerFactory serializerFactory; |
63 |
|
|
64 |
|
@Inject |
65 |
|
private Provider<ComponentManager> contextComponentManager; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
70 |
25 |
public XMLOutputFilterFactory()... |
71 |
|
{ |
72 |
25 |
super(FilterStreamType.FILTER_XML); |
73 |
|
|
74 |
25 |
setName("Generic XML output stream"); |
75 |
25 |
setDescription("Write generic XML from wiki events."); |
76 |
|
} |
77 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
78 |
25 |
@Override... |
79 |
|
public Collection<Class<?>> getFilterInterfaces() throws FilterException |
80 |
|
{ |
81 |
25 |
List<InputFilterStreamFactory> factories; |
82 |
25 |
try { |
83 |
25 |
factories = this.contextComponentManager.get().getInstanceList(InputFilterStreamFactory.class); |
84 |
|
} catch (ComponentLookupException e) { |
85 |
0 |
throw new FilterException("Failed to lookup InputFilterFactory components instances", e); |
86 |
|
} |
87 |
|
|
88 |
25 |
Set<Class<?>> filters = new HashSet<Class<?>>(); |
89 |
|
|
90 |
25 |
filters.add(UnknownFilter.class); |
91 |
|
|
92 |
25 |
for (InputFilterStreamFactory factory : factories) { |
93 |
96 |
if (factory.getClass() != XMLInputFilterFactory.class) { |
94 |
71 |
filters.addAll(factory.getFilterInterfaces()); |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
25 |
return filters; |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
25 |
@Override... |
102 |
|
protected Object createListener(Result result, FilterXMLOutputProperties properties) throws XMLStreamException, |
103 |
|
FactoryConfigurationError, FilterException |
104 |
|
{ |
105 |
|
|
106 |
25 |
return this.serializerFactory.createSerializer(getFilterInterfaces().toArray(ArrayUtils.EMPTY_CLASS_ARRAY), |
107 |
|
result, null); |
108 |
|
} |
109 |
|
} |