KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > io > path > PathTrackingWriter


1 package com.thoughtworks.xstream.io.path;
2
3 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
4
5 public class PathTrackingWriter implements HierarchicalStreamWriter {
6
7     private HierarchicalStreamWriter targetWriter;
8     private PathTracker pathTracker;
9
10     public PathTrackingWriter(HierarchicalStreamWriter targetWriter, PathTracker pathTracker) {
11         this.targetWriter = targetWriter;
12         this.pathTracker = pathTracker;
13     }
14
15     public void startNode(String JavaDoc name) {
16         pathTracker.pushElement(name);
17         targetWriter.startNode(name);
18     }
19
20     public void addAttribute(String JavaDoc key, String JavaDoc value) {
21         targetWriter.addAttribute(key, value);
22     }
23
24     public void setValue(String JavaDoc text) {
25         targetWriter.setValue(text);
26     }
27
28     public void endNode() {
29         targetWriter.endNode();
30         pathTracker.popElement();
31     }
32
33 }
34
Popular Tags