Exemple #1
0
  protected boolean doBasicPathsMatch(final Path path1, final Path path2) {
    if (path1.equals(path2)) {
      return true;
    }
    // ignore count designators and attribute specifications whenc omparing paths
    // ie, /a/b[3]/c/@foo for our purposes is equivalent to /a/b/c

    String path1Relpaced =
        StringUtils.chomp(path1.toString().replaceAll("\\[.*\\]", "").replaceAll("/@.*$", ""), "/");
    String path2Replaced =
        StringUtils.chomp(path2.toString().replaceAll("\\[.*\\]", "").replaceAll("/@.*$", ""), "/");

    return path1Relpaced.equals(path2Replaced);
  }
Exemple #2
0
  protected void updatePath(
      PathTrackingReader reader,
      Path path,
      Path currentPath,
      XstreamPathValueTracker pathValueTracker) {
    if (doBasicPathsMatch(path, currentPath)) {

      if (path.toString().contains("@")) {
        String attributeName = StringUtils.substringAfterLast(path.toString(), "@");
        pathValueTracker.add(path, reader.getAttribute(attributeName));

      } else {
        pathValueTracker.add(path, reader.getValue());
      }
    }
  }