01: /*
02: @license.text@
03: */
04: package com.pavelvlasov.util.samples;
05:
06: import java.io.File;
07:
08: import biz.hammurapi.util.PoliteVisitor;
09: import biz.hammurapi.xml.dom.DOMUtils;
10: import biz.hammurapi.xml.dom.DomVisitable;
11:
12: /**
13: * @author Pavel Vlasov
14: * @revision $Revision$
15: */
16: public class DomVisitableSample {
17:
18: public static void main(String[] args) throws Exception {
19: new DomVisitable(DOMUtils.parse(new File(args[0])))
20: .accept(new PoliteVisitor() {
21: int level;
22:
23: public boolean visit(Object target) {
24: for (int i = 0; i < level; i++) {
25: System.out.print("\t");
26: }
27: System.out.println("> "
28: + target.getClass().getName() + ": "
29: + target);
30: level++;
31: return true;
32: }
33:
34: public void leave(Object target) {
35: level--;
36: for (int i = 0; i < level; i++) {
37: System.out.print("\t");
38: }
39: System.out.println("< "
40: + target.getClass().getName());
41: }
42:
43: });
44: }
45: }
|