package

com.thoughtworks.xstream.io.path

Library for tracking paths of nodes in documents using a subset of XPath. This subset of XPath is just enough for XStream to be able to use XPath expressions to represent references across the object graph, while still remaining very quick.

The Path class represents a path to a single node in the tree. Two absolute paths can also be compared to calculate the relative path between them. A relative path can be applied to an absolute path to calculate another absolute path.

A PathTracker can be linked to a HierarchicalStreamWriter or HierarchicalStreamReader and expose the path of wherever the node is currently positioned. This is done by wrapping the HierarchicalStreamWriter/HierarchicalStreamReader instances with a PathTrackingWriter or PathTrackingReader.

Note that the paths produced are XPath compliant, so can be read by other XPath engines. The following are examples of path expressions that the Path object supports:

  • /
  • /some/node
  • /a/b/c/b/a
  • /some[3]/node[2]/a
  • ../../../another[3]/node

Classes

Path Represents a path (subset of XPath) to a single node in the tree. 
PathTracker Maintains the current Path as a stream is moved through. 
PathTrackingReader Wrapper for HierarchicalStreamReader that tracks the path (a subset of XPath) of the current node that is being read. 
PathTrackingWriter Wrapper for HierarchicalStreamWriter that tracks the path (a subset of XPath) of the current node that is being written.