KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thoughtworks.xstream.io.path;
2
3 import com.thoughtworks.xstream.converters.ErrorWriter;
4 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
5
6 public class PathTrackingReader implements HierarchicalStreamReader {
7     private HierarchicalStreamReader reader;
8     private PathTracker pathTracker;
9
10     public PathTrackingReader(HierarchicalStreamReader reader, PathTracker pathTracker) {
11         this.reader = reader;
12         this.pathTracker = pathTracker;
13         pathTracker.pushElement(getNodeName());
14     }
15
16     public boolean hasMoreChildren() {
17         return reader.hasMoreChildren();
18     }
19
20     public void moveDown() {
21         reader.moveDown();
22         pathTracker.pushElement(getNodeName());
23     }
24
25     public void moveUp() {
26         reader.moveUp();
27         pathTracker.popElement();
28     }
29
30     public String JavaDoc getNodeName() {
31         return reader.getNodeName();
32     }
33
34     public String JavaDoc getValue() {
35         return reader.getValue();
36     }
37
38     public String JavaDoc getAttribute(String JavaDoc name) {
39         return reader.getAttribute(name);
40     }
41
42     public Object JavaDoc peekUnderlyingNode() {
43         return reader.peekUnderlyingNode();
44     }
45
46     public void appendErrors(ErrorWriter errorWriter) {
47         errorWriter.add("path", pathTracker.getCurrentPath());
48         reader.appendErrors(errorWriter);
49     }
50 }
51
Popular Tags