/** * @deprecated As of 1.4.2 */ public Path currentPath() { return pathTracker.getPath(); }
public void endNode() { super.endNode(); pathTracker.popElement(); } }
public PathTrackingReader(HierarchicalStreamReader reader, PathTracker pathTracker) { super(reader); this.pathTracker = pathTracker; pathTracker.pushElement(getNodeName()); }
/** * Notify the tracker that the stream has moved into a new element. * * @param name Name of the element */ public void pushElement(String name) { if (pointer + 1 >= capacity) { resizeStacks(capacity * 2); } pathStack[pointer] = name; Map indexMap = indexMapStack[pointer]; if (indexMap == null) { indexMap = new HashMap(); indexMapStack[pointer] = indexMap; } if (indexMap.containsKey(name)) { indexMap.put(name, new Integer(((Integer) indexMap.get(name)).intValue() + 1)); } else { indexMap.put(name, new Integer(1)); } pointer++; currentPath = null; }
/** * Get the last path element from the stack. * * @return the name of the path element * @since 1.4.2 */ public String peekElement() { return peekElement(0); }
/** * Notify the tracker that the stream has moved into a new element. * * @param name Name of the element */ public void pushElement(final String name) { if (pointer + 1 >= capacity) { resizeStacks(capacity * 2); } pathStack[pointer] = name; Map<String, Integer> indexMap = indexMapStack[pointer]; if (indexMap == null) { indexMap = new HashMap<>(); indexMapStack[pointer] = indexMap; } if (indexMap.containsKey(name)) { indexMap.put(name, new Integer(indexMap.get(name).intValue() + 1)); } else { indexMap.put(name, new Integer(1)); } pointer++; currentPath = null; }
/** * Current Path in stream. */ public Path getPath() { if (currentPath == null) { String[] chunks = new String[pointer + 1]; chunks[0] = ""; for (int i = -pointer; ++i <= 0; ) { final String name = peekElement(i); chunks[i + pointer] = name; } currentPath = new Path(chunks); } return currentPath; } }
protected Object getCurrentReferenceKey() { return pathTracker.getPath(); }
public void moveDown() { super.moveDown(); pathTracker.pushElement(getNodeName()); }
public void moveUp() { super.moveUp(); pathTracker.popElement(); }
/** * Notify the tracker that the stream has moved into a new element. * * @param name Name of the element */ public void pushElement(String name) { if (pointer + 1 >= capacity) { resizeStacks(capacity * 2); } pathStack[pointer] = name; Map indexMap = indexMapStack[pointer]; if (indexMap == null) { indexMap = new HashMap(); indexMapStack[pointer] = indexMap; } if (indexMap.containsKey(name)) { indexMap.put(name, new Integer(((Integer) indexMap.get(name)).intValue() + 1)); } else { indexMap.put(name, new Integer(1)); } pointer++; currentPath = null; }
/** * Get the last path element from the stack. * * @return the name of the path element * @since 1.4.2 */ public String peekElement() { return peekElement(0); }
protected Object getReferenceKey(String reference) { final Path path = new Path(isNameEncoding ? ((AbstractReader)reader.underlyingReader()).decodeNode(reference) : reference); // We have absolute references, if path starts with '/' return reference.charAt(0) != '/' ? pathTracker.getPath().apply(path) : path; }
public void startNode(String name) { pathTracker.pushElement(isNameEncoding ? ((AbstractWriter)wrapped.underlyingWriter()).encodeNode(name) : name); super.startNode(name); }
@Override public void moveUp() { super.moveUp(); pathTracker.popElement(); }
/** * Notify the tracker that the stream has moved into a new element. * * @param name Name of the element */ public void pushElement(String name) { if (pointer + 1 >= capacity) { resizeStacks(capacity * 2); } pathStack[pointer] = name; Map indexMap = indexMapStack[pointer]; if (indexMap == null) { indexMap = new HashMap(); indexMapStack[pointer] = indexMap; } if (indexMap.containsKey(name)) { indexMap.put(name, new Integer(((Integer) indexMap.get(name)).intValue() + 1)); } else { indexMap.put(name, new Integer(1)); } pointer++; currentPath = null; }
/** * Get the last path element from the stack. * * @return the name of the path element * @since 1.4.2 */ public String peekElement() { return peekElement(0); }
public void appendErrors(ErrorWriter errorWriter) { errorWriter.add("path", pathTracker.getPath().toString()); super.appendErrors(errorWriter); }
public void startNode(String name, Class clazz) { pathTracker.pushElement(isNameEncoding ? ((AbstractWriter)wrapped.underlyingWriter()).encodeNode(name) : name); super.startNode(name, clazz); }
@Override public void endNode() { super.endNode(); pathTracker.popElement(); } }