XStream
  1. XStream
  2. XSTR-490

Unable to get Path for use in converter

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3, 1.4
    • Fix Version/s: 1.4.3
    • Component/s: IO
    • Labels:
      None

      Description

      I need to be able to know what the parent type is when doing a conversion, which is most easily established by being able to get at the PathTracker, but, there is no API that exposes it.

      For now, I'm therefore adding the following to PathTrackingReader:

      public PathTracker getPathTracker()

      { return pathTracker; }

      My first attempt was:
      reader.moveUp();
      String parent = reader.getNodeName();
      reader.moveDown();

      Which seemed to work... until I discovered that I'd inadvertently gobbled up the next sibling element!

      And instead, I can now do:
      PathTrackingReader ptr = (PathTrackingReader) reader;
      PathTracker tracker = ptr.getPathTracker();
      String path = tracker.getPath().toString();
      int end = path.lastIndexOf('/');
      int start = path.lastIndexOf('/', end - 1) + 1;
      String parent = path.substring(start, end);

      Would you please consider making the above use case supported, either by my API change, or by another means?

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Neale
        • Votes:
          0 Vote for this issue
          Watchers:
          3 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: