public class

PathTracker

extends Object
java.lang.Object
   ↳ com.thoughtworks.xstream.io.path.PathTracker

Class Overview

Maintains the current Path as a stream is moved through.

Can be linked to a HierarchicalStreamWriter or HierarchicalStreamReader by wrapping them with a PathTrackingWriter or PathTrackingReader.

Example

 PathTracker tracker = new PathTracker();
 tracker.pushElement("table");
 tracker.pushElement("tr");
 tracker.pushElement("td");
 tracker.pushElement("form");
 tracker.popElement("form");
 tracker.popElement("td");
 tracker.pushElement("td");
 tracker.pushElement("div");

 Path path = tracker.getPath(); // returns "/table/tr/td[2]/div"
 

Summary

Public Constructors
PathTracker()
PathTracker(int initialCapacity)
Public Methods
String getCurrentPath()
This method is deprecated. Use getPath() instead.
Path getPath()
Current Path in stream.
void popElement()
Notify the tracker that the stream has moved out of an element.
void pushElement(String name)
Notify the tracker that the stream has moved into a new element.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PathTracker ()

public PathTracker (int initialCapacity)

Parameters
initialCapacity Size of the initial stack of nodes (one level per depth in the tree). Note that this is only for optimizations - the stack will resize itself if it exceeds its capacity. If in doubt, use the other constructor.

Public Methods

public String getCurrentPath ()

This method is deprecated.
Use getPath() instead.

public Path getPath ()

Current Path in stream.

public void popElement ()

Notify the tracker that the stream has moved out of an element.

public void pushElement (String name)

Notify the tracker that the stream has moved into a new element.

Parameters
name Name of the element