forked from ScottOaks/JavaPerformanceTuning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOMBuilderTest.java
More file actions
45 lines (40 loc) · 1.34 KB
/
Copy pathDOMBuilderTest.java
File metadata and controls
45 lines (40 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) 2013,2014 Scott Oaks. All rights reserved.
*/
package net.sdo;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.sourceforge.sizeof.SizeOf;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class DOMBuilderTest extends AbstractParsingTest {
protected DocumentBuilderFactory dbf;
protected DocumentBuilder db;
@Override
protected void engineInit(RunParams rp) throws IOException {
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException ex) {
throw new IOException("Can't get document builder", ex);
}
db.setErrorHandler(new SAXErrorHandler());
}
@Override
protected void engineRun(InputStream in) throws IOException {
try {
db.reset();
Document doc = db.parse(in);
if (System.getProperty("parseDebug") != null) {
System.out.println("Waiting for input");
System.in.read();
}
} catch (SAXException ex) {
throw new IOException("Can't Parse" , ex);
}
}
}