jimu-decompiled/sources/com/thoughtworks/xstream/io/xml/AbstractDocumentReader.java
2025-05-13 19:24:51 +02:00

84 lines
2.6 KiB
Java

package com.thoughtworks.xstream.io.xml;
import com.thoughtworks.xstream.converters.ErrorWriter;
import com.thoughtworks.xstream.core.util.FastStack;
import com.thoughtworks.xstream.io.AttributeNameIterator;
import com.thoughtworks.xstream.io.naming.NameCoder;
import java.util.Iterator;
/* loaded from: classes.dex */
public abstract class AbstractDocumentReader extends AbstractXmlReader implements DocumentReader {
private Object current;
private FastStack pointers;
private static class Pointer {
public int v;
private Pointer() {
}
}
protected AbstractDocumentReader(Object obj) {
this(obj, new XmlFriendlyNameCoder());
}
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
public void appendErrors(ErrorWriter errorWriter) {
}
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
public void close() {
}
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
public Iterator getAttributeNames() {
return new AttributeNameIterator(this);
}
protected abstract Object getChild(int i);
protected abstract int getChildCount();
@Override // com.thoughtworks.xstream.io.xml.DocumentReader
public Object getCurrent() {
return this.current;
}
protected abstract Object getParent();
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
public boolean hasMoreChildren() {
return ((Pointer) this.pointers.peek()).v < getChildCount();
}
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
public void moveDown() {
Pointer pointer = (Pointer) this.pointers.peek();
this.pointers.push(new Pointer());
this.current = getChild(pointer.v);
pointer.v++;
reassignCurrentElement(this.current);
}
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
public void moveUp() {
this.current = getParent();
this.pointers.popSilently();
reassignCurrentElement(this.current);
}
protected abstract void reassignCurrentElement(Object obj);
protected AbstractDocumentReader(Object obj, NameCoder nameCoder) {
super(nameCoder);
this.pointers = new FastStack(16);
this.current = obj;
this.pointers.push(new Pointer());
reassignCurrentElement(this.current);
}
protected AbstractDocumentReader(Object obj, XmlFriendlyReplacer xmlFriendlyReplacer) {
this(obj, (NameCoder) xmlFriendlyReplacer);
}
}