|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DomXMLReaderDriver.java | - | 60% | 100% | 63.6% |
|
1 |
package com.thoughtworks.xstream.xml.dom;
|
|
2 |
|
|
3 |
import com.thoughtworks.xstream.xml.CannotParseXMLException;
|
|
4 |
import com.thoughtworks.xstream.xml.XMLReader;
|
|
5 |
import com.thoughtworks.xstream.xml.XMLReaderDriver;
|
|
6 |
import org.w3c.dom.Document;
|
|
7 |
import org.xml.sax.SAXException;
|
|
8 |
|
|
9 |
import javax.xml.parsers.DocumentBuilder;
|
|
10 |
import javax.xml.parsers.DocumentBuilderFactory;
|
|
11 |
import javax.xml.parsers.FactoryConfigurationError;
|
|
12 |
import javax.xml.parsers.ParserConfigurationException;
|
|
13 |
import java.io.ByteArrayInputStream;
|
|
14 |
import java.io.IOException;
|
|
15 |
|
|
16 |
public class DomXMLReaderDriver implements XMLReaderDriver { |
|
17 |
|
|
18 | 41 |
public XMLReader createReader(String xml) {
|
19 | 41 |
try {
|
20 | 41 |
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); |
21 | 41 |
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); |
22 | 41 |
ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes());
|
23 | 41 |
Document document = documentBuilder.parse(inputStream); |
24 | 41 |
return new DomXMLReader(document); |
25 |
} catch (FactoryConfigurationError e) {
|
|
26 | 0 |
throw new CannotParseXMLException(e); |
27 |
} catch (ParserConfigurationException e) {
|
|
28 | 0 |
throw new CannotParseXMLException(e); |
29 |
} catch (SAXException e) {
|
|
30 | 0 |
throw new CannotParseXMLException(e); |
31 |
} catch (IOException e) {
|
|
32 | 0 |
throw new CannotParseXMLException(e); |
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
|
|