hit count |
method name |
method modifiers |
method signature |
12 |
<init> |
[public] |
void <init>(net.jaekl.qd.xml.ParseResult) |
204 |
characters |
[public] |
void characters(char[],int,int) |
12 |
endDocument |
[public] |
void endDocument() |
235 |
endElement |
[public] |
void endElement(java.lang.String,java.lang.String,java.lang.String) |
48 |
endPrefixMapping |
[public] |
void endPrefixMapping(java.lang.String) |
0 |
ignorableWhitespace |
[public] |
void ignorableWhitespace(char[],int,int) |
0 |
processingInstruction |
[public] |
void processingInstruction(java.lang.String,java.lang.String) |
12 |
setDocumentLocator |
[public] |
void setDocumentLocator(org.xml.sax.Locator) |
0 |
skippedEntity |
[public] |
void skippedEntity(java.lang.String) |
12 |
startDocument |
[public] |
void startDocument() |
235 |
startElement |
[public] |
void startElement(java.lang.String,java.lang.String,java.lang.String,org.xml.sax.Attributes) |
48 |
startPrefixMapping |
[public] |
void startPrefixMapping(java.lang.String,java.lang.String) |
1 |
|
|
2 |
|
|
3 |
|
package net.jaekl.qd.xml; |
4 |
|
|
5 |
|
import java.util.Stack; |
6 |
|
|
7 |
|
import org.xml.sax.Attributes; |
8 |
|
import org.xml.sax.ContentHandler; |
9 |
|
import org.xml.sax.Locator; |
10 |
|
import org.xml.sax.SAXException; |
11 |
|
|
12 |
|
public class ParseHandler implements ContentHandler |
13 |
|
{ |
14 |
|
Stack<ParseResult> m_stack; |
15 |
|
|
16 |
Block: 1/1 |
public ParseHandler(ParseResult root) { |
17 |
|
m_stack = new Stack<ParseResult>(); |
18 |
|
m_stack.push(root); |
19 |
|
} |
20 |
|
|
21 |
|
@Override |
22 |
|
public void characters(char[] ch, int start, int length) throws SAXException |
23 |
|
{ |
24 |
Block: 1/1 |
if (m_stack.isEmpty()) { |
25 |
Block: 1/1 Branch: 1/1 |
return; |
26 |
|
} |
27 |
|
|
28 |
|
try { |
29 |
Block: 1/1 Branch: 1/1 |
m_stack.peek().characters(ch, start, length); |
30 |
|
} |
31 |
Block: 0/1 |
catch (XmlParseException xpe) { |
32 |
|
throw new SAXException(xpe); |
33 |
|
} |
34 |
Block: 1/1 |
} |
35 |
|
|
36 |
|
@Override |
37 |
|
public void endElement(String uri, String localName, String qName) throws SAXException |
38 |
|
{ |
39 |
|
try { |
40 |
Block: 1/1 |
if (m_stack.isEmpty()) { |
41 |
Block: 1/1 Branch: 1/1 |
return; |
42 |
|
} |
43 |
|
|
44 |
Block: 1/1 Branch: 1/1 |
boolean pop = m_stack.peek().endElement(uri, localName, qName); |
45 |
|
if (pop) { |
46 |
Block: 1/1 Branch: 1/1 |
m_stack.pop(); |
47 |
|
|
48 |
|
if (m_stack.isEmpty()) { |
49 |
Block: 1/1 Branch: 1/1 |
return; |
50 |
|
} |
51 |
|
|
52 |
Block: 1/1 Branch: 1/1 |
m_stack.peek().endExternal(uri, localName, qName); |
53 |
|
} |
54 |
|
} |
55 |
Block: 0/1 |
catch (XmlParseException xpe) { |
56 |
|
throw new SAXException(xpe); |
57 |
Block: 1/1 Branch: 1/1 |
} |
58 |
Block: 1/1 |
} |
59 |
|
|
60 |
|
@Override |
61 |
|
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException |
62 |
|
{ |
63 |
|
try { |
64 |
Block: 1/1 |
ParseResult current = m_stack.peek(); |
65 |
|
ParseResult next = current.startElement(uri, localName, qName, attributes); |
66 |
|
if (next != current) { |
67 |
Block: 1/1 Branch: 1/1 |
m_stack.push(next); |
68 |
|
} |
69 |
|
} |
70 |
Block: 0/1 |
catch (XmlParseException xpe) { |
71 |
|
throw new SAXException(xpe); |
72 |
Block: 1/1 Branch: 1/1 |
} |
73 |
Block: 1/1 |
} |
74 |
|
|
75 |
|
@Override |
76 |
|
public void endDocument() throws SAXException { |
77 |
Block: 1/1 |
if (! m_stack.isEmpty()) { |
78 |
Block: 1/1 Branch: 1/1 |
String missingTag = m_stack.peek().getTagName(); |
79 |
|
throw new SAXException(new MissingInfoException(missingTag)); |
80 |
|
} |
81 |
Block: 1/1 Branch: 1/1 |
} |
82 |
|
|
83 |
|
@Override |
84 |
|
public void endPrefixMapping(String prefix) throws SAXException { |
85 |
|
|
86 |
Block: 1/1 |
} |
87 |
|
|
88 |
|
@Override |
89 |
|
public void ignorableWhitespace(char[] ch, int start, int length) |
90 |
|
throws SAXException |
91 |
|
{ |
92 |
|
|
93 |
Block: 0/1 |
} |
94 |
|
|
95 |
|
@Override |
96 |
|
public void processingInstruction(String target, String data) |
97 |
|
throws SAXException |
98 |
|
{ |
99 |
|
|
100 |
Block: 0/1 |
} |
101 |
|
|
102 |
|
@Override |
103 |
|
public void setDocumentLocator(Locator locator) { |
104 |
|
|
105 |
Block: 1/1 |
} |
106 |
|
|
107 |
|
@Override |
108 |
|
public void skippedEntity(String name) throws SAXException { |
109 |
|
|
110 |
Block: 0/1 |
} |
111 |
|
|
112 |
|
@Override |
113 |
|
public void startDocument() throws SAXException { |
114 |
|
|
115 |
Block: 1/1 |
} |
116 |
|
|
117 |
|
@Override |
118 |
|
public void startPrefixMapping(String prefix, String uri) |
119 |
|
throws SAXException |
120 |
|
{ |
121 |
|
|
122 |
Block: 1/1 |
} |
123 |
|
} |