|
|||||||||||||||||||
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DebugVisitor.java | - | 0% | 0% | 0% |
|
1 |
/* |
|
2 |
* JBind |
|
3 |
* |
|
4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
5 |
* |
|
6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
8 |
* 'Apache Software License V 1.1'. |
|
9 |
*/ |
|
10 |
package org.jbind.xml.dom3.core; |
|
11 |
|
|
12 |
import java.io.BufferedWriter; |
|
13 |
import java.io.IOException; |
|
14 |
import java.io.OutputStream; |
|
15 |
import java.io.OutputStreamWriter; |
|
16 |
|
|
17 |
import org.jbind.xml.dom3.types.IDomAttr; |
|
18 |
import org.jbind.xml.dom3.types.IDomElement; |
|
19 |
import org.jbind.xml.dom3.types.IDomText; |
|
20 |
|
|
21 |
public class DebugVisitor extends DomVisitor { |
|
22 |
|
|
23 |
private BufferedWriter myWriter = null; |
|
24 |
|
|
25 |
private StringBuffer myIndent = new StringBuffer(); |
|
26 |
|
|
27 | 0 |
public DebugVisitor(OutputStream aStream) { |
28 | 0 |
myWriter = new BufferedWriter(new OutputStreamWriter(aStream)); |
29 |
} |
|
30 |
|
|
31 | 0 |
private void write(String aString) { |
32 | 0 |
try { |
33 | 0 |
myWriter.write(aString); |
34 |
} catch (IOException e) { |
|
35 | 0 |
e.printStackTrace(); |
36 |
} |
|
37 |
} |
|
38 |
|
|
39 | 0 |
private void writeLn(String aString) { |
40 | 0 |
try { |
41 | 0 |
myWriter.write(aString); |
42 | 0 |
myWriter.write("\n"); |
43 | 0 |
myWriter.flush(); |
44 |
} catch (IOException e) { |
|
45 | 0 |
e.printStackTrace(); |
46 |
} |
|
47 |
} |
|
48 |
|
|
49 | 0 |
private void addIndent() { |
50 | 0 |
myIndent.append(" "); |
51 |
} |
|
52 | 0 |
private void removeIndent() { |
53 | 0 |
myIndent.setLength(myIndent.length() - 2); |
54 |
} |
|
55 |
|
|
56 | 0 |
public void visitAttrStart(IDomAttr aNode) { |
57 | 0 |
writeLn("" + myIndent + "attribute: " + aNode.getLocalName() + " (" + aNode.getNamespaceURI() + ")" + " - " + aNode.getTextContent()); |
58 | 0 |
addIndent(); |
59 |
} |
|
60 |
|
|
61 | 0 |
public void visitAttrEnd(IDomAttr aNode) { |
62 | 0 |
removeIndent(); |
63 |
} |
|
64 |
|
|
65 | 0 |
public void visitElementStart(IDomElement aNode) { |
66 | 0 |
writeLn("" + myIndent + "element: " + aNode.getLocalName() + " (" + aNode.getNamespaceURI() + ")"); |
67 | 0 |
addIndent(); |
68 |
} |
|
69 |
|
|
70 | 0 |
public void visitElementEnd(IDomElement aNode) { |
71 | 0 |
removeIndent(); |
72 |
} |
|
73 |
|
|
74 | 0 |
public void visitTextStart(IDomText aNode) { |
75 | 0 |
writeLn("" + myIndent + "text: " + aNode.getTextContent()); |
76 |
} |
|
77 |
|
|
78 |
} |
|
79 |
|
|