Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
}
|
||||
}
|
178
sources/com/thoughtworks/xstream/io/xml/AbstractPullReader.java
Normal file
178
sources/com/thoughtworks/xstream/io/xml/AbstractPullReader.java
Normal file
@@ -0,0 +1,178 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
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 AbstractPullReader extends AbstractXmlReader {
|
||||
protected static final int COMMENT = 4;
|
||||
protected static final int END_NODE = 2;
|
||||
protected static final int OTHER = 0;
|
||||
protected static final int START_NODE = 1;
|
||||
protected static final int TEXT = 3;
|
||||
private final FastStack elementStack;
|
||||
private final FastStack lookahead;
|
||||
private final FastStack lookback;
|
||||
private boolean marked;
|
||||
private final FastStack pool;
|
||||
|
||||
private static class Event {
|
||||
int type;
|
||||
String value;
|
||||
|
||||
private Event() {
|
||||
}
|
||||
}
|
||||
|
||||
protected AbstractPullReader(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.elementStack = new FastStack(16);
|
||||
this.pool = new FastStack(16);
|
||||
this.lookahead = new FastStack(4);
|
||||
this.lookback = new FastStack(4);
|
||||
}
|
||||
|
||||
private void move() {
|
||||
Event readEvent = readEvent();
|
||||
this.pool.push(readEvent);
|
||||
int i = readEvent.type;
|
||||
if (i == 1) {
|
||||
this.elementStack.push(pullElementName());
|
||||
} else {
|
||||
if (i != 2) {
|
||||
return;
|
||||
}
|
||||
this.elementStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private Event readEvent() {
|
||||
return this.marked ? this.lookback.hasStuff() ? (Event) this.lookahead.push(this.lookback.pop()) : (Event) this.lookahead.push(readRealEvent()) : this.lookback.hasStuff() ? (Event) this.lookback.pop() : readRealEvent();
|
||||
}
|
||||
|
||||
private Event readRealEvent() {
|
||||
Event event = this.pool.hasStuff() ? (Event) this.pool.pop() : new Event();
|
||||
event.type = pullNextEvent();
|
||||
int i = event.type;
|
||||
if (i == 3) {
|
||||
event.value = pullText();
|
||||
} else if (i == 1) {
|
||||
event.value = pullElementName();
|
||||
} else {
|
||||
event.value = null;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public Iterator getAttributeNames() {
|
||||
return new AttributeNameIterator(this);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return unescapeXmlName((String) this.elementStack.peek());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
mark();
|
||||
Event readEvent = readEvent();
|
||||
StringBuffer stringBuffer = null;
|
||||
String str = null;
|
||||
while (true) {
|
||||
int i = readEvent.type;
|
||||
if (i == 3) {
|
||||
String str2 = readEvent.value;
|
||||
if (str2 != null && str2.length() > 0) {
|
||||
if (str == null) {
|
||||
str = str2;
|
||||
} else {
|
||||
if (stringBuffer == null) {
|
||||
stringBuffer = new StringBuffer(str);
|
||||
}
|
||||
stringBuffer.append(str2);
|
||||
}
|
||||
}
|
||||
} else if (i != 4) {
|
||||
break;
|
||||
}
|
||||
readEvent = readEvent();
|
||||
}
|
||||
reset();
|
||||
return stringBuffer != null ? stringBuffer.toString() : str == null ? "" : str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public boolean hasMoreChildren() {
|
||||
int i;
|
||||
mark();
|
||||
do {
|
||||
i = readEvent().type;
|
||||
if (i == 1) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
} while (i != 2);
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void mark() {
|
||||
this.marked = true;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveDown() {
|
||||
int size = this.elementStack.size();
|
||||
while (this.elementStack.size() <= size) {
|
||||
move();
|
||||
if (this.elementStack.size() < size) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveUp() {
|
||||
int size = this.elementStack.size();
|
||||
while (this.elementStack.size() >= size) {
|
||||
move();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
int i;
|
||||
mark();
|
||||
do {
|
||||
Event readEvent = readEvent();
|
||||
i = readEvent.type;
|
||||
if (i == 1) {
|
||||
reset();
|
||||
return readEvent.value;
|
||||
}
|
||||
} while (i != 2);
|
||||
reset();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract String pullElementName();
|
||||
|
||||
protected abstract int pullNextEvent();
|
||||
|
||||
protected abstract String pullText();
|
||||
|
||||
public void reset() {
|
||||
while (this.lookahead.hasStuff()) {
|
||||
this.lookback.push(this.lookahead.pop());
|
||||
}
|
||||
this.marked = false;
|
||||
}
|
||||
|
||||
protected AbstractPullReader(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractDriver;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractXmlDriver extends AbstractDriver {
|
||||
public AbstractXmlDriver() {
|
||||
this(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected XmlFriendlyReplacer xmlFriendlyReplacer() {
|
||||
NameCoder nameCoder = getNameCoder();
|
||||
if (nameCoder instanceof XmlFriendlyReplacer) {
|
||||
return (XmlFriendlyReplacer) nameCoder;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AbstractXmlDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
public AbstractXmlDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractReader;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractXmlReader extends AbstractReader {
|
||||
protected AbstractXmlReader() {
|
||||
this(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected String escapeXmlName(String str) {
|
||||
return encodeNode(str);
|
||||
}
|
||||
|
||||
public String unescapeXmlName(String str) {
|
||||
return decodeNode(str);
|
||||
}
|
||||
|
||||
protected AbstractXmlReader(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
protected AbstractXmlReader(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractWriter;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractXmlWriter extends AbstractWriter implements XmlFriendlyWriter {
|
||||
protected AbstractXmlWriter() {
|
||||
this(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyWriter
|
||||
public String escapeXmlName(String str) {
|
||||
return super.encodeNode(str);
|
||||
}
|
||||
|
||||
protected AbstractXmlWriter(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
protected AbstractXmlWriter(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.XmlHeaderAwareReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.xml.xppdom.XppDom;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractXppDomDriver extends AbstractXmlDriver {
|
||||
public AbstractXppDomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
protected abstract XmlPullParser createParser() throws XmlPullParserException;
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
XmlPullParser createParser = createParser();
|
||||
createParser.setInput(reader);
|
||||
return new XppDomReader(XppDom.build(createParser), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (XmlPullParserException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return createWriter(new OutputStreamWriter(outputStream));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return createReader(new XmlHeaderAwareReader(inputStream));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (IOException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.XmlHeaderAwareReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractXppDriver extends AbstractXmlDriver {
|
||||
public AbstractXppDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
protected abstract XmlPullParser createParser() throws XmlPullParserException;
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new XppReader(reader, createParser(), getNameCoder());
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new StreamException("Cannot create XmlPullParser", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return createWriter(new OutputStreamWriter(outputStream));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return createReader(new XmlHeaderAwareReader(inputStream));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (IOException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
}
|
45
sources/com/thoughtworks/xstream/io/xml/BEAStaxDriver.java
Normal file
45
sources/com/thoughtworks/xstream/io/xml/BEAStaxDriver.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.bea.xml.stream.MXParserFactory;
|
||||
import com.bea.xml.stream.XMLOutputFactoryBase;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BEAStaxDriver extends StaxDriver {
|
||||
public BEAStaxDriver() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLInputFactory createInputFactory() {
|
||||
MXParserFactory mXParserFactory = new MXParserFactory();
|
||||
mXParserFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
return mXParserFactory;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLOutputFactory createOutputFactory() {
|
||||
return new XMLOutputFactoryBase();
|
||||
}
|
||||
|
||||
public BEAStaxDriver(QNameMap qNameMap, XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(qNameMap, xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public BEAStaxDriver(QNameMap qNameMap, NameCoder nameCoder) {
|
||||
super(qNameMap, nameCoder);
|
||||
}
|
||||
|
||||
public BEAStaxDriver(QNameMap qNameMap) {
|
||||
super(qNameMap);
|
||||
}
|
||||
|
||||
public BEAStaxDriver(XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public BEAStaxDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
35
sources/com/thoughtworks/xstream/io/xml/CompactWriter.java
Normal file
35
sources/com/thoughtworks/xstream/io/xml/CompactWriter.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CompactWriter extends PrettyPrintWriter {
|
||||
public CompactWriter(Writer writer) {
|
||||
super(writer);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.PrettyPrintWriter
|
||||
protected void endOfLine() {
|
||||
}
|
||||
|
||||
public CompactWriter(Writer writer, int i) {
|
||||
super(writer, i);
|
||||
}
|
||||
|
||||
public CompactWriter(Writer writer, NameCoder nameCoder) {
|
||||
super(writer, nameCoder);
|
||||
}
|
||||
|
||||
public CompactWriter(Writer writer, int i, NameCoder nameCoder) {
|
||||
super(writer, i, nameCoder);
|
||||
}
|
||||
|
||||
public CompactWriter(Writer writer, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
super(writer, xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public CompactWriter(Writer writer, int i, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
super(writer, i, xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DocumentReader extends HierarchicalStreamReader {
|
||||
Object getCurrent();
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DocumentWriter extends HierarchicalStreamWriter {
|
||||
List getTopLevelNodes();
|
||||
}
|
134
sources/com/thoughtworks/xstream/io/xml/Dom4JDriver.java
Normal file
134
sources/com/thoughtworks/xstream/io/xml/Dom4JDriver.java
Normal file
@@ -0,0 +1,134 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.FilterWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Dom4JDriver extends AbstractXmlDriver {
|
||||
private DocumentFactory documentFactory;
|
||||
private OutputFormat outputFormat;
|
||||
|
||||
public Dom4JDriver() {
|
||||
this(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new Dom4JReader(createReader().read(reader), getNameCoder());
|
||||
} catch (DocumentException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
final HierarchicalStreamWriter[] hierarchicalStreamWriterArr = new HierarchicalStreamWriter[1];
|
||||
hierarchicalStreamWriterArr[0] = new Dom4JXmlWriter(new XMLWriter(new FilterWriter(writer) { // from class: com.thoughtworks.xstream.io.xml.Dom4JDriver.1
|
||||
@Override // java.io.FilterWriter, java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
hierarchicalStreamWriterArr[0].close();
|
||||
}
|
||||
}, this.outputFormat), getNameCoder());
|
||||
return hierarchicalStreamWriterArr[0];
|
||||
}
|
||||
|
||||
public DocumentFactory getDocumentFactory() {
|
||||
return this.documentFactory;
|
||||
}
|
||||
|
||||
public OutputFormat getOutputFormat() {
|
||||
return this.outputFormat;
|
||||
}
|
||||
|
||||
public void setDocumentFactory(DocumentFactory documentFactory) {
|
||||
this.documentFactory = documentFactory;
|
||||
}
|
||||
|
||||
public void setOutputFormat(OutputFormat outputFormat) {
|
||||
this.outputFormat = outputFormat;
|
||||
}
|
||||
|
||||
public Dom4JDriver(NameCoder nameCoder) {
|
||||
this(new DocumentFactory(), OutputFormat.createPrettyPrint(), nameCoder);
|
||||
this.outputFormat.setTrimText(false);
|
||||
}
|
||||
|
||||
public Dom4JDriver(DocumentFactory documentFactory, OutputFormat outputFormat) {
|
||||
this(documentFactory, outputFormat, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return new Dom4JReader(createReader().read(inputStream), getNameCoder());
|
||||
} catch (DocumentException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
Charset charset = null;
|
||||
String encoding = getOutputFormat() != null ? getOutputFormat().getEncoding() : null;
|
||||
if (encoding != null && Charset.isSupported(encoding)) {
|
||||
charset = Charset.forName(encoding);
|
||||
}
|
||||
return createWriter(charset != null ? new OutputStreamWriter(outputStream, charset) : new OutputStreamWriter(outputStream));
|
||||
}
|
||||
|
||||
public Dom4JDriver(DocumentFactory documentFactory, OutputFormat outputFormat, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.documentFactory = documentFactory;
|
||||
this.outputFormat = outputFormat;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
return new Dom4JReader(createReader().read(url), getNameCoder());
|
||||
} catch (DocumentException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
public Dom4JDriver(DocumentFactory documentFactory, OutputFormat outputFormat, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(documentFactory, outputFormat, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
return new Dom4JReader(createReader().read(file), getNameCoder());
|
||||
} catch (DocumentException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
protected SAXReader createReader() throws DocumentException {
|
||||
SAXReader sAXReader = new SAXReader();
|
||||
try {
|
||||
sAXReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
return sAXReader;
|
||||
} catch (SAXException e) {
|
||||
throw new DocumentException("Cannot disable DOCTYPE processing", e);
|
||||
}
|
||||
}
|
||||
}
|
105
sources/com/thoughtworks/xstream/io/xml/Dom4JReader.java
Normal file
105
sources/com/thoughtworks/xstream/io/xml/Dom4JReader.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.util.List;
|
||||
import org.dom4j.Branch;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Dom4JReader extends AbstractDocumentReader {
|
||||
private Element currentElement;
|
||||
|
||||
public Dom4JReader(Branch branch) {
|
||||
this(branch instanceof Element ? (Element) branch : ((Document) branch).getRootElement());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader, com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
|
||||
public void appendErrors(ErrorWriter errorWriter) {
|
||||
errorWriter.add("xpath", this.currentElement.getPath());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.currentElement.attributeValue(encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.attributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(this.currentElement.attribute(i).getQualifiedName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.currentElement.elements().get(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.currentElement.elements().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
return this.currentElement.getText();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
List elements = this.currentElement.elements();
|
||||
if (elements == null || elements.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return decodeNode(((Element) elements.get(0)).getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (Element) obj;
|
||||
}
|
||||
|
||||
public Dom4JReader(Element element) {
|
||||
this(element, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.currentElement.attribute(i).getValue();
|
||||
}
|
||||
|
||||
public Dom4JReader(Document document) {
|
||||
this(document.getRootElement());
|
||||
}
|
||||
|
||||
public Dom4JReader(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
}
|
||||
|
||||
public Dom4JReader(Document document, NameCoder nameCoder) {
|
||||
this(document.getRootElement(), nameCoder);
|
||||
}
|
||||
|
||||
public Dom4JReader(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public Dom4JReader(Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(document.getRootElement(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
71
sources/com/thoughtworks/xstream/io/xml/Dom4JWriter.java
Normal file
71
sources/com/thoughtworks/xstream/io/xml/Dom4JWriter.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.dom4j.Branch;
|
||||
import org.dom4j.DocumentFactory;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Dom4JWriter extends AbstractDocumentWriter {
|
||||
private final DocumentFactory documentFactory;
|
||||
|
||||
public Dom4JWriter(Branch branch, DocumentFactory documentFactory, NameCoder nameCoder) {
|
||||
super(branch, nameCoder);
|
||||
this.documentFactory = documentFactory;
|
||||
}
|
||||
|
||||
private Branch top() {
|
||||
return (Branch) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().addAttribute(encodeAttribute(str), str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
Element createElement = this.documentFactory.createElement(encodeNode(str));
|
||||
if (top() != null) {
|
||||
top().add(createElement);
|
||||
}
|
||||
return createElement;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().setText(str);
|
||||
}
|
||||
|
||||
public Dom4JWriter(DocumentFactory documentFactory, NameCoder nameCoder) {
|
||||
this((Branch) null, documentFactory, nameCoder);
|
||||
}
|
||||
|
||||
public Dom4JWriter(Branch branch, NameCoder nameCoder) {
|
||||
this(branch, new DocumentFactory(), nameCoder);
|
||||
}
|
||||
|
||||
public Dom4JWriter(Branch branch, DocumentFactory documentFactory, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(branch, documentFactory, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public Dom4JWriter(DocumentFactory documentFactory, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((Branch) null, documentFactory, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public Dom4JWriter(DocumentFactory documentFactory) {
|
||||
this(documentFactory, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public Dom4JWriter(Branch branch, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(branch, new DocumentFactory(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public Dom4JWriter(Branch branch) {
|
||||
this(branch, new DocumentFactory(), new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public Dom4JWriter() {
|
||||
this(new DocumentFactory(), new XmlFriendlyNameCoder());
|
||||
}
|
||||
}
|
125
sources/com/thoughtworks/xstream/io/xml/Dom4JXmlWriter.java
Normal file
125
sources/com/thoughtworks/xstream/io/xml/Dom4JXmlWriter.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastStack;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.IOException;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.dom4j.tree.DefaultElement;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Dom4JXmlWriter extends AbstractXmlWriter {
|
||||
private AttributesImpl attributes;
|
||||
private boolean children;
|
||||
private final FastStack elementStack;
|
||||
private boolean started;
|
||||
private final XMLWriter writer;
|
||||
|
||||
public Dom4JXmlWriter(XMLWriter xMLWriter) {
|
||||
this(xMLWriter, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
private void startElement() throws SAXException {
|
||||
if (this.started) {
|
||||
return;
|
||||
}
|
||||
this.writer.startElement("", "", (String) this.elementStack.peek(), this.attributes);
|
||||
this.attributes.clear();
|
||||
this.started = true;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
this.attributes.addAttribute("", "", encodeAttribute(str), "string", str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
try {
|
||||
this.writer.endDocument();
|
||||
this.writer.flush();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (SAXException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
try {
|
||||
if (this.children) {
|
||||
startElement();
|
||||
this.writer.endElement("", "", (String) this.elementStack.pop());
|
||||
return;
|
||||
}
|
||||
DefaultElement defaultElement = new DefaultElement((String) this.elementStack.pop());
|
||||
for (int i = 0; i < this.attributes.getLength(); i++) {
|
||||
defaultElement.addAttribute(this.attributes.getQName(i), this.attributes.getValue(i));
|
||||
}
|
||||
this.writer.write(defaultElement);
|
||||
this.attributes.clear();
|
||||
this.children = true;
|
||||
this.started = true;
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (SAXException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
try {
|
||||
this.writer.flush();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
char[] charArray = str.toCharArray();
|
||||
if (charArray.length > 0) {
|
||||
try {
|
||||
startElement();
|
||||
this.writer.characters(charArray, 0, charArray.length);
|
||||
this.children = true;
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
if (this.elementStack.size() > 0) {
|
||||
try {
|
||||
startElement();
|
||||
this.started = false;
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
this.elementStack.push(encodeNode(str));
|
||||
this.children = false;
|
||||
}
|
||||
|
||||
public Dom4JXmlWriter(XMLWriter xMLWriter, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.writer = xMLWriter;
|
||||
this.elementStack = new FastStack(16);
|
||||
this.attributes = new AttributesImpl();
|
||||
try {
|
||||
xMLWriter.startDocument();
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Dom4JXmlWriter(XMLWriter xMLWriter, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(xMLWriter, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
152
sources/com/thoughtworks/xstream/io/xml/DomDriver.java
Normal file
152
sources/com/thoughtworks/xstream/io/xml/DomDriver.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DomDriver extends AbstractXmlDriver {
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$javax$xml$parsers$DocumentBuilderFactory;
|
||||
private DocumentBuilderFactory documentBuilderFactory;
|
||||
private final String encoding;
|
||||
|
||||
public DomDriver() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected DocumentBuilderFactory createDocumentBuilderFactory() {
|
||||
Class cls;
|
||||
Class<?> cls2;
|
||||
DocumentBuilderFactory newInstance = DocumentBuilderFactory.newInstance();
|
||||
if (JVM.isVersion(5)) {
|
||||
try {
|
||||
if (class$javax$xml$parsers$DocumentBuilderFactory == null) {
|
||||
cls = class$("javax.xml.parsers.DocumentBuilderFactory");
|
||||
class$javax$xml$parsers$DocumentBuilderFactory = cls;
|
||||
} else {
|
||||
cls = class$javax$xml$parsers$DocumentBuilderFactory;
|
||||
}
|
||||
Class<?>[] clsArr = new Class[2];
|
||||
if (class$java$lang$String == null) {
|
||||
cls2 = class$("java.lang.String");
|
||||
class$java$lang$String = cls2;
|
||||
} else {
|
||||
cls2 = class$java$lang$String;
|
||||
}
|
||||
clsArr[0] = cls2;
|
||||
clsArr[1] = Boolean.TYPE;
|
||||
cls.getMethod("setFeature", clsArr).invoke(newInstance, "http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ObjectAccessException("Cannot set feature of DocumentBuilderFactory.", e);
|
||||
} catch (NoSuchMethodException unused) {
|
||||
} catch (InvocationTargetException e2) {
|
||||
Throwable cause = e2.getCause();
|
||||
if (JVM.isVersion(6) || ((cause instanceof ParserConfigurationException) && cause.getMessage().indexOf("disallow-doctype-decl") < 0)) {
|
||||
throw new StreamException(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
newInstance.setExpandEntityReferences(false);
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
return createReader(new InputSource(reader));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
public DomDriver(String str) {
|
||||
this(str, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
return createReader(new InputSource(inputStream));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
try {
|
||||
return createWriter(this.encoding != null ? new OutputStreamWriter(outputStream, this.encoding) : new OutputStreamWriter(outputStream));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DomDriver(String str, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.encoding = str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
return createReader(new InputSource(url.toExternalForm()));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
return createReader(new InputSource(file.toURI().toASCIIString()));
|
||||
}
|
||||
|
||||
public DomDriver(String str, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(str, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
private HierarchicalStreamReader createReader(InputSource inputSource) {
|
||||
try {
|
||||
if (this.documentBuilderFactory == null) {
|
||||
synchronized (this) {
|
||||
if (this.documentBuilderFactory == null) {
|
||||
this.documentBuilderFactory = createDocumentBuilderFactory();
|
||||
}
|
||||
}
|
||||
}
|
||||
DocumentBuilder newDocumentBuilder = this.documentBuilderFactory.newDocumentBuilder();
|
||||
if (this.encoding != null) {
|
||||
inputSource.setEncoding(this.encoding);
|
||||
}
|
||||
return new DomReader(newDocumentBuilder.parse(inputSource), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (FactoryConfigurationError e2) {
|
||||
throw new StreamException(e2);
|
||||
} catch (ParserConfigurationException e3) {
|
||||
throw new StreamException(e3);
|
||||
} catch (SAXException e4) {
|
||||
throw new StreamException(e4);
|
||||
}
|
||||
}
|
||||
}
|
126
sources/com/thoughtworks/xstream/io/xml/DomReader.java
Normal file
126
sources/com/thoughtworks/xstream/io/xml/DomReader.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DomReader extends AbstractDocumentReader {
|
||||
private List childElements;
|
||||
private Element currentElement;
|
||||
private StringBuffer textBuffer;
|
||||
|
||||
public DomReader(Element element) {
|
||||
this(element, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
Attr attributeNode = this.currentElement.getAttributeNode(encodeAttribute(str));
|
||||
if (attributeNode == null) {
|
||||
return null;
|
||||
}
|
||||
return attributeNode.getValue();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.getAttributes().getLength();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(((Attr) this.currentElement.getAttributes().item(i)).getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.childElements.get(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.childElements.size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getTagName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParentNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
NodeList childNodes = this.currentElement.getChildNodes();
|
||||
this.textBuffer.setLength(0);
|
||||
int length = childNodes.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
Node item = childNodes.item(i);
|
||||
if (item instanceof Text) {
|
||||
this.textBuffer.append(((Text) item).getData());
|
||||
}
|
||||
}
|
||||
return this.textBuffer.toString();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
NodeList childNodes = this.currentElement.getChildNodes();
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node item = childNodes.item(i);
|
||||
if (item instanceof Element) {
|
||||
return decodeNode(((Element) item).getTagName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (Element) obj;
|
||||
NodeList childNodes = this.currentElement.getChildNodes();
|
||||
this.childElements = new ArrayList();
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node item = childNodes.item(i);
|
||||
if (item instanceof Element) {
|
||||
this.childElements.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DomReader(Document document) {
|
||||
this(document.getDocumentElement());
|
||||
}
|
||||
|
||||
public DomReader(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
this.textBuffer = new StringBuffer();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return ((Attr) this.currentElement.getAttributes().item(i)).getValue();
|
||||
}
|
||||
|
||||
public DomReader(Document document, NameCoder nameCoder) {
|
||||
this(document.getDocumentElement(), nameCoder);
|
||||
}
|
||||
|
||||
public DomReader(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public DomReader(Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(document.getDocumentElement(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
71
sources/com/thoughtworks/xstream/io/xml/DomWriter.java
Normal file
71
sources/com/thoughtworks/xstream/io/xml/DomWriter.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DomWriter extends AbstractDocumentWriter {
|
||||
private final Document document;
|
||||
private boolean hasRootElement;
|
||||
|
||||
public DomWriter(Document document) {
|
||||
this(document, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
private Element top() {
|
||||
return (Element) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().setAttribute(encodeAttribute(str), str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
Element createElement = this.document.createElement(encodeNode(str));
|
||||
if (top() != null) {
|
||||
top().appendChild(createElement);
|
||||
} else if (!this.hasRootElement) {
|
||||
this.document.appendChild(createElement);
|
||||
this.hasRootElement = true;
|
||||
}
|
||||
return createElement;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().appendChild(this.document.createTextNode(str));
|
||||
}
|
||||
|
||||
public DomWriter(Element element) {
|
||||
this(element, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public DomWriter(Document document, NameCoder nameCoder) {
|
||||
this(document.getDocumentElement(), document, nameCoder);
|
||||
}
|
||||
|
||||
public DomWriter(Element element, Document document, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
this.document = document;
|
||||
this.hasRootElement = document.getDocumentElement() != null;
|
||||
}
|
||||
|
||||
public DomWriter(Element element, NameCoder nameCoder) {
|
||||
this(element, element.getOwnerDocument(), nameCoder);
|
||||
}
|
||||
|
||||
public DomWriter(Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(document.getDocumentElement(), document, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public DomWriter(Element element, Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, document, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public DomWriter(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, element.getOwnerDocument(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
88
sources/com/thoughtworks/xstream/io/xml/JDom2Driver.java
Normal file
88
sources/com/thoughtworks/xstream/io/xml/JDom2Driver.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractDriver;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import org.jdom2.JDOMException;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDom2Driver extends AbstractDriver {
|
||||
public JDom2Driver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected SAXBuilder createBuilder() {
|
||||
SAXBuilder sAXBuilder = new SAXBuilder();
|
||||
sAXBuilder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
return sAXBuilder;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new JDom2Reader(createBuilder().build(reader), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
public JDom2Driver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return new PrettyPrintWriter(new OutputStreamWriter(outputStream));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return new JDom2Reader(createBuilder().build(inputStream), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
return new JDom2Reader(createBuilder().build(url), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
return new JDom2Reader(createBuilder().build(file), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
}
|
87
sources/com/thoughtworks/xstream/io/xml/JDom2Reader.java
Normal file
87
sources/com/thoughtworks/xstream/io/xml/JDom2Reader.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.util.List;
|
||||
import org.jdom2.Attribute;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDom2Reader extends AbstractDocumentReader {
|
||||
private Element currentElement;
|
||||
|
||||
public JDom2Reader(Element element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.currentElement.getAttributeValue(encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.getAttributes().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(((Attribute) this.currentElement.getAttributes().get(i)).getQualifiedName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.currentElement.getChildren().get(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.currentElement.getChildren().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParentElement();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
return this.currentElement.getText();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
List children = this.currentElement.getChildren();
|
||||
if (children == null || children.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return decodeNode(((Element) children.get(0)).getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (Element) obj;
|
||||
}
|
||||
|
||||
public JDom2Reader(Document document) {
|
||||
super(document.getRootElement());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return ((Attribute) this.currentElement.getAttributes().get(i)).getValue();
|
||||
}
|
||||
|
||||
public JDom2Reader(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
}
|
||||
|
||||
public JDom2Reader(Document document, NameCoder nameCoder) {
|
||||
super(document.getRootElement(), nameCoder);
|
||||
}
|
||||
}
|
64
sources/com/thoughtworks/xstream/io/xml/JDom2Writer.java
Normal file
64
sources/com/thoughtworks/xstream/io/xml/JDom2Writer.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.jdom2.DefaultJDOMFactory;
|
||||
import org.jdom2.Element;
|
||||
import org.jdom2.JDOMFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDom2Writer extends AbstractDocumentWriter {
|
||||
private final JDOMFactory documentFactory;
|
||||
|
||||
public JDom2Writer(Element element, JDOMFactory jDOMFactory, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
this.documentFactory = jDOMFactory;
|
||||
}
|
||||
|
||||
private Element top() {
|
||||
return (Element) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().setAttribute(this.documentFactory.attribute(encodeAttribute(str), str2));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
Element element = this.documentFactory.element(encodeNode(str));
|
||||
Element pVar = top();
|
||||
if (pVar != null) {
|
||||
pVar.addContent(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().addContent(this.documentFactory.text(str));
|
||||
}
|
||||
|
||||
public JDom2Writer(Element element, JDOMFactory jDOMFactory) {
|
||||
this(element, jDOMFactory, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public JDom2Writer(JDOMFactory jDOMFactory, NameCoder nameCoder) {
|
||||
this(null, jDOMFactory, nameCoder);
|
||||
}
|
||||
|
||||
public JDom2Writer(JDOMFactory jDOMFactory) {
|
||||
this((Element) null, jDOMFactory);
|
||||
}
|
||||
|
||||
public JDom2Writer(Element element, NameCoder nameCoder) {
|
||||
this(element, new DefaultJDOMFactory(), nameCoder);
|
||||
}
|
||||
|
||||
public JDom2Writer(Element element) {
|
||||
this(element, (JDOMFactory) new DefaultJDOMFactory());
|
||||
}
|
||||
|
||||
public JDom2Writer() {
|
||||
this((JDOMFactory) new DefaultJDOMFactory());
|
||||
}
|
||||
}
|
91
sources/com/thoughtworks/xstream/io/xml/JDomDriver.java
Normal file
91
sources/com/thoughtworks/xstream/io/xml/JDomDriver.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDomDriver extends AbstractXmlDriver {
|
||||
public JDomDriver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected SAXBuilder createBuilder() {
|
||||
SAXBuilder sAXBuilder = new SAXBuilder();
|
||||
sAXBuilder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
return sAXBuilder;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new JDomReader(createBuilder().build(reader), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
public JDomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return new PrettyPrintWriter(new OutputStreamWriter(outputStream));
|
||||
}
|
||||
|
||||
public JDomDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return new JDomReader(createBuilder().build(inputStream), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
return new JDomReader(createBuilder().build(url), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
return new JDomReader(createBuilder().build(file), getNameCoder());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (JDOMException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
}
|
95
sources/com/thoughtworks/xstream/io/xml/JDomReader.java
Normal file
95
sources/com/thoughtworks/xstream/io/xml/JDomReader.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.util.List;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDomReader extends AbstractDocumentReader {
|
||||
private Element currentElement;
|
||||
|
||||
public JDomReader(Element element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.currentElement.getAttributeValue(encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.getAttributes().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(((Attribute) this.currentElement.getAttributes().get(i)).getQualifiedName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.currentElement.getChildren().get(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.currentElement.getChildren().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParentElement();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
return this.currentElement.getText();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
List children = this.currentElement.getChildren();
|
||||
if (children == null || children.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return decodeNode(((Element) children.get(0)).getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (Element) obj;
|
||||
}
|
||||
|
||||
public JDomReader(Document document) {
|
||||
super(document.getRootElement());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return ((Attribute) this.currentElement.getAttributes().get(i)).getValue();
|
||||
}
|
||||
|
||||
public JDomReader(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
}
|
||||
|
||||
public JDomReader(Document document, NameCoder nameCoder) {
|
||||
super(document.getRootElement(), nameCoder);
|
||||
}
|
||||
|
||||
public JDomReader(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public JDomReader(Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(document.getRootElement(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
76
sources/com/thoughtworks/xstream/io/xml/JDomWriter.java
Normal file
76
sources/com/thoughtworks/xstream/io/xml/JDomWriter.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.jdom.DefaultJDOMFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JDomWriter extends AbstractDocumentWriter {
|
||||
private final JDOMFactory documentFactory;
|
||||
|
||||
public JDomWriter(Element element, JDOMFactory jDOMFactory, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
this.documentFactory = jDOMFactory;
|
||||
}
|
||||
|
||||
private Element top() {
|
||||
return (Element) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().setAttribute(this.documentFactory.attribute(encodeAttribute(str), str2));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
Element element = this.documentFactory.element(encodeNode(str));
|
||||
Element pVar = top();
|
||||
if (pVar != null) {
|
||||
pVar.addContent(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().addContent(this.documentFactory.text(str));
|
||||
}
|
||||
|
||||
public JDomWriter(Element element, JDOMFactory jDOMFactory, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, jDOMFactory, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public JDomWriter(Element element, JDOMFactory jDOMFactory) {
|
||||
this(element, jDOMFactory, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public JDomWriter(JDOMFactory jDOMFactory, NameCoder nameCoder) {
|
||||
this((Element) null, jDOMFactory, nameCoder);
|
||||
}
|
||||
|
||||
public JDomWriter(JDOMFactory jDOMFactory, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((Element) null, jDOMFactory, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public JDomWriter(JDOMFactory jDOMFactory) {
|
||||
this((Element) null, jDOMFactory);
|
||||
}
|
||||
|
||||
public JDomWriter(Element element, NameCoder nameCoder) {
|
||||
this(element, (JDOMFactory) new DefaultJDOMFactory(), nameCoder);
|
||||
}
|
||||
|
||||
public JDomWriter(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (JDOMFactory) new DefaultJDOMFactory(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public JDomWriter(Element element) {
|
||||
this(element, (JDOMFactory) new DefaultJDOMFactory());
|
||||
}
|
||||
|
||||
public JDomWriter() {
|
||||
this((JDOMFactory) new DefaultJDOMFactory());
|
||||
}
|
||||
}
|
21
sources/com/thoughtworks/xstream/io/xml/KXml2DomDriver.java
Normal file
21
sources/com/thoughtworks/xstream/io/xml/KXml2DomDriver.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.kxml2.io.KXmlParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class KXml2DomDriver extends AbstractXppDomDriver {
|
||||
public KXml2DomDriver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDomDriver
|
||||
protected XmlPullParser createParser() {
|
||||
return new KXmlParser();
|
||||
}
|
||||
|
||||
public KXml2DomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
21
sources/com/thoughtworks/xstream/io/xml/KXml2Driver.java
Normal file
21
sources/com/thoughtworks/xstream/io/xml/KXml2Driver.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.kxml2.io.KXmlParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class KXml2Driver extends AbstractXppDriver {
|
||||
public KXml2Driver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDriver
|
||||
protected XmlPullParser createParser() {
|
||||
return new KXmlParser();
|
||||
}
|
||||
|
||||
public KXml2Driver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
269
sources/com/thoughtworks/xstream/io/xml/PrettyPrintWriter.java
Normal file
269
sources/com/thoughtworks/xstream/io/xml/PrettyPrintWriter.java
Normal file
@@ -0,0 +1,269 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastStack;
|
||||
import com.thoughtworks.xstream.core.util.QuickWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PrettyPrintWriter extends AbstractXmlWriter {
|
||||
public static int XML_1_0 = 0;
|
||||
public static int XML_1_1 = 1;
|
||||
public static int XML_QUIRKS = -1;
|
||||
protected int depth;
|
||||
private final FastStack elementStack;
|
||||
private final char[] lineIndenter;
|
||||
private final int mode;
|
||||
private String newLine;
|
||||
private boolean readyForNewLine;
|
||||
private boolean tagInProgress;
|
||||
private boolean tagIsEmpty;
|
||||
private final QuickWriter writer;
|
||||
private static final char[] NULL = "�".toCharArray();
|
||||
private static final char[] AMP = "&".toCharArray();
|
||||
private static final char[] LT = "<".toCharArray();
|
||||
private static final char[] GT = ">".toCharArray();
|
||||
private static final char[] CR = "
".toCharArray();
|
||||
private static final char[] QUOT = """.toCharArray();
|
||||
private static final char[] APOS = "'".toCharArray();
|
||||
private static final char[] CLOSE = "</".toCharArray();
|
||||
|
||||
private PrettyPrintWriter(Writer writer, int i, char[] cArr, NameCoder nameCoder, String str) {
|
||||
super(nameCoder);
|
||||
this.elementStack = new FastStack(16);
|
||||
this.writer = new QuickWriter(writer);
|
||||
this.lineIndenter = cArr;
|
||||
this.newLine = str;
|
||||
this.mode = i;
|
||||
if (i < XML_QUIRKS || i > XML_1_1) {
|
||||
throw new IllegalArgumentException("Not a valid XML mode");
|
||||
}
|
||||
}
|
||||
|
||||
private void finishTag() {
|
||||
if (this.tagInProgress) {
|
||||
this.writer.write('>');
|
||||
}
|
||||
this.tagInProgress = false;
|
||||
if (this.readyForNewLine) {
|
||||
endOfLine();
|
||||
}
|
||||
this.readyForNewLine = false;
|
||||
this.tagIsEmpty = false;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
this.writer.write(' ');
|
||||
this.writer.write(encodeAttribute(str));
|
||||
this.writer.write('=');
|
||||
this.writer.write('\"');
|
||||
writeAttributeValue(this.writer, str2);
|
||||
this.writer.write('\"');
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
this.writer.close();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
this.depth--;
|
||||
if (this.tagIsEmpty) {
|
||||
this.writer.write('/');
|
||||
this.readyForNewLine = false;
|
||||
finishTag();
|
||||
this.elementStack.popSilently();
|
||||
} else {
|
||||
finishTag();
|
||||
this.writer.write(CLOSE);
|
||||
this.writer.write((String) this.elementStack.pop());
|
||||
this.writer.write('>');
|
||||
}
|
||||
this.readyForNewLine = true;
|
||||
if (this.depth == 0) {
|
||||
this.writer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
protected void endOfLine() {
|
||||
this.writer.write(getNewLine());
|
||||
for (int i = 0; i < this.depth; i++) {
|
||||
this.writer.write(this.lineIndenter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
this.writer.flush();
|
||||
}
|
||||
|
||||
protected String getNewLine() {
|
||||
return this.newLine;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
this.readyForNewLine = false;
|
||||
this.tagIsEmpty = false;
|
||||
finishTag();
|
||||
writeText(this.writer, str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
String encodeNode = encodeNode(str);
|
||||
this.tagIsEmpty = false;
|
||||
finishTag();
|
||||
this.writer.write('<');
|
||||
this.writer.write(encodeNode);
|
||||
this.elementStack.push(encodeNode);
|
||||
this.tagInProgress = true;
|
||||
this.depth++;
|
||||
this.readyForNewLine = true;
|
||||
this.tagIsEmpty = true;
|
||||
}
|
||||
|
||||
protected void writeAttributeValue(QuickWriter quickWriter, String str) {
|
||||
writeText(str, true);
|
||||
}
|
||||
|
||||
protected void writeText(QuickWriter quickWriter, String str) {
|
||||
writeText(str, false);
|
||||
}
|
||||
|
||||
private void writeText(String str, boolean z) {
|
||||
int length = str.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
char charAt = str.charAt(i);
|
||||
if (charAt == 0) {
|
||||
if (this.mode != XML_QUIRKS) {
|
||||
throw new StreamException("Invalid character 0x0 in XML stream");
|
||||
}
|
||||
this.writer.write(NULL);
|
||||
} else if (charAt == '\r') {
|
||||
this.writer.write(CR);
|
||||
} else if (charAt == '\"') {
|
||||
this.writer.write(QUOT);
|
||||
} else if (charAt == '<') {
|
||||
this.writer.write(LT);
|
||||
} else if (charAt == '>') {
|
||||
this.writer.write(GT);
|
||||
} else if (charAt == '\t' || charAt == '\n') {
|
||||
if (!z) {
|
||||
this.writer.write(charAt);
|
||||
}
|
||||
if (Character.isDefined(charAt) || Character.isISOControl(charAt)) {
|
||||
if (this.mode != XML_1_0 && (charAt < '\t' || charAt == 11 || charAt == '\f' || charAt == 14 || (charAt >= 15 && charAt <= 31))) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Invalid character 0x");
|
||||
stringBuffer.append(Integer.toHexString(charAt));
|
||||
stringBuffer.append(" in XML 1.0 stream");
|
||||
throw new StreamException(stringBuffer.toString());
|
||||
}
|
||||
if (this.mode == XML_QUIRKS && (charAt == 65534 || charAt == 65535)) {
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append("Invalid character 0x");
|
||||
stringBuffer2.append(Integer.toHexString(charAt));
|
||||
stringBuffer2.append(" in XML stream");
|
||||
throw new StreamException(stringBuffer2.toString());
|
||||
}
|
||||
this.writer.write("&#x");
|
||||
this.writer.write(Integer.toHexString(charAt));
|
||||
this.writer.write(';');
|
||||
} else {
|
||||
if (this.mode != XML_QUIRKS && charAt > 55295 && charAt < 57344) {
|
||||
StringBuffer stringBuffer3 = new StringBuffer();
|
||||
stringBuffer3.append("Invalid character 0x");
|
||||
stringBuffer3.append(Integer.toHexString(charAt));
|
||||
stringBuffer3.append(" in XML stream");
|
||||
throw new StreamException(stringBuffer3.toString());
|
||||
}
|
||||
this.writer.write(charAt);
|
||||
}
|
||||
} else if (charAt != '&') {
|
||||
if (charAt == '\'') {
|
||||
this.writer.write(APOS);
|
||||
}
|
||||
if (Character.isDefined(charAt)) {
|
||||
}
|
||||
if (this.mode != XML_1_0) {
|
||||
}
|
||||
if (this.mode == XML_QUIRKS) {
|
||||
}
|
||||
this.writer.write("&#x");
|
||||
this.writer.write(Integer.toHexString(charAt));
|
||||
this.writer.write(';');
|
||||
} else {
|
||||
this.writer.write(AMP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, char[] cArr, String str, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(writer, XML_QUIRKS, cArr, xmlFriendlyReplacer, str);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, char[] cArr, NameCoder nameCoder) {
|
||||
this(writer, i, cArr, nameCoder, "\n");
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, char[] cArr, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(writer, i, cArr, xmlFriendlyReplacer, "\n");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractWriter, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
startNode(str);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, char[] cArr, String str) {
|
||||
this(writer, cArr, str, new XmlFriendlyReplacer());
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, char[] cArr) {
|
||||
this(writer, i, cArr, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, char[] cArr) {
|
||||
this(writer, XML_QUIRKS, cArr);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, String str, String str2) {
|
||||
this(writer, str.toCharArray(), str2);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, String str) {
|
||||
this(writer, i, str.toCharArray());
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, String str) {
|
||||
this(writer, str.toCharArray());
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, NameCoder nameCoder) {
|
||||
this(writer, i, new char[]{' ', ' '}, nameCoder);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(writer, i, new char[]{' ', ' '}, xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, NameCoder nameCoder) {
|
||||
this(writer, XML_QUIRKS, new char[]{' ', ' '}, nameCoder, "\n");
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(writer, new char[]{' ', ' '}, "\n", xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer, int i) {
|
||||
this(writer, i, new char[]{' ', ' '});
|
||||
}
|
||||
|
||||
public PrettyPrintWriter(Writer writer) {
|
||||
this(writer, new char[]{' ', ' '});
|
||||
}
|
||||
}
|
57
sources/com/thoughtworks/xstream/io/xml/QNameMap.java
Normal file
57
sources/com/thoughtworks/xstream/io/xml/QNameMap.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class QNameMap {
|
||||
private Map javaToQName;
|
||||
private Map qnameToJava;
|
||||
private String defaultPrefix = "";
|
||||
private String defaultNamespace = "";
|
||||
|
||||
public String getDefaultNamespace() {
|
||||
return this.defaultNamespace;
|
||||
}
|
||||
|
||||
public String getDefaultPrefix() {
|
||||
return this.defaultPrefix;
|
||||
}
|
||||
|
||||
public String getJavaClassName(QName qName) {
|
||||
String str;
|
||||
Map map = this.qnameToJava;
|
||||
return (map == null || (str = (String) map.get(qName)) == null) ? qName.getLocalPart() : str;
|
||||
}
|
||||
|
||||
public QName getQName(String str) {
|
||||
QName qName;
|
||||
Map map = this.javaToQName;
|
||||
return (map == null || (qName = (QName) map.get(str)) == null) ? new QName(this.defaultNamespace, str, this.defaultPrefix) : qName;
|
||||
}
|
||||
|
||||
public synchronized void registerMapping(QName qName, String str) {
|
||||
if (this.javaToQName == null) {
|
||||
this.javaToQName = Collections.synchronizedMap(new HashMap());
|
||||
}
|
||||
if (this.qnameToJava == null) {
|
||||
this.qnameToJava = Collections.synchronizedMap(new HashMap());
|
||||
}
|
||||
this.javaToQName.put(str, qName);
|
||||
this.qnameToJava.put(qName, str);
|
||||
}
|
||||
|
||||
public void setDefaultNamespace(String str) {
|
||||
this.defaultNamespace = str;
|
||||
}
|
||||
|
||||
public void setDefaultPrefix(String str) {
|
||||
this.defaultPrefix = str;
|
||||
}
|
||||
|
||||
public synchronized void registerMapping(QName qName, Class cls) {
|
||||
registerMapping(qName, cls.getName());
|
||||
}
|
||||
}
|
303
sources/com/thoughtworks/xstream/io/xml/SaxWriter.java
Normal file
303
sources/com/thoughtworks/xstream/io/xml/SaxWriter.java
Normal file
@@ -0,0 +1,303 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.DTDHandler;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class SaxWriter extends AbstractXmlWriter implements XMLReader {
|
||||
public static final String CONFIGURED_XSTREAM_PROPERTY = "http://com.thoughtworks.xstream/sax/property/configured-xstream";
|
||||
public static final String SOURCE_OBJECT_LIST_PROPERTY = "http://com.thoughtworks.xstream/sax/property/source-object-list";
|
||||
private final AttributesImpl attributeList;
|
||||
private char[] buffer;
|
||||
private ContentHandler contentHandler;
|
||||
private int depth;
|
||||
private DTDHandler dtdHandler;
|
||||
private List elementStack;
|
||||
private EntityResolver entityResolver;
|
||||
private ErrorHandler errorHandler;
|
||||
private Map features;
|
||||
private final boolean includeEnclosingDocument;
|
||||
private final Map properties;
|
||||
private boolean startTagInProgress;
|
||||
|
||||
public SaxWriter(NameCoder nameCoder) {
|
||||
this(true, nameCoder);
|
||||
}
|
||||
|
||||
private void endDocument(boolean z) throws SAXException {
|
||||
int i = this.depth;
|
||||
if (i == 0 || (i == 1 && z)) {
|
||||
this.contentHandler.endDocument();
|
||||
this.depth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void flushStartTag() throws SAXException {
|
||||
if (this.startTagInProgress) {
|
||||
String str = (String) this.elementStack.get(0);
|
||||
this.contentHandler.startElement("", str, str, this.attributeList);
|
||||
this.attributeList.clear();
|
||||
this.startTagInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void startDocument(boolean z) throws SAXException {
|
||||
if (this.depth == 0) {
|
||||
this.contentHandler.startDocument();
|
||||
if (z) {
|
||||
this.depth++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
if (!this.startTagInProgress) {
|
||||
throw new StreamException(new IllegalStateException("No startElement being processed"));
|
||||
}
|
||||
String escapeXmlName = escapeXmlName(str);
|
||||
this.attributeList.addAttribute("", escapeXmlName, escapeXmlName, "CDATA", str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
try {
|
||||
flushStartTag();
|
||||
String str = (String) this.elementStack.remove(0);
|
||||
this.contentHandler.endElement("", str, str);
|
||||
this.depth--;
|
||||
if (this.depth == 0 && this.includeEnclosingDocument) {
|
||||
endDocument(false);
|
||||
}
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public ContentHandler getContentHandler() {
|
||||
return this.contentHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public DTDHandler getDTDHandler() {
|
||||
return this.dtdHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public EntityResolver getEntityResolver() {
|
||||
return this.entityResolver;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public ErrorHandler getErrorHandler() {
|
||||
return this.errorHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public boolean getFeature(String str) throws SAXNotRecognizedException {
|
||||
if (!str.equals("http://xml.org/sax/features/namespaces") && !str.equals("http://xml.org/sax/features/namespace-prefixes")) {
|
||||
throw new SAXNotRecognizedException(str);
|
||||
}
|
||||
Boolean bool = (Boolean) this.features.get(str);
|
||||
if (bool == null) {
|
||||
bool = Boolean.FALSE;
|
||||
}
|
||||
return bool.booleanValue();
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public Object getProperty(String str) throws SAXNotRecognizedException {
|
||||
if (str.equals(CONFIGURED_XSTREAM_PROPERTY) || str.equals(SOURCE_OBJECT_LIST_PROPERTY)) {
|
||||
return this.properties.get(str);
|
||||
}
|
||||
throw new SAXNotRecognizedException(str);
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void parse(String str) throws SAXException {
|
||||
parse();
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setContentHandler(ContentHandler contentHandler) {
|
||||
if (contentHandler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
}
|
||||
this.contentHandler = contentHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setDTDHandler(DTDHandler dTDHandler) {
|
||||
if (dTDHandler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
}
|
||||
this.dtdHandler = dTDHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setEntityResolver(EntityResolver entityResolver) {
|
||||
if (entityResolver == null) {
|
||||
throw new NullPointerException("resolver");
|
||||
}
|
||||
this.entityResolver = entityResolver;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
if (errorHandler == null) {
|
||||
throw new NullPointerException("handler");
|
||||
}
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setFeature(String str, boolean z) throws SAXNotRecognizedException {
|
||||
if (!str.equals("http://xml.org/sax/features/namespaces") && !str.equals("http://xml.org/sax/features/namespace-prefixes")) {
|
||||
throw new SAXNotRecognizedException(str);
|
||||
}
|
||||
this.features.put(str, z ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void setProperty(String str, Object obj) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if (str.equals(CONFIGURED_XSTREAM_PROPERTY)) {
|
||||
if (!(obj instanceof XStream)) {
|
||||
throw new SAXNotSupportedException("Value for property \"http://com.thoughtworks.xstream/sax/property/configured-xstream\" must be a non-null XStream object");
|
||||
}
|
||||
} else {
|
||||
if (!str.equals(SOURCE_OBJECT_LIST_PROPERTY)) {
|
||||
throw new SAXNotRecognizedException(str);
|
||||
}
|
||||
if (!(obj instanceof List)) {
|
||||
throw new SAXNotSupportedException("Value for property \"http://com.thoughtworks.xstream/sax/property/source-object-list\" must be a non-null List object");
|
||||
}
|
||||
List list = (List) obj;
|
||||
if (list.isEmpty()) {
|
||||
throw new SAXNotSupportedException("Value for property \"http://com.thoughtworks.xstream/sax/property/source-object-list\" shall not be an empty list");
|
||||
}
|
||||
obj = Collections.unmodifiableList(new ArrayList(list));
|
||||
}
|
||||
this.properties.put(str, obj);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
try {
|
||||
flushStartTag();
|
||||
int length = str.length();
|
||||
if (length > this.buffer.length) {
|
||||
this.buffer = new char[length];
|
||||
}
|
||||
str.getChars(0, length, this.buffer, 0);
|
||||
this.contentHandler.characters(this.buffer, 0, length);
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
try {
|
||||
if (this.depth != 0) {
|
||||
flushStartTag();
|
||||
} else if (this.includeEnclosingDocument) {
|
||||
startDocument(false);
|
||||
}
|
||||
this.elementStack.add(0, escapeXmlName(str));
|
||||
this.startTagInProgress = true;
|
||||
this.depth++;
|
||||
} catch (SAXException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public SaxWriter(boolean z, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.entityResolver = null;
|
||||
this.dtdHandler = null;
|
||||
this.contentHandler = null;
|
||||
this.errorHandler = null;
|
||||
this.features = new HashMap();
|
||||
this.properties = new HashMap();
|
||||
this.depth = 0;
|
||||
this.elementStack = new LinkedList();
|
||||
this.buffer = new char[PeripheralType.SERVO];
|
||||
this.startTagInProgress = false;
|
||||
this.attributeList = new AttributesImpl();
|
||||
this.includeEnclosingDocument = z;
|
||||
}
|
||||
|
||||
@Override // org.xml.sax.XMLReader
|
||||
public void parse(InputSource inputSource) throws SAXException {
|
||||
parse();
|
||||
}
|
||||
|
||||
private void parse() throws SAXException {
|
||||
XStream xStream = (XStream) this.properties.get(CONFIGURED_XSTREAM_PROPERTY);
|
||||
if (xStream == null) {
|
||||
xStream = new XStream();
|
||||
}
|
||||
List list = (List) this.properties.get(SOURCE_OBJECT_LIST_PROPERTY);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
try {
|
||||
startDocument(true);
|
||||
Iterator it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
xStream.marshal(it.next(), this);
|
||||
}
|
||||
endDocument(true);
|
||||
return;
|
||||
} catch (StreamException e) {
|
||||
if (e.getCause() instanceof SAXException) {
|
||||
throw ((SAXException) e.getCause());
|
||||
}
|
||||
throw new SAXException(e);
|
||||
}
|
||||
}
|
||||
throw new SAXException("Missing or empty source object list. Setting property \"http://com.thoughtworks.xstream/sax/property/source-object-list\" is mandatory");
|
||||
}
|
||||
|
||||
public SaxWriter(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(true, xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public SaxWriter(boolean z, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(z, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public SaxWriter(boolean z) {
|
||||
this(z, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public SaxWriter() {
|
||||
this(true);
|
||||
}
|
||||
}
|
43
sources/com/thoughtworks/xstream/io/xml/SjsxpDriver.java
Normal file
43
sources/com/thoughtworks/xstream/io/xml/SjsxpDriver.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SjsxpDriver extends StaxDriver {
|
||||
public SjsxpDriver() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLInputFactory createInputFactory() {
|
||||
try {
|
||||
XMLInputFactory xMLInputFactory = (XMLInputFactory) Class.forName("com.sun.xml.internal.stream.XMLInputFactoryImpl").newInstance();
|
||||
xMLInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
return xMLInputFactory;
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
throw new StreamException("Cannot create SJSXP (Sun JDK 6 StAX) XMLInputFaqctory instance.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLOutputFactory createOutputFactory() {
|
||||
try {
|
||||
return (XMLOutputFactory) Class.forName("com.sun.xml.internal.stream.XMLOutputFactoryImpl").newInstance();
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
throw new StreamException("Cannot create SJSXP (Sun JDK 6 StAX) XMLOutputFaqctory instance.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public SjsxpDriver(QNameMap qNameMap, XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(qNameMap, xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public SjsxpDriver(QNameMap qNameMap) {
|
||||
super(qNameMap);
|
||||
}
|
||||
|
||||
public SjsxpDriver(XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(xmlFriendlyNameCoder);
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StandardStaxDriver extends StaxDriver {
|
||||
public StandardStaxDriver() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLInputFactory createInputFactory() {
|
||||
try {
|
||||
Class staxInputFactory = JVM.getStaxInputFactory();
|
||||
if (staxInputFactory == null) {
|
||||
throw new StreamException("Java runtime has no standard XMLInputFactory implementation.", null);
|
||||
}
|
||||
XMLInputFactory xMLInputFactory = (XMLInputFactory) staxInputFactory.newInstance();
|
||||
xMLInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
return xMLInputFactory;
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
throw new StreamException("Cannot create standard XMLInputFactory instance of Java runtime.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLOutputFactory createOutputFactory() {
|
||||
try {
|
||||
Class staxOutputFactory = JVM.getStaxOutputFactory();
|
||||
if (staxOutputFactory != null) {
|
||||
return (XMLOutputFactory) staxOutputFactory.newInstance();
|
||||
}
|
||||
throw new StreamException("Java runtime has no standard XMLOutputFactory implementation.", null);
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
throw new StreamException("Cannot create standard XMLOutputFactory instance of Java runtime.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public StandardStaxDriver(QNameMap qNameMap, XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(qNameMap, xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public StandardStaxDriver(QNameMap qNameMap, NameCoder nameCoder) {
|
||||
super(qNameMap, nameCoder);
|
||||
}
|
||||
|
||||
public StandardStaxDriver(QNameMap qNameMap) {
|
||||
super(qNameMap);
|
||||
}
|
||||
|
||||
public StandardStaxDriver(XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public StandardStaxDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
197
sources/com/thoughtworks/xstream/io/xml/StaxDriver.java
Normal file
197
sources/com/thoughtworks/xstream/io/xml/StaxDriver.java
Normal file
@@ -0,0 +1,197 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.ReaderWrapper;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StaxDriver extends AbstractXmlDriver {
|
||||
private XMLInputFactory inputFactory;
|
||||
private XMLOutputFactory outputFactory;
|
||||
private QNameMap qnameMap;
|
||||
|
||||
public StaxDriver() {
|
||||
this(new QNameMap());
|
||||
}
|
||||
|
||||
protected XMLInputFactory createInputFactory() {
|
||||
XMLInputFactory newInstance = XMLInputFactory.newInstance();
|
||||
newInstance.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
protected XMLOutputFactory createOutputFactory() {
|
||||
return XMLOutputFactory.newInstance();
|
||||
}
|
||||
|
||||
protected XMLStreamReader createParser(Reader reader) throws XMLStreamException {
|
||||
return getInputFactory().createXMLStreamReader(reader);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return createStaxReader(createParser(reader));
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractPullReader createStaxReader(XMLStreamReader xMLStreamReader) {
|
||||
return new StaxReader(this.qnameMap, xMLStreamReader, getNameCoder());
|
||||
}
|
||||
|
||||
public StaxWriter createStaxWriter(XMLStreamWriter xMLStreamWriter, boolean z) throws XMLStreamException {
|
||||
return new StaxWriter(this.qnameMap, xMLStreamWriter, z, isRepairingNamespace(), getNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
try {
|
||||
return createStaxWriter(getOutputFactory().createXMLStreamWriter(writer));
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
public XMLInputFactory getInputFactory() {
|
||||
if (this.inputFactory == null) {
|
||||
this.inputFactory = createInputFactory();
|
||||
}
|
||||
return this.inputFactory;
|
||||
}
|
||||
|
||||
public XMLOutputFactory getOutputFactory() {
|
||||
if (this.outputFactory == null) {
|
||||
this.outputFactory = createOutputFactory();
|
||||
}
|
||||
return this.outputFactory;
|
||||
}
|
||||
|
||||
public QNameMap getQnameMap() {
|
||||
return this.qnameMap;
|
||||
}
|
||||
|
||||
public boolean isRepairingNamespace() {
|
||||
return Boolean.TRUE.equals(getOutputFactory().getProperty("javax.xml.stream.isRepairingNamespaces"));
|
||||
}
|
||||
|
||||
public void setQnameMap(QNameMap qNameMap) {
|
||||
this.qnameMap = qNameMap;
|
||||
}
|
||||
|
||||
public void setRepairingNamespace(boolean z) {
|
||||
getOutputFactory().setProperty("javax.xml.stream.isRepairingNamespaces", z ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public StaxDriver(QNameMap qNameMap) {
|
||||
this(qNameMap, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected XMLStreamReader createParser(InputStream inputStream) throws XMLStreamException {
|
||||
return getInputFactory().createXMLStreamReader(inputStream);
|
||||
}
|
||||
|
||||
public StaxWriter createStaxWriter(XMLStreamWriter xMLStreamWriter) throws XMLStreamException {
|
||||
return createStaxWriter(xMLStreamWriter, true);
|
||||
}
|
||||
|
||||
public StaxDriver(QNameMap qNameMap, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.qnameMap = qNameMap;
|
||||
}
|
||||
|
||||
protected XMLStreamReader createParser(Source source) throws XMLStreamException {
|
||||
return getInputFactory().createXMLStreamReader(source);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return createStaxReader(createParser(inputStream));
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
try {
|
||||
return createStaxWriter(getOutputFactory().createXMLStreamWriter(outputStream));
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
public StaxDriver(NameCoder nameCoder) {
|
||||
this(new QNameMap(), nameCoder);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
final InputStream openStream = url.openStream();
|
||||
return new ReaderWrapper(createStaxReader(createParser(new StreamSource(openStream, url.toExternalForm())))) { // from class: com.thoughtworks.xstream.io.xml.StaxDriver.1
|
||||
@Override // com.thoughtworks.xstream.io.ReaderWrapper, com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void close() {
|
||||
super.close();
|
||||
try {
|
||||
openStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (IOException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
public StaxDriver(QNameMap qNameMap, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(qNameMap, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public StaxDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(new QNameMap(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
final FileInputStream fileInputStream = new FileInputStream(file);
|
||||
return new ReaderWrapper(createStaxReader(createParser(new StreamSource(fileInputStream, file.toURI().toASCIIString())))) { // from class: com.thoughtworks.xstream.io.xml.StaxDriver.2
|
||||
@Override // com.thoughtworks.xstream.io.ReaderWrapper, com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void close() {
|
||||
super.close();
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (XMLStreamException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
}
|
||||
}
|
||||
}
|
98
sources/com/thoughtworks/xstream/io/xml/StaxReader.java
Normal file
98
sources/com/thoughtworks/xstream/io/xml/StaxReader.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StaxReader extends AbstractPullReader {
|
||||
private final XMLStreamReader in;
|
||||
private final QNameMap qnameMap;
|
||||
|
||||
public StaxReader(QNameMap qNameMap, XMLStreamReader xMLStreamReader) {
|
||||
this(qNameMap, xMLStreamReader, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
|
||||
public void appendErrors(ErrorWriter errorWriter) {
|
||||
errorWriter.add("line number", String.valueOf(this.in.getLocation().getLineNumber()));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void close() {
|
||||
try {
|
||||
this.in.close();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.in.getAttributeValue((String) null, encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.in.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(this.in.getAttributeLocalName(i));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected String pullElementName() {
|
||||
return this.qnameMap.getJavaClassName(this.in.getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected int pullNextEvent() {
|
||||
try {
|
||||
int next = this.in.next();
|
||||
if (next != 1) {
|
||||
if (next != 2) {
|
||||
if (next == 4) {
|
||||
return 3;
|
||||
}
|
||||
if (next == 5) {
|
||||
return 4;
|
||||
}
|
||||
if (next != 7) {
|
||||
if (next != 8) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected String pullText() {
|
||||
return this.in.getText();
|
||||
}
|
||||
|
||||
public StaxReader(QNameMap qNameMap, XMLStreamReader xMLStreamReader, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.qnameMap = qNameMap;
|
||||
this.in = xMLStreamReader;
|
||||
moveDown();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.in.getAttributeValue(i);
|
||||
}
|
||||
|
||||
public StaxReader(QNameMap qNameMap, XMLStreamReader xMLStreamReader, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(qNameMap, xMLStreamReader, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
142
sources/com/thoughtworks/xstream/io/xml/StaxWriter.java
Normal file
142
sources/com/thoughtworks/xstream/io/xml/StaxWriter.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StaxWriter extends AbstractXmlWriter {
|
||||
private boolean namespaceRepairingMode;
|
||||
private final XMLStreamWriter out;
|
||||
private final QNameMap qnameMap;
|
||||
private int tagDepth;
|
||||
private final boolean writeEnclosingDocument;
|
||||
|
||||
public StaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter) throws XMLStreamException {
|
||||
this(qNameMap, xMLStreamWriter, true, true);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
try {
|
||||
this.out.writeAttribute(encodeAttribute(str), str2);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
try {
|
||||
this.out.close();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
try {
|
||||
this.tagDepth--;
|
||||
this.out.writeEndElement();
|
||||
if (this.tagDepth == 0 && this.writeEnclosingDocument) {
|
||||
this.out.writeEndDocument();
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
try {
|
||||
this.out.flush();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
protected QNameMap getQNameMap() {
|
||||
return this.qnameMap;
|
||||
}
|
||||
|
||||
protected XMLStreamWriter getXMLStreamWriter() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
public boolean isNamespaceRepairingMode() {
|
||||
return this.namespaceRepairingMode;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
try {
|
||||
this.out.writeCharacters(str);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
QName qName;
|
||||
String prefix;
|
||||
String namespaceURI;
|
||||
boolean z;
|
||||
boolean z2;
|
||||
boolean z3;
|
||||
try {
|
||||
qName = this.qnameMap.getQName(encodeNode(str));
|
||||
prefix = qName.getPrefix();
|
||||
namespaceURI = qName.getNamespaceURI();
|
||||
z = false;
|
||||
z2 = prefix != null && prefix.length() > 0;
|
||||
z3 = namespaceURI != null && namespaceURI.length() > 0;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
if (z3) {
|
||||
z = z2 ? true : true;
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
this.out.writeStartElement(prefix, qName.getLocalPart(), namespaceURI);
|
||||
if (z2) {
|
||||
this.out.setPrefix(prefix, namespaceURI);
|
||||
} else if (z3 && z) {
|
||||
this.out.setDefaultNamespace(namespaceURI);
|
||||
}
|
||||
if (z3 && z && !isNamespaceRepairingMode()) {
|
||||
if (z2) {
|
||||
this.out.writeNamespace(prefix, namespaceURI);
|
||||
} else {
|
||||
this.out.writeDefaultNamespace(namespaceURI);
|
||||
}
|
||||
}
|
||||
this.tagDepth++;
|
||||
}
|
||||
|
||||
public StaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, NameCoder nameCoder) throws XMLStreamException {
|
||||
this(qNameMap, xMLStreamWriter, true, true, nameCoder);
|
||||
}
|
||||
|
||||
public StaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2, NameCoder nameCoder) throws XMLStreamException {
|
||||
super(nameCoder);
|
||||
this.qnameMap = qNameMap;
|
||||
this.out = xMLStreamWriter;
|
||||
this.writeEnclosingDocument = z;
|
||||
this.namespaceRepairingMode = z2;
|
||||
if (z) {
|
||||
xMLStreamWriter.writeStartDocument();
|
||||
}
|
||||
}
|
||||
|
||||
public StaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2) throws XMLStreamException {
|
||||
this(qNameMap, xMLStreamWriter, z, z2, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public StaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2, XmlFriendlyReplacer xmlFriendlyReplacer) throws XMLStreamException {
|
||||
this(qNameMap, xMLStreamWriter, z, z2, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
143
sources/com/thoughtworks/xstream/io/xml/TraxSource.java
Normal file
143
sources/com/thoughtworks/xstream/io/xml/TraxSource.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLFilter;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TraxSource extends SAXSource {
|
||||
public static final String XSTREAM_FEATURE = "http://com.thoughtworks.xstream/XStreamSource/feature";
|
||||
private List source;
|
||||
private XMLReader xmlReader;
|
||||
private XStream xstream;
|
||||
|
||||
public TraxSource() {
|
||||
super(new InputSource());
|
||||
this.xmlReader = null;
|
||||
this.xstream = null;
|
||||
this.source = null;
|
||||
}
|
||||
|
||||
private void configureXMLReader() {
|
||||
XMLReader xMLReader = this.xmlReader;
|
||||
if (xMLReader != null) {
|
||||
try {
|
||||
if (this.xstream != null) {
|
||||
xMLReader.setProperty(SaxWriter.CONFIGURED_XSTREAM_PROPERTY, this.xstream);
|
||||
}
|
||||
if (this.source != null) {
|
||||
this.xmlReader.setProperty(SaxWriter.SOURCE_OBJECT_LIST_PROPERTY, this.source);
|
||||
}
|
||||
} catch (SAXException e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createXMLReader(XMLReader xMLReader) {
|
||||
XMLFilter xMLFilter;
|
||||
if (xMLReader == null) {
|
||||
this.xmlReader = new SaxWriter();
|
||||
} else {
|
||||
if (!(xMLReader instanceof XMLFilter)) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
XMLReader xMLReader2 = xMLReader;
|
||||
while (true) {
|
||||
xMLFilter = (XMLFilter) xMLReader2;
|
||||
if (!(xMLFilter.getParent() instanceof XMLFilter)) {
|
||||
break;
|
||||
} else {
|
||||
xMLReader2 = xMLFilter.getParent();
|
||||
}
|
||||
}
|
||||
if (!(xMLFilter.getParent() instanceof SaxWriter)) {
|
||||
xMLFilter.setParent(new SaxWriter());
|
||||
}
|
||||
this.xmlReader = xMLReader;
|
||||
}
|
||||
configureXMLReader();
|
||||
}
|
||||
|
||||
@Override // javax.xml.transform.sax.SAXSource
|
||||
public XMLReader getXMLReader() {
|
||||
if (this.xmlReader == null) {
|
||||
createXMLReader(null);
|
||||
}
|
||||
return this.xmlReader;
|
||||
}
|
||||
|
||||
@Override // javax.xml.transform.sax.SAXSource
|
||||
public void setInputSource(InputSource inputSource) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setSource(Object obj) {
|
||||
if (obj == null) {
|
||||
throw new IllegalArgumentException("obj");
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(1);
|
||||
arrayList.add(obj);
|
||||
setSourceAsList(arrayList);
|
||||
}
|
||||
|
||||
public void setSourceAsList(List list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
throw new IllegalArgumentException("list");
|
||||
}
|
||||
this.source = list;
|
||||
configureXMLReader();
|
||||
}
|
||||
|
||||
@Override // javax.xml.transform.sax.SAXSource
|
||||
public void setXMLReader(XMLReader xMLReader) {
|
||||
createXMLReader(xMLReader);
|
||||
}
|
||||
|
||||
public void setXStream(XStream xStream) {
|
||||
if (xStream == null) {
|
||||
throw new IllegalArgumentException("xstream");
|
||||
}
|
||||
this.xstream = xStream;
|
||||
configureXMLReader();
|
||||
}
|
||||
|
||||
public TraxSource(Object obj) {
|
||||
super(new InputSource());
|
||||
this.xmlReader = null;
|
||||
this.xstream = null;
|
||||
this.source = null;
|
||||
setSource(obj);
|
||||
}
|
||||
|
||||
public TraxSource(Object obj, XStream xStream) {
|
||||
super(new InputSource());
|
||||
this.xmlReader = null;
|
||||
this.xstream = null;
|
||||
this.source = null;
|
||||
setSource(obj);
|
||||
setXStream(xStream);
|
||||
}
|
||||
|
||||
public TraxSource(List list) {
|
||||
super(new InputSource());
|
||||
this.xmlReader = null;
|
||||
this.xstream = null;
|
||||
this.source = null;
|
||||
setSourceAsList(list);
|
||||
}
|
||||
|
||||
public TraxSource(List list, XStream xStream) {
|
||||
super(new InputSource());
|
||||
this.xmlReader = null;
|
||||
this.xstream = null;
|
||||
this.source = null;
|
||||
setSourceAsList(list);
|
||||
setXStream(xStream);
|
||||
}
|
||||
}
|
45
sources/com/thoughtworks/xstream/io/xml/WstxDriver.java
Normal file
45
sources/com/thoughtworks/xstream/io/xml/WstxDriver.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.ctc.wstx.stax.WstxInputFactory;
|
||||
import com.ctc.wstx.stax.WstxOutputFactory;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WstxDriver extends StaxDriver {
|
||||
public WstxDriver() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLInputFactory createInputFactory() {
|
||||
WstxInputFactory wstxInputFactory = new WstxInputFactory();
|
||||
wstxInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
return wstxInputFactory;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.StaxDriver
|
||||
protected XMLOutputFactory createOutputFactory() {
|
||||
return new WstxOutputFactory();
|
||||
}
|
||||
|
||||
public WstxDriver(QNameMap qNameMap, XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(qNameMap, xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public WstxDriver(QNameMap qNameMap, NameCoder nameCoder) {
|
||||
super(qNameMap, nameCoder);
|
||||
}
|
||||
|
||||
public WstxDriver(QNameMap qNameMap) {
|
||||
super(qNameMap);
|
||||
}
|
||||
|
||||
public WstxDriver(XmlFriendlyNameCoder xmlFriendlyNameCoder) {
|
||||
super(xmlFriendlyNameCoder);
|
||||
}
|
||||
|
||||
public WstxDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XStream11NameCoder extends XmlFriendlyNameCoder {
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder, com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder, com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
return str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XStream11XmlFriendlyReplacer extends XmlFriendlyReplacer {
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder, com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder, com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.XmlFriendlyReplacer
|
||||
public String unescapeName(String str) {
|
||||
return str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,343 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XmlFriendlyNameCoder implements NameCoder, Cloneable {
|
||||
private static final IntPair[] XML_NAME_CHAR_EXTRA_BOUNDS;
|
||||
private static final IntPair[] XML_NAME_START_CHAR_BOUNDS;
|
||||
private final String dollarReplacement;
|
||||
private transient Map escapeCache;
|
||||
private final String escapeCharReplacement;
|
||||
private final String hexPrefix;
|
||||
private transient Map unescapeCache;
|
||||
|
||||
private static class IntPair {
|
||||
int max;
|
||||
int min;
|
||||
|
||||
public IntPair(int i, int i2) {
|
||||
this.min = i;
|
||||
this.max = i2;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r0v0, types: [com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder$1IntPairList, java.util.ArrayList] */
|
||||
static {
|
||||
?? r0 = new ArrayList() { // from class: com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder.1IntPairList
|
||||
void add(int i, int i2) {
|
||||
super.add((C1IntPairList) new IntPair(i, i2));
|
||||
}
|
||||
|
||||
void add(char c) {
|
||||
super.add((C1IntPairList) new IntPair(c, c));
|
||||
}
|
||||
};
|
||||
r0.add(':');
|
||||
r0.add(65, 90);
|
||||
r0.add(97, 122);
|
||||
r0.add('_');
|
||||
r0.add(192, 214);
|
||||
r0.add(216, 246);
|
||||
r0.add(248, 767);
|
||||
r0.add(880, 893);
|
||||
r0.add(895, 8191);
|
||||
r0.add(8204, 8205);
|
||||
r0.add(8304, 8591);
|
||||
r0.add(11264, 12271);
|
||||
r0.add(12289, 55295);
|
||||
r0.add(63744, 64975);
|
||||
r0.add(65008, 65533);
|
||||
r0.add(65536, 983039);
|
||||
XML_NAME_START_CHAR_BOUNDS = (IntPair[]) r0.toArray(new IntPair[r0.size()]);
|
||||
r0.clear();
|
||||
r0.add('-');
|
||||
r0.add('.');
|
||||
r0.add(48, 57);
|
||||
r0.add((char) 183);
|
||||
r0.add(768, 879);
|
||||
r0.add(8255, 8256);
|
||||
XML_NAME_CHAR_EXTRA_BOUNDS = (IntPair[]) r0.toArray(new IntPair[r0.size()]);
|
||||
}
|
||||
|
||||
public XmlFriendlyNameCoder() {
|
||||
this("_-", "__");
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:12:0x0034, code lost:
|
||||
|
||||
return r9;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private java.lang.String decodeName(java.lang.String r9) {
|
||||
/*
|
||||
r8 = this;
|
||||
java.util.Map r0 = r8.unescapeCache
|
||||
java.lang.Object r0 = r0.get(r9)
|
||||
java.lang.String r0 = (java.lang.String) r0
|
||||
if (r0 != 0) goto Lb0
|
||||
java.lang.String r0 = r8.dollarReplacement
|
||||
r1 = 0
|
||||
char r0 = r0.charAt(r1)
|
||||
java.lang.String r2 = r8.escapeCharReplacement
|
||||
char r2 = r2.charAt(r1)
|
||||
java.lang.String r3 = r8.hexPrefix
|
||||
char r3 = r3.charAt(r1)
|
||||
int r4 = r9.length()
|
||||
r5 = 0
|
||||
L22:
|
||||
if (r5 >= r4) goto L32
|
||||
char r6 = r9.charAt(r5)
|
||||
if (r6 == r0) goto L32
|
||||
if (r6 == r2) goto L32
|
||||
if (r6 != r3) goto L2f
|
||||
goto L32
|
||||
L2f:
|
||||
int r5 = r5 + 1
|
||||
goto L22
|
||||
L32:
|
||||
if (r5 != r4) goto L35
|
||||
return r9
|
||||
L35:
|
||||
java.lang.StringBuffer r6 = new java.lang.StringBuffer
|
||||
int r7 = r4 + 8
|
||||
r6.<init>(r7)
|
||||
if (r5 <= 0) goto L45
|
||||
java.lang.String r1 = r9.substring(r1, r5)
|
||||
r6.append(r1)
|
||||
L45:
|
||||
if (r5 >= r4) goto La7
|
||||
char r1 = r9.charAt(r5)
|
||||
if (r1 != r0) goto L64
|
||||
java.lang.String r7 = r8.dollarReplacement
|
||||
boolean r7 = r9.startsWith(r7, r5)
|
||||
if (r7 == 0) goto L64
|
||||
java.lang.String r1 = r8.dollarReplacement
|
||||
int r1 = r1.length()
|
||||
int r1 = r1 + (-1)
|
||||
int r5 = r5 + r1
|
||||
r1 = 36
|
||||
r6.append(r1)
|
||||
goto La4
|
||||
L64:
|
||||
if (r1 != r3) goto L88
|
||||
java.lang.String r7 = r8.hexPrefix
|
||||
boolean r7 = r9.startsWith(r7, r5)
|
||||
if (r7 == 0) goto L88
|
||||
java.lang.String r1 = r8.hexPrefix
|
||||
int r1 = r1.length()
|
||||
int r5 = r5 + r1
|
||||
int r1 = r5 + 4
|
||||
java.lang.String r1 = r9.substring(r5, r1)
|
||||
r7 = 16
|
||||
int r1 = java.lang.Integer.parseInt(r1, r7)
|
||||
char r1 = (char) r1
|
||||
int r5 = r5 + 3
|
||||
r6.append(r1)
|
||||
goto La4
|
||||
L88:
|
||||
if (r1 != r2) goto La1
|
||||
java.lang.String r7 = r8.escapeCharReplacement
|
||||
boolean r7 = r9.startsWith(r7, r5)
|
||||
if (r7 == 0) goto La1
|
||||
java.lang.String r1 = r8.escapeCharReplacement
|
||||
int r1 = r1.length()
|
||||
int r1 = r1 + (-1)
|
||||
int r5 = r5 + r1
|
||||
r1 = 95
|
||||
r6.append(r1)
|
||||
goto La4
|
||||
La1:
|
||||
r6.append(r1)
|
||||
La4:
|
||||
int r5 = r5 + 1
|
||||
goto L45
|
||||
La7:
|
||||
java.lang.String r0 = r6.toString()
|
||||
java.util.Map r1 = r8.unescapeCache
|
||||
r1.put(r9, r0)
|
||||
Lb0:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder.decodeName(java.lang.String):java.lang.String");
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:16:0x002c, code lost:
|
||||
|
||||
return r8;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private java.lang.String encodeName(java.lang.String r8) {
|
||||
/*
|
||||
r7 = this;
|
||||
java.util.Map r0 = r7.escapeCache
|
||||
java.lang.Object r0 = r0.get(r8)
|
||||
java.lang.String r0 = (java.lang.String) r0
|
||||
if (r0 != 0) goto L9c
|
||||
int r0 = r8.length()
|
||||
r1 = 0
|
||||
r2 = 0
|
||||
L10:
|
||||
r3 = 95
|
||||
r4 = 36
|
||||
if (r2 >= r0) goto L2a
|
||||
char r5 = r8.charAt(r2)
|
||||
if (r5 == r4) goto L2a
|
||||
if (r5 == r3) goto L2a
|
||||
r6 = 27
|
||||
if (r5 <= r6) goto L2a
|
||||
r6 = 127(0x7f, float:1.78E-43)
|
||||
if (r5 < r6) goto L27
|
||||
goto L2a
|
||||
L27:
|
||||
int r2 = r2 + 1
|
||||
goto L10
|
||||
L2a:
|
||||
if (r2 != r0) goto L2d
|
||||
return r8
|
||||
L2d:
|
||||
java.lang.StringBuffer r5 = new java.lang.StringBuffer
|
||||
int r6 = r0 + 8
|
||||
r5.<init>(r6)
|
||||
if (r2 <= 0) goto L3d
|
||||
java.lang.String r1 = r8.substring(r1, r2)
|
||||
r5.append(r1)
|
||||
L3d:
|
||||
if (r2 >= r0) goto L93
|
||||
char r1 = r8.charAt(r2)
|
||||
if (r1 != r4) goto L4b
|
||||
java.lang.String r1 = r7.dollarReplacement
|
||||
r5.append(r1)
|
||||
goto L90
|
||||
L4b:
|
||||
if (r1 != r3) goto L53
|
||||
java.lang.String r1 = r7.escapeCharReplacement
|
||||
r5.append(r1)
|
||||
goto L90
|
||||
L53:
|
||||
if (r2 != 0) goto L5b
|
||||
boolean r6 = isXmlNameStartChar(r1)
|
||||
if (r6 == 0) goto L63
|
||||
L5b:
|
||||
if (r2 <= 0) goto L8d
|
||||
boolean r6 = isXmlNameChar(r1)
|
||||
if (r6 != 0) goto L8d
|
||||
L63:
|
||||
java.lang.String r6 = r7.hexPrefix
|
||||
r5.append(r6)
|
||||
r6 = 16
|
||||
if (r1 >= r6) goto L72
|
||||
java.lang.String r6 = "000"
|
||||
r5.append(r6)
|
||||
goto L85
|
||||
L72:
|
||||
r6 = 256(0x100, float:3.59E-43)
|
||||
if (r1 >= r6) goto L7c
|
||||
java.lang.String r6 = "00"
|
||||
r5.append(r6)
|
||||
goto L85
|
||||
L7c:
|
||||
r6 = 4096(0x1000, float:5.74E-42)
|
||||
if (r1 >= r6) goto L85
|
||||
java.lang.String r6 = "0"
|
||||
r5.append(r6)
|
||||
L85:
|
||||
java.lang.String r1 = java.lang.Integer.toHexString(r1)
|
||||
r5.append(r1)
|
||||
goto L90
|
||||
L8d:
|
||||
r5.append(r1)
|
||||
L90:
|
||||
int r2 = r2 + 1
|
||||
goto L3d
|
||||
L93:
|
||||
java.lang.String r0 = r5.toString()
|
||||
java.util.Map r1 = r7.escapeCache
|
||||
r1.put(r8, r0)
|
||||
L9c:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder.encodeName(java.lang.String):java.lang.String");
|
||||
}
|
||||
|
||||
private static boolean isInNameCharBounds(int i, IntPair[] intPairArr) {
|
||||
for (IntPair intPair : intPairArr) {
|
||||
if (i >= intPair.min && i <= intPair.max) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isXmlNameChar(int i) {
|
||||
if (isXmlNameStartChar(i)) {
|
||||
return true;
|
||||
}
|
||||
return isInNameCharBounds(i, XML_NAME_CHAR_EXTRA_BOUNDS);
|
||||
}
|
||||
|
||||
private static boolean isXmlNameStartChar(int i) {
|
||||
return isInNameCharBounds(i, XML_NAME_START_CHAR_BOUNDS);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
this.escapeCache = createCacheMap();
|
||||
this.unescapeCache = createCacheMap();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
XmlFriendlyNameCoder xmlFriendlyNameCoder = (XmlFriendlyNameCoder) super.clone();
|
||||
xmlFriendlyNameCoder.readResolve();
|
||||
return xmlFriendlyNameCoder;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new ObjectAccessException("Cannot clone XmlFriendlyNameCoder", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map createCacheMap() {
|
||||
return new HashMap();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
return decodeName(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
return decodeName(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeAttribute(String str) {
|
||||
return encodeName(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeNode(String str) {
|
||||
return encodeName(str);
|
||||
}
|
||||
|
||||
public XmlFriendlyNameCoder(String str, String str2) {
|
||||
this(str, str2, "_.");
|
||||
}
|
||||
|
||||
public XmlFriendlyNameCoder(String str, String str2, String str3) {
|
||||
this.dollarReplacement = str;
|
||||
this.escapeCharReplacement = str2;
|
||||
this.hexPrefix = str3;
|
||||
readResolve();
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface XmlFriendlyReader {
|
||||
String unescapeXmlName(String str);
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XmlFriendlyReplacer extends XmlFriendlyNameCoder {
|
||||
public XmlFriendlyReplacer() {
|
||||
this("_-", "__");
|
||||
}
|
||||
|
||||
public String escapeName(String str) {
|
||||
return super.encodeNode(str);
|
||||
}
|
||||
|
||||
public String unescapeName(String str) {
|
||||
return super.decodeNode(str);
|
||||
}
|
||||
|
||||
public XmlFriendlyReplacer(String str, String str2) {
|
||||
super(str, str2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface XmlFriendlyWriter {
|
||||
String escapeXmlName(String str);
|
||||
}
|
119
sources/com/thoughtworks/xstream/io/xml/XomDriver.java
Normal file
119
sources/com/thoughtworks/xstream/io/xml/XomDriver.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import nu.xom.Builder;
|
||||
import nu.xom.ParsingException;
|
||||
import nu.xom.ValidityException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XomDriver extends AbstractXmlDriver {
|
||||
private final Builder builder;
|
||||
|
||||
public XomDriver() {
|
||||
this(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
protected Builder createBuilder() {
|
||||
Builder builder = getBuilder();
|
||||
return builder != null ? builder : new Builder();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new XomReader(createBuilder().build(reader), getNameCoder());
|
||||
} catch (ParsingException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (ValidityException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
} catch (IOException e3) {
|
||||
throw new StreamException(e3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new PrettyPrintWriter(writer, getNameCoder());
|
||||
}
|
||||
|
||||
protected Builder getBuilder() {
|
||||
return this.builder;
|
||||
}
|
||||
|
||||
public XomDriver(Builder builder) {
|
||||
this(builder, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return new PrettyPrintWriter(new OutputStreamWriter(outputStream), getNameCoder());
|
||||
}
|
||||
|
||||
public XomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.builder = null;
|
||||
}
|
||||
|
||||
public XomDriver(Builder builder, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return new XomReader(createBuilder().build(inputStream), getNameCoder());
|
||||
} catch (ParsingException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (ValidityException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
} catch (IOException e3) {
|
||||
throw new StreamException(e3);
|
||||
}
|
||||
}
|
||||
|
||||
public XomDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public XomDriver(Builder builder, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(builder, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
return new XomReader(createBuilder().build(url.toExternalForm()), getNameCoder());
|
||||
} catch (ValidityException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (ParsingException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
} catch (IOException e3) {
|
||||
throw new StreamException(e3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
return new XomReader(createBuilder().build(file), getNameCoder());
|
||||
} catch (ParsingException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (ValidityException e2) {
|
||||
throw new StreamException((Throwable) e2);
|
||||
} catch (IOException e3) {
|
||||
throw new StreamException(e3);
|
||||
}
|
||||
}
|
||||
}
|
103
sources/com/thoughtworks/xstream/io/xml/XomReader.java
Normal file
103
sources/com/thoughtworks/xstream/io/xml/XomReader.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import nu.xom.Document;
|
||||
import nu.xom.Element;
|
||||
import nu.xom.Elements;
|
||||
import nu.xom.Text;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XomReader extends AbstractDocumentReader {
|
||||
private Element currentElement;
|
||||
|
||||
public XomReader(Element element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.currentElement.getAttributeValue(encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(this.currentElement.getAttribute(i).getQualifiedName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.currentElement.getChildElements().get(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.currentElement.getChildElements().size();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getLocalName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int childCount = this.currentElement.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
Text child = this.currentElement.getChild(i);
|
||||
if (child instanceof Text) {
|
||||
stringBuffer.append(child.getValue());
|
||||
}
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
Elements childElements = this.currentElement.getChildElements();
|
||||
if (childElements == null || childElements.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return decodeNode(childElements.get(0).getLocalName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (Element) obj;
|
||||
}
|
||||
|
||||
public XomReader(Document document) {
|
||||
super(document.getRootElement());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.currentElement.getAttribute(i).getValue();
|
||||
}
|
||||
|
||||
public XomReader(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
}
|
||||
|
||||
public XomReader(Document document, NameCoder nameCoder) {
|
||||
super(document.getRootElement(), nameCoder);
|
||||
}
|
||||
|
||||
public XomReader(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public XomReader(Document document, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(document.getRootElement(), (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
47
sources/com/thoughtworks/xstream/io/xml/XomWriter.java
Normal file
47
sources/com/thoughtworks/xstream/io/xml/XomWriter.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import nu.xom.Attribute;
|
||||
import nu.xom.Element;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XomWriter extends AbstractDocumentWriter {
|
||||
public XomWriter() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private Element top() {
|
||||
return (Element) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().addAttribute(new Attribute(encodeAttribute(str), str2));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
Element element = new Element(encodeNode(str));
|
||||
if (top() != null) {
|
||||
top().appendChild(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().appendChild(str);
|
||||
}
|
||||
|
||||
public XomWriter(Element element) {
|
||||
this(element, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public XomWriter(Element element, NameCoder nameCoder) {
|
||||
super(element, nameCoder);
|
||||
}
|
||||
|
||||
public XomWriter(Element element, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(element, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
21
sources/com/thoughtworks/xstream/io/xml/Xpp3DomDriver.java
Normal file
21
sources/com/thoughtworks/xstream/io/xml/Xpp3DomDriver.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.xmlpull.mxp1.MXParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Xpp3DomDriver extends AbstractXppDomDriver {
|
||||
public Xpp3DomDriver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDomDriver
|
||||
protected XmlPullParser createParser() {
|
||||
return new MXParser();
|
||||
}
|
||||
|
||||
public Xpp3DomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
21
sources/com/thoughtworks/xstream/io/xml/Xpp3Driver.java
Normal file
21
sources/com/thoughtworks/xstream/io/xml/Xpp3Driver.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.xmlpull.mxp1.MXParser;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Xpp3Driver extends AbstractXppDriver {
|
||||
public Xpp3Driver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDriver
|
||||
protected XmlPullParser createParser() {
|
||||
return new MXParser();
|
||||
}
|
||||
|
||||
public Xpp3Driver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
}
|
25
sources/com/thoughtworks/xstream/io/xml/XppDomDriver.java
Normal file
25
sources/com/thoughtworks/xstream/io/xml/XppDomDriver.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDomDriver extends AbstractXppDomDriver {
|
||||
public XppDomDriver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDomDriver
|
||||
protected synchronized XmlPullParser createParser() throws XmlPullParserException {
|
||||
return XppDriver.createDefaultParser();
|
||||
}
|
||||
|
||||
public XppDomDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
public XppDomDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
super(xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
86
sources/com/thoughtworks/xstream/io/xml/XppDomReader.java
Normal file
86
sources/com/thoughtworks/xstream/io/xml/XppDomReader.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.xml.xppdom.XppDom;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDomReader extends AbstractDocumentReader {
|
||||
private XppDom currentElement;
|
||||
|
||||
public XppDomReader(XppDom xppDom) {
|
||||
super(xppDom);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.currentElement.getAttribute(encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.currentElement.getAttributeNames().length;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(this.currentElement.getAttributeNames()[i]);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getChild(int i) {
|
||||
return this.currentElement.getChild(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected int getChildCount() {
|
||||
return this.currentElement.getChildCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return decodeNode(this.currentElement.getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected Object getParent() {
|
||||
return this.currentElement.getParent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
String str;
|
||||
try {
|
||||
str = this.currentElement.getValue();
|
||||
} catch (Exception unused) {
|
||||
str = null;
|
||||
}
|
||||
return str == null ? "" : str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractReader, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
if (this.currentElement.getChildCount() == 0) {
|
||||
return null;
|
||||
}
|
||||
return decodeNode(this.currentElement.getChild(0).getName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentReader
|
||||
protected void reassignCurrentElement(Object obj) {
|
||||
this.currentElement = (XppDom) obj;
|
||||
}
|
||||
|
||||
public XppDomReader(XppDom xppDom, NameCoder nameCoder) {
|
||||
super(xppDom, nameCoder);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
XppDom xppDom = this.currentElement;
|
||||
return xppDom.getAttribute(xppDom.getAttributeNames()[i]);
|
||||
}
|
||||
|
||||
public XppDomReader(XppDom xppDom, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(xppDom, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
58
sources/com/thoughtworks/xstream/io/xml/XppDomWriter.java
Normal file
58
sources/com/thoughtworks/xstream/io/xml/XppDomWriter.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.xml.xppdom.XppDom;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDomWriter extends AbstractDocumentWriter {
|
||||
public XppDomWriter() {
|
||||
this((XppDom) null, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
private XppDom top() {
|
||||
return (XppDom) getCurrent();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
top().setAttribute(encodeAttribute(str), str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
|
||||
protected Object createNode(String str) {
|
||||
XppDom xppDom = new XppDom(encodeNode(str));
|
||||
if (top() != null) {
|
||||
top().addChild(xppDom);
|
||||
}
|
||||
return xppDom;
|
||||
}
|
||||
|
||||
public XppDom getConfiguration() {
|
||||
return (XppDom) getTopLevelNodes().get(0);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
top().setValue(str);
|
||||
}
|
||||
|
||||
public XppDomWriter(XppDom xppDom) {
|
||||
this(xppDom, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public XppDomWriter(NameCoder nameCoder) {
|
||||
this((XppDom) null, nameCoder);
|
||||
}
|
||||
|
||||
public XppDomWriter(XppDom xppDom, NameCoder nameCoder) {
|
||||
super(xppDom, nameCoder);
|
||||
}
|
||||
|
||||
public XppDomWriter(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((XppDom) null, xmlFriendlyReplacer);
|
||||
}
|
||||
|
||||
public XppDomWriter(XppDom xppDom, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this(xppDom, (NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
39
sources/com/thoughtworks/xstream/io/xml/XppDriver.java
Normal file
39
sources/com/thoughtworks/xstream/io/xml/XppDriver.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDriver extends AbstractXppDriver {
|
||||
private static XmlPullParserFactory factory;
|
||||
|
||||
public XppDriver() {
|
||||
super(new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
public static synchronized XmlPullParser createDefaultParser() throws XmlPullParserException {
|
||||
XmlPullParser newPullParser;
|
||||
synchronized (XppDriver.class) {
|
||||
if (factory == null) {
|
||||
factory = XmlPullParserFactory.newInstance();
|
||||
}
|
||||
newPullParser = factory.newPullParser();
|
||||
}
|
||||
return newPullParser;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractXppDriver
|
||||
protected XmlPullParser createParser() throws XmlPullParserException {
|
||||
return createDefaultParser();
|
||||
}
|
||||
|
||||
public XppDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
public XppDriver(XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
this((NameCoder) xmlFriendlyReplacer);
|
||||
}
|
||||
}
|
140
sources/com/thoughtworks/xstream/io/xml/XppReader.java
Normal file
140
sources/com/thoughtworks/xstream/io/xml/XppReader.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package com.thoughtworks.xstream.io.xml;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppReader extends AbstractPullReader {
|
||||
static /* synthetic */ Class class$org$xmlpull$v1$XmlPullParser;
|
||||
private final XmlPullParser parser;
|
||||
private final Reader reader;
|
||||
|
||||
public XppReader(Reader reader, XmlPullParser xmlPullParser) {
|
||||
this(reader, xmlPullParser, new XmlFriendlyNameCoder());
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
|
||||
public void appendErrors(ErrorWriter errorWriter) {
|
||||
errorWriter.add("line number", String.valueOf(this.parser.getLineNumber()));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void close() {
|
||||
try {
|
||||
this.reader.close();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected XmlPullParser createParser() {
|
||||
Class cls;
|
||||
try {
|
||||
if (class$org$xmlpull$v1$XmlPullParser == null) {
|
||||
cls = class$("org.xmlpull.v1.XmlPullParser");
|
||||
class$org$xmlpull$v1$XmlPullParser = cls;
|
||||
} else {
|
||||
cls = class$org$xmlpull$v1$XmlPullParser;
|
||||
}
|
||||
return (XmlPullParser) Class.forName("org.xmlpull.mxp1.MXParser", true, cls.getClassLoader()).newInstance();
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
|
||||
throw new StreamException("Cannot create Xpp3 parser instance.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.parser.getAttributeValue(null, encodeAttribute(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.parser.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return decodeAttribute(this.parser.getAttributeName(i));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected String pullElementName() {
|
||||
return this.parser.getName();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected int pullNextEvent() {
|
||||
try {
|
||||
int next = this.parser.next();
|
||||
if (next != 0) {
|
||||
if (next != 1) {
|
||||
if (next != 2) {
|
||||
if (next != 3) {
|
||||
if (next != 4) {
|
||||
return next != 9 ? 0 : 4;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
} catch (XmlPullParserException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.xml.AbstractPullReader
|
||||
protected String pullText() {
|
||||
return this.parser.getText();
|
||||
}
|
||||
|
||||
public XppReader(Reader reader, XmlPullParser xmlPullParser, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.parser = xmlPullParser;
|
||||
this.reader = reader;
|
||||
try {
|
||||
xmlPullParser.setInput(this.reader);
|
||||
moveDown();
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.parser.getAttributeValue(i);
|
||||
}
|
||||
|
||||
public XppReader(Reader reader) {
|
||||
this(reader, new XmlFriendlyReplacer());
|
||||
}
|
||||
|
||||
public XppReader(Reader reader, XmlFriendlyReplacer xmlFriendlyReplacer) {
|
||||
super(xmlFriendlyReplacer);
|
||||
try {
|
||||
this.parser = createParser();
|
||||
this.reader = reader;
|
||||
this.parser.setInput(this.reader);
|
||||
moveDown();
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.thoughtworks.xstream.io.xml.xppdom;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Xpp3Dom extends XppDom {
|
||||
public Xpp3Dom(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.thoughtworks.xstream.io.xml.xppdom;
|
||||
|
||||
import java.io.Reader;
|
||||
import org.xmlpull.mxp1.MXParser;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Xpp3DomBuilder {
|
||||
public static Xpp3Dom build(Reader reader) throws Exception {
|
||||
MXParser mXParser = new MXParser();
|
||||
mXParser.setInput(reader);
|
||||
try {
|
||||
return (Xpp3Dom) XppDom.build(mXParser);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
152
sources/com/thoughtworks/xstream/io/xml/xppdom/XppDom.java
Normal file
152
sources/com/thoughtworks/xstream/io/xml/xppdom/XppDom.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package com.thoughtworks.xstream.io.xml.xppdom;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDom implements Serializable {
|
||||
private static final long serialVersionUID = 1;
|
||||
private Map attributes;
|
||||
private List childList = new ArrayList();
|
||||
private transient Map childMap = new HashMap();
|
||||
private String name;
|
||||
private XppDom parent;
|
||||
private String value;
|
||||
|
||||
public XppDom(String str) {
|
||||
this.name = str;
|
||||
}
|
||||
|
||||
public static XppDom build(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
int eventType = xmlPullParser.getEventType();
|
||||
XppDom xppDom = null;
|
||||
while (eventType != 1) {
|
||||
if (eventType == 2) {
|
||||
Xpp3Dom xpp3Dom = new Xpp3Dom(xmlPullParser.getName());
|
||||
int size = arrayList.size();
|
||||
if (size > 0) {
|
||||
((XppDom) arrayList.get(size - 1)).addChild(xpp3Dom);
|
||||
}
|
||||
arrayList.add(xpp3Dom);
|
||||
arrayList2.add(new StringBuffer());
|
||||
int attributeCount = xmlPullParser.getAttributeCount();
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
xpp3Dom.setAttribute(xmlPullParser.getAttributeName(i), xmlPullParser.getAttributeValue(i));
|
||||
}
|
||||
} else if (eventType == 4) {
|
||||
((StringBuffer) arrayList2.get(arrayList2.size() - 1)).append(xmlPullParser.getText());
|
||||
} else if (eventType == 3) {
|
||||
int size2 = arrayList.size() - 1;
|
||||
XppDom xppDom2 = (XppDom) arrayList.remove(size2);
|
||||
String obj = arrayList2.remove(size2).toString();
|
||||
if (obj.length() == 0) {
|
||||
obj = null;
|
||||
}
|
||||
xppDom2.setValue(obj);
|
||||
if (size2 == 0) {
|
||||
xppDom = xppDom2;
|
||||
}
|
||||
}
|
||||
eventType = xmlPullParser.next();
|
||||
}
|
||||
return xppDom;
|
||||
}
|
||||
|
||||
public void addChild(XppDom xppDom) {
|
||||
xppDom.setParent(this);
|
||||
this.childList.add(xppDom);
|
||||
this.childMap.put(xppDom.getName(), xppDom);
|
||||
}
|
||||
|
||||
public String getAttribute(String str) {
|
||||
Map map = this.attributes;
|
||||
if (map != null) {
|
||||
return (String) map.get(str);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] getAttributeNames() {
|
||||
Map map = this.attributes;
|
||||
return map == null ? new String[0] : (String[]) map.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public XppDom getChild(int i) {
|
||||
return (XppDom) this.childList.get(i);
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
List list = this.childList;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public XppDom[] getChildren() {
|
||||
List list = this.childList;
|
||||
return list == null ? new XppDom[0] : (XppDom[]) list.toArray(new XppDom[0]);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public XppDom getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
Object readResolve() {
|
||||
this.childMap = new HashMap();
|
||||
for (XppDom xppDom : this.childList) {
|
||||
this.childMap.put(xppDom.getName(), xppDom);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setAttribute(String str, String str2) {
|
||||
if (this.attributes == null) {
|
||||
this.attributes = new HashMap();
|
||||
}
|
||||
this.attributes.put(str, str2);
|
||||
}
|
||||
|
||||
public void setParent(XppDom xppDom) {
|
||||
this.parent = xppDom;
|
||||
}
|
||||
|
||||
public void setValue(String str) {
|
||||
this.value = str;
|
||||
}
|
||||
|
||||
public XppDom getChild(String str) {
|
||||
return (XppDom) this.childMap.get(str);
|
||||
}
|
||||
|
||||
public XppDom[] getChildren(String str) {
|
||||
if (this.childList == null) {
|
||||
return new XppDom[0];
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
int size = this.childList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
XppDom xppDom = (XppDom) this.childList.get(i);
|
||||
if (str.equals(xppDom.getName())) {
|
||||
arrayList.add(xppDom);
|
||||
}
|
||||
}
|
||||
return (XppDom[]) arrayList.toArray(new XppDom[0]);
|
||||
}
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
package com.thoughtworks.xstream.io.xml.xppdom;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppDomComparator implements Comparator {
|
||||
private final ThreadLocal xpath;
|
||||
|
||||
public XppDomComparator() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private int compareInternal(XppDom xppDom, XppDom xppDom2, StringBuffer stringBuffer, int i) {
|
||||
int compareTo;
|
||||
int length = stringBuffer.length();
|
||||
String name = xppDom.getName();
|
||||
int compareTo2 = name.compareTo(xppDom2.getName());
|
||||
stringBuffer.append(name);
|
||||
if (i >= 0) {
|
||||
stringBuffer.append('[');
|
||||
stringBuffer.append(i);
|
||||
stringBuffer.append(']');
|
||||
}
|
||||
if (compareTo2 != 0) {
|
||||
stringBuffer.append('?');
|
||||
return compareTo2;
|
||||
}
|
||||
String[] attributeNames = xppDom.getAttributeNames();
|
||||
String[] attributeNames2 = xppDom2.getAttributeNames();
|
||||
int length2 = attributeNames.length;
|
||||
int length3 = attributeNames2.length - length2;
|
||||
if (length3 != 0) {
|
||||
stringBuffer.append("::count(@*)");
|
||||
return length3 < 0 ? 1 : -1;
|
||||
}
|
||||
Arrays.sort(attributeNames);
|
||||
Arrays.sort(attributeNames2);
|
||||
for (int i2 = 0; i2 < length2; i2++) {
|
||||
String str = attributeNames[i2];
|
||||
int compareTo3 = str.compareTo(attributeNames2[i2]);
|
||||
if (compareTo3 != 0) {
|
||||
stringBuffer.append("[@");
|
||||
stringBuffer.append(str);
|
||||
stringBuffer.append("?]");
|
||||
return compareTo3;
|
||||
}
|
||||
int compareTo4 = xppDom.getAttribute(str).compareTo(xppDom2.getAttribute(str));
|
||||
if (compareTo4 != 0) {
|
||||
stringBuffer.append("[@");
|
||||
stringBuffer.append(str);
|
||||
stringBuffer.append(']');
|
||||
return compareTo4;
|
||||
}
|
||||
}
|
||||
int childCount = xppDom.getChildCount();
|
||||
int childCount2 = xppDom2.getChildCount() - childCount;
|
||||
if (childCount2 != 0) {
|
||||
stringBuffer.append("::count(*)");
|
||||
return childCount2 < 0 ? 1 : -1;
|
||||
}
|
||||
if (childCount <= 0) {
|
||||
String value = xppDom2.getValue();
|
||||
String value2 = xppDom.getValue();
|
||||
compareTo = value2 == null ? value != null ? -1 : 0 : value != null ? value2.compareTo(value) : 1;
|
||||
if (compareTo != 0) {
|
||||
stringBuffer.append("::text()");
|
||||
return compareTo;
|
||||
}
|
||||
} else {
|
||||
if (xppDom.getValue() != null || xppDom2.getValue() != null) {
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append("XppDom cannot handle mixed mode at ");
|
||||
stringBuffer2.append((Object) stringBuffer);
|
||||
stringBuffer2.append("::text()");
|
||||
throw new IllegalArgumentException(stringBuffer2.toString());
|
||||
}
|
||||
stringBuffer.append('/');
|
||||
HashMap hashMap = new HashMap();
|
||||
compareTo = childCount2;
|
||||
for (int i3 = 0; i3 < childCount; i3++) {
|
||||
XppDom child = xppDom.getChild(i3);
|
||||
XppDom child2 = xppDom2.getChild(i3);
|
||||
String name2 = child.getName();
|
||||
if (!hashMap.containsKey(name2)) {
|
||||
hashMap.put(name2, new int[1]);
|
||||
}
|
||||
int[] iArr = (int[]) hashMap.get(name2);
|
||||
int i4 = iArr[0];
|
||||
iArr[0] = i4 + 1;
|
||||
compareTo = compareInternal(child, child2, stringBuffer, i4);
|
||||
if (compareTo != 0) {
|
||||
return compareTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuffer.setLength(length);
|
||||
return compareTo;
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Object obj, Object obj2) {
|
||||
StringBuffer stringBuffer = new StringBuffer("/");
|
||||
int compareInternal = compareInternal((XppDom) obj, (XppDom) obj2, stringBuffer, -1);
|
||||
ThreadLocal threadLocal = this.xpath;
|
||||
if (threadLocal != null) {
|
||||
if (compareInternal != 0) {
|
||||
threadLocal.set(stringBuffer.toString());
|
||||
} else {
|
||||
threadLocal.set(null);
|
||||
}
|
||||
}
|
||||
return compareInternal;
|
||||
}
|
||||
|
||||
public XppDomComparator(ThreadLocal threadLocal) {
|
||||
this.xpath = threadLocal;
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.thoughtworks.xstream.io.xml.xppdom;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XppFactory {
|
||||
public static XppDom buildDom(String str) throws XmlPullParserException, IOException {
|
||||
return buildDom(new StringReader(str));
|
||||
}
|
||||
|
||||
public static XmlPullParser createDefaultParser() throws XmlPullParserException {
|
||||
return XmlPullParserFactory.newInstance().newPullParser();
|
||||
}
|
||||
|
||||
public static XppDom buildDom(Reader reader) throws XmlPullParserException, IOException {
|
||||
XmlPullParser createDefaultParser = createDefaultParser();
|
||||
createDefaultParser.setInput(reader);
|
||||
return XppDom.build(createDefaultParser);
|
||||
}
|
||||
|
||||
public static XppDom buildDom(InputStream inputStream, String str) throws XmlPullParserException, IOException {
|
||||
XmlPullParser createDefaultParser = createDefaultParser();
|
||||
createDefaultParser.setInput(inputStream, str);
|
||||
return XppDom.build(createDefaultParser);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user