pathtrackingreader.java

来自「xstream是一个把java object序列化成xml文件的开源库,轻便好用」· Java 代码 · 共 41 行

JAVA
41
字号
package com.thoughtworks.xstream.io.path;import com.thoughtworks.xstream.converters.ErrorWriter;import com.thoughtworks.xstream.io.HierarchicalStreamReader;import com.thoughtworks.xstream.io.ReaderWrapper;/** * Wrapper for HierarchicalStreamReader that tracks the path (a subset of XPath) of the current node that is being read. * * @see PathTracker * @see Path * * @author Joe Walnes */public class PathTrackingReader extends ReaderWrapper {    private final PathTracker pathTracker;    public PathTrackingReader(HierarchicalStreamReader reader, PathTracker pathTracker) {        super(reader);        this.pathTracker = pathTracker;        pathTracker.pushElement(getNodeName());    }    public void moveDown() {        super.moveDown();        pathTracker.pushElement(getNodeName());    }    public void moveUp() {        super.moveUp();        pathTracker.popElement();    }    public void appendErrors(ErrorWriter errorWriter) {        errorWriter.add("path", pathTracker.getPath().toString());        super.appendErrors(errorWriter);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?