1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.xml.sax; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.InputStream; |
24 |
|
import java.io.InputStreamReader; |
25 |
|
import java.io.Reader; |
26 |
|
import java.net.URL; |
27 |
|
import java.util.HashMap; |
28 |
|
import java.util.Map; |
29 |
|
|
30 |
|
import org.xml.sax.ContentHandler; |
31 |
|
import org.xml.sax.DTDHandler; |
32 |
|
import org.xml.sax.EntityResolver; |
33 |
|
import org.xml.sax.ErrorHandler; |
34 |
|
import org.xml.sax.InputSource; |
35 |
|
import org.xml.sax.SAXException; |
36 |
|
import org.xml.sax.SAXNotRecognizedException; |
37 |
|
import org.xml.sax.SAXNotSupportedException; |
38 |
|
import org.xml.sax.XMLReader; |
39 |
|
import org.xwiki.rendering.wikimodel.IWikiParser; |
40 |
|
import org.xwiki.rendering.wikimodel.WikiParserException; |
41 |
|
import org.xwiki.rendering.wikimodel.xml.WemTagNotifier; |
42 |
|
|
43 |
|
|
44 |
|
@version |
45 |
|
@since |
46 |
|
|
|
|
| 38.1% |
Uncovered Elements: 26 (42) |
Complexity: 17 |
Complexity Density: 0.65 |
|
47 |
|
public class WemReader implements XMLReader |
48 |
|
{ |
49 |
|
private ContentHandler fContentHandler; |
50 |
|
|
51 |
|
private DTDHandler fDTDHandler; |
52 |
|
|
53 |
|
private EntityResolver fEntityResolver; |
54 |
|
|
55 |
|
private ErrorHandler fErrorHandler; |
56 |
|
|
57 |
|
private IWikiParser fParser; |
58 |
|
|
59 |
|
protected Map<String, Object> fProperties = new HashMap<String, Object>(); |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
6 |
public WemReader(IWikiParser parser)... |
62 |
|
{ |
63 |
6 |
fParser = parser; |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
@see |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
public ContentHandler getContentHandler()... |
70 |
|
{ |
71 |
0 |
return fContentHandler; |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
@see |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
public DTDHandler getDTDHandler()... |
78 |
|
{ |
79 |
0 |
return fDTDHandler; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
@see |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0 |
public EntityResolver getEntityResolver()... |
86 |
|
{ |
87 |
0 |
return fEntityResolver; |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
@see |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0 |
public ErrorHandler getErrorHandler()... |
94 |
|
{ |
95 |
0 |
return fErrorHandler; |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
@see |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
0 |
public boolean getFeature(String name)... |
102 |
|
throws SAXNotRecognizedException, |
103 |
|
SAXNotSupportedException |
104 |
|
{ |
105 |
|
|
106 |
0 |
return false; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
@see |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0 |
public Object getProperty(String name)... |
113 |
|
throws SAXNotRecognizedException, |
114 |
|
SAXNotSupportedException |
115 |
|
{ |
116 |
0 |
return fProperties.get(name); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
@see |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
122 |
6 |
public void parse(InputSource input) throws IOException, SAXException... |
123 |
|
{ |
124 |
6 |
Reader reader = input.getCharacterStream(); |
125 |
6 |
parse(reader); |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
@param |
130 |
|
@throws |
131 |
|
@throws |
132 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
133 |
6 |
private void parse(Reader reader) throws SAXException, IOException... |
134 |
|
{ |
135 |
6 |
try { |
136 |
6 |
WemToSax handler = new WemToSax(fContentHandler); |
137 |
6 |
WemTagNotifier tagNotifier = new WemTagNotifier(handler); |
138 |
6 |
fParser.parse(reader, tagNotifier); |
139 |
|
} catch (WikiParserException e) { |
140 |
0 |
throw new SAXException(e); |
141 |
|
} finally { |
142 |
6 |
reader.close(); |
143 |
|
} |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
@see |
148 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
149 |
0 |
public void parse(String systemId) throws IOException, SAXException... |
150 |
|
{ |
151 |
0 |
URL url = new URL(systemId); |
152 |
0 |
InputStream input = url.openStream(); |
153 |
0 |
try { |
154 |
0 |
InputStreamReader reader = new InputStreamReader(input, "UTF-8"); |
155 |
0 |
parse(reader); |
156 |
|
} finally { |
157 |
0 |
input.close(); |
158 |
|
} |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
|
@see |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
6 |
public void setContentHandler(ContentHandler handler)... |
165 |
|
{ |
166 |
6 |
fContentHandler = handler; |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
@see |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0 |
public void setDTDHandler(DTDHandler handler)... |
173 |
|
{ |
174 |
0 |
fDTDHandler = handler; |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
@see |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
180 |
0 |
public void setEntityResolver(EntityResolver resolver)... |
181 |
|
{ |
182 |
0 |
fEntityResolver = resolver; |
183 |
|
} |
184 |
|
|
185 |
|
|
186 |
|
@see |
187 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
0 |
public void setErrorHandler(ErrorHandler handler)... |
189 |
|
{ |
190 |
0 |
fErrorHandler = handler; |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
@see |
195 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
196 |
6 |
public void setFeature(String name, boolean value)... |
197 |
|
throws SAXNotRecognizedException, |
198 |
|
SAXNotSupportedException |
199 |
|
{ |
200 |
|
|
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
|
@see |
205 |
|
|
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
6 |
public void setProperty(String name, Object value)... |
208 |
|
throws SAXNotRecognizedException, |
209 |
|
SAXNotSupportedException |
210 |
|
{ |
211 |
6 |
fProperties.put(name, value); |
212 |
|
} |
213 |
|
} |