63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package com.thoughtworks.xstream.io.xml;
|
|
|
|
import com.thoughtworks.xstream.core.util.FastStack;
|
|
import com.thoughtworks.xstream.io.naming.NameCoder;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class AbstractDocumentWriter extends AbstractXmlWriter implements DocumentWriter {
|
|
private final FastStack nodeStack;
|
|
private final List result;
|
|
|
|
public AbstractDocumentWriter(Object obj, NameCoder nameCoder) {
|
|
super(nameCoder);
|
|
this.result = new ArrayList();
|
|
this.nodeStack = new FastStack(16);
|
|
if (obj != null) {
|
|
this.nodeStack.push(obj);
|
|
this.result.add(obj);
|
|
}
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
|
public void close() {
|
|
}
|
|
|
|
protected abstract Object createNode(String str);
|
|
|
|
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
|
public final void endNode() {
|
|
endNodeInternally();
|
|
Object pop = this.nodeStack.pop();
|
|
if (this.nodeStack.size() == 0) {
|
|
this.result.add(pop);
|
|
}
|
|
}
|
|
|
|
public void endNodeInternally() {
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
|
public void flush() {
|
|
}
|
|
|
|
protected final Object getCurrent() {
|
|
return this.nodeStack.peek();
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.io.xml.DocumentWriter
|
|
public List getTopLevelNodes() {
|
|
return this.result;
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
|
public final void startNode(String str) {
|
|
this.nodeStack.push(createNode(str));
|
|
}
|
|
|
|
public AbstractDocumentWriter(Object obj, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
|
this(obj, (NameCoder) xmlFriendlyReplacer);
|
|
}
|
|
}
|