Initial commit
This commit is contained in:
44
sources/com/thoughtworks/xstream/io/AbstractDriver.java
Normal file
44
sources/com/thoughtworks/xstream/io/AbstractDriver.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractDriver implements HierarchicalStreamDriver {
|
||||
private NameCoder replacer;
|
||||
|
||||
public AbstractDriver() {
|
||||
this(new NoNameCoder());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
try {
|
||||
return createReader(url.openStream());
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected NameCoder getNameCoder() {
|
||||
return this.replacer;
|
||||
}
|
||||
|
||||
public AbstractDriver(NameCoder nameCoder) {
|
||||
this.replacer = nameCoder;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
try {
|
||||
return createReader(new FileInputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
}
|
44
sources/com/thoughtworks/xstream/io/AbstractReader.java
Normal file
44
sources/com/thoughtworks/xstream/io/AbstractReader.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.Cloneables;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractReader implements ExtendedHierarchicalStreamReader {
|
||||
private NameCoder nameCoder;
|
||||
|
||||
protected AbstractReader() {
|
||||
this(new NoNameCoder());
|
||||
}
|
||||
|
||||
public String decodeAttribute(String str) {
|
||||
return this.nameCoder.decodeAttribute(str);
|
||||
}
|
||||
|
||||
public String decodeNode(String str) {
|
||||
return this.nameCoder.decodeNode(str);
|
||||
}
|
||||
|
||||
protected String encodeAttribute(String str) {
|
||||
return this.nameCoder.encodeAttribute(str);
|
||||
}
|
||||
|
||||
protected String encodeNode(String str) {
|
||||
return this.nameCoder.encodeNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
throw new UnsupportedOperationException("peekNextChild");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public HierarchicalStreamReader underlyingReader() {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected AbstractReader(NameCoder nameCoder) {
|
||||
this.nameCoder = (NameCoder) Cloneables.cloneIfPossible(nameCoder);
|
||||
}
|
||||
}
|
36
sources/com/thoughtworks/xstream/io/AbstractWriter.java
Normal file
36
sources/com/thoughtworks/xstream/io/AbstractWriter.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.Cloneables;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractWriter implements ExtendedHierarchicalStreamWriter {
|
||||
private NameCoder nameCoder;
|
||||
|
||||
protected AbstractWriter() {
|
||||
this(new NoNameCoder());
|
||||
}
|
||||
|
||||
public String encodeAttribute(String str) {
|
||||
return this.nameCoder.encodeAttribute(str);
|
||||
}
|
||||
|
||||
public String encodeNode(String str) {
|
||||
return this.nameCoder.encodeNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
startNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public HierarchicalStreamWriter underlyingWriter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected AbstractWriter(NameCoder nameCoder) {
|
||||
this.nameCoder = (NameCoder) Cloneables.cloneIfPossible(nameCoder);
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AttributeNameIterator implements Iterator {
|
||||
private final int count;
|
||||
private int current;
|
||||
private final HierarchicalStreamReader reader;
|
||||
|
||||
public AttributeNameIterator(HierarchicalStreamReader hierarchicalStreamReader) {
|
||||
this.reader = hierarchicalStreamReader;
|
||||
this.count = hierarchicalStreamReader.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
return this.current < this.count;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public Object next() {
|
||||
HierarchicalStreamReader hierarchicalStreamReader = this.reader;
|
||||
int i = this.current;
|
||||
this.current = i + 1;
|
||||
return hierarchicalStreamReader.getAttributeName(i);
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ExtendedHierarchicalStreamReader extends HierarchicalStreamReader {
|
||||
String peekNextChild();
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface ExtendedHierarchicalStreamWriter extends HierarchicalStreamWriter {
|
||||
void startNode(String str, Class cls);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ExtendedHierarchicalStreamWriterHelper {
|
||||
public static void startNode(HierarchicalStreamWriter hierarchicalStreamWriter, String str, Class cls) {
|
||||
if (hierarchicalStreamWriter instanceof ExtendedHierarchicalStreamWriter) {
|
||||
((ExtendedHierarchicalStreamWriter) hierarchicalStreamWriter).startNode(str, cls);
|
||||
} else {
|
||||
hierarchicalStreamWriter.startNode(str);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HierarchicalStreamDriver {
|
||||
HierarchicalStreamReader createReader(File file);
|
||||
|
||||
HierarchicalStreamReader createReader(InputStream inputStream);
|
||||
|
||||
HierarchicalStreamReader createReader(Reader reader);
|
||||
|
||||
HierarchicalStreamReader createReader(URL url);
|
||||
|
||||
HierarchicalStreamWriter createWriter(OutputStream outputStream);
|
||||
|
||||
HierarchicalStreamWriter createWriter(Writer writer);
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorReporter;
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HierarchicalStreamReader extends ErrorReporter {
|
||||
@Override // com.thoughtworks.xstream.converters.ErrorReporter
|
||||
void appendErrors(ErrorWriter errorWriter);
|
||||
|
||||
void close();
|
||||
|
||||
String getAttribute(int i);
|
||||
|
||||
String getAttribute(String str);
|
||||
|
||||
int getAttributeCount();
|
||||
|
||||
String getAttributeName(int i);
|
||||
|
||||
Iterator getAttributeNames();
|
||||
|
||||
String getNodeName();
|
||||
|
||||
String getValue();
|
||||
|
||||
boolean hasMoreChildren();
|
||||
|
||||
void moveDown();
|
||||
|
||||
void moveUp();
|
||||
|
||||
HierarchicalStreamReader underlyingReader();
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HierarchicalStreamWriter {
|
||||
void addAttribute(String str, String str2);
|
||||
|
||||
void close();
|
||||
|
||||
void endNode();
|
||||
|
||||
void flush();
|
||||
|
||||
void setValue(String str);
|
||||
|
||||
void startNode(String str);
|
||||
|
||||
HierarchicalStreamWriter underlyingWriter();
|
||||
}
|
87
sources/com/thoughtworks/xstream/io/ReaderWrapper.java
Normal file
87
sources/com/thoughtworks/xstream/io/ReaderWrapper.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ReaderWrapper implements ExtendedHierarchicalStreamReader {
|
||||
protected HierarchicalStreamReader wrapped;
|
||||
|
||||
protected ReaderWrapper(HierarchicalStreamReader hierarchicalStreamReader) {
|
||||
this.wrapped = hierarchicalStreamReader;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
|
||||
public void appendErrors(ErrorWriter errorWriter) {
|
||||
this.wrapped.appendErrors(errorWriter);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void close() {
|
||||
this.wrapped.close();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.wrapped.getAttribute(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.wrapped.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return this.wrapped.getAttributeName(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public Iterator getAttributeNames() {
|
||||
return this.wrapped.getAttributeNames();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return this.wrapped.getNodeName();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
return this.wrapped.getValue();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public boolean hasMoreChildren() {
|
||||
return this.wrapped.hasMoreChildren();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveDown() {
|
||||
this.wrapped.moveDown();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveUp() {
|
||||
this.wrapped.moveUp();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
HierarchicalStreamReader hierarchicalStreamReader = this.wrapped;
|
||||
if (hierarchicalStreamReader instanceof ExtendedHierarchicalStreamReader) {
|
||||
return ((ExtendedHierarchicalStreamReader) hierarchicalStreamReader).peekNextChild();
|
||||
}
|
||||
throw new UnsupportedOperationException("peekNextChild");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public HierarchicalStreamReader underlyingReader() {
|
||||
return this.wrapped.underlyingReader();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.wrapped.getAttribute(i);
|
||||
}
|
||||
}
|
121
sources/com/thoughtworks/xstream/io/StatefulWriter.java
Normal file
121
sources/com/thoughtworks/xstream/io/StatefulWriter.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastStack;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StatefulWriter extends WriterWrapper {
|
||||
public static int STATE_CLOSED = 4;
|
||||
public static int STATE_NODE_END = 3;
|
||||
public static int STATE_NODE_START = 1;
|
||||
public static int STATE_OPEN = 0;
|
||||
public static int STATE_VALUE = 2;
|
||||
private transient FastStack attributes;
|
||||
private transient int balance;
|
||||
private transient int state;
|
||||
|
||||
public StatefulWriter(HierarchicalStreamWriter hierarchicalStreamWriter) {
|
||||
super(hierarchicalStreamWriter);
|
||||
this.state = STATE_OPEN;
|
||||
this.attributes = new FastStack(16);
|
||||
}
|
||||
|
||||
private void checkClosed() {
|
||||
if (this.state == STATE_CLOSED) {
|
||||
throw new StreamException(new IOException("Writing on a closed stream"));
|
||||
}
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
this.attributes = new FastStack(16);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void startNodeCommon() {
|
||||
checkClosed();
|
||||
if (this.state == STATE_VALUE) {
|
||||
throw new StreamException(new IllegalStateException("Opening node after writing text"));
|
||||
}
|
||||
this.state = STATE_NODE_START;
|
||||
this.balance++;
|
||||
this.attributes.push(new HashSet());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
checkClosed();
|
||||
if (this.state != STATE_NODE_START) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Writing attribute '");
|
||||
stringBuffer.append(str);
|
||||
stringBuffer.append("' without an opened node");
|
||||
throw new StreamException(new IllegalStateException(stringBuffer.toString()));
|
||||
}
|
||||
Set set = (Set) this.attributes.peek();
|
||||
if (!set.contains(str)) {
|
||||
set.add(str);
|
||||
super.addAttribute(str, str2);
|
||||
} else {
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append("Writing attribute '");
|
||||
stringBuffer2.append(str);
|
||||
stringBuffer2.append("' twice");
|
||||
throw new StreamException(new IllegalStateException(stringBuffer2.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
int i = this.state;
|
||||
int i2 = STATE_NODE_END;
|
||||
this.state = STATE_CLOSED;
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
checkClosed();
|
||||
int i = this.balance;
|
||||
this.balance = i - 1;
|
||||
if (i == 0) {
|
||||
throw new StreamException(new IllegalStateException("Unbalanced node"));
|
||||
}
|
||||
this.attributes.popSilently();
|
||||
this.state = STATE_NODE_END;
|
||||
super.endNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
checkClosed();
|
||||
super.flush();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
checkClosed();
|
||||
if (this.state != STATE_NODE_START) {
|
||||
throw new StreamException(new IllegalStateException("Writing text without an opened node"));
|
||||
}
|
||||
this.state = STATE_VALUE;
|
||||
super.setValue(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
startNodeCommon();
|
||||
super.startNode(str);
|
||||
}
|
||||
|
||||
public int state() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
startNodeCommon();
|
||||
super.startNode(str, cls);
|
||||
}
|
||||
}
|
18
sources/com/thoughtworks/xstream/io/StreamException.java
Normal file
18
sources/com/thoughtworks/xstream/io/StreamException.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
import com.thoughtworks.xstream.XStreamException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StreamException extends XStreamException {
|
||||
public StreamException(Throwable th) {
|
||||
super(th);
|
||||
}
|
||||
|
||||
public StreamException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public StreamException(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
}
|
50
sources/com/thoughtworks/xstream/io/WriterWrapper.java
Normal file
50
sources/com/thoughtworks/xstream/io/WriterWrapper.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.thoughtworks.xstream.io;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class WriterWrapper implements ExtendedHierarchicalStreamWriter {
|
||||
protected HierarchicalStreamWriter wrapped;
|
||||
|
||||
protected WriterWrapper(HierarchicalStreamWriter hierarchicalStreamWriter) {
|
||||
this.wrapped = hierarchicalStreamWriter;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
this.wrapped.addAttribute(str, str2);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
this.wrapped.close();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
this.wrapped.endNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
this.wrapped.flush();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
this.wrapped.setValue(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
this.wrapped.startNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public HierarchicalStreamWriter underlyingWriter() {
|
||||
return this.wrapped.underlyingWriter();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
((ExtendedHierarchicalStreamWriter) this.wrapped).startNode(str, cls);
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.thoughtworks.xstream.io.binary;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractDriver;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BinaryStreamDriver extends AbstractDriver {
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
throw new UnsupportedOperationException("The BinaryDriver cannot use character-oriented input streams.");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
throw new UnsupportedOperationException("The BinaryDriver cannot use character-oriented output streams.");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
return new BinaryStreamReader(inputStream);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
return new BinaryStreamWriter(outputStream);
|
||||
}
|
||||
}
|
@@ -0,0 +1,207 @@
|
||||
package com.thoughtworks.xstream.io.binary;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.binary.Token;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BinaryStreamReader implements ExtendedHierarchicalStreamReader {
|
||||
private final DataInputStream in;
|
||||
private Token pushback;
|
||||
private final ReaderDepthState depthState = new ReaderDepthState();
|
||||
private final IdRegistry idRegistry = new IdRegistry();
|
||||
private final Token.Formatter tokenFormatter = new Token.Formatter();
|
||||
|
||||
private static class IdRegistry {
|
||||
private Map map;
|
||||
|
||||
private IdRegistry() {
|
||||
this.map = new HashMap();
|
||||
}
|
||||
|
||||
public String get(long j) {
|
||||
String str = (String) this.map.get(new Long(j));
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Unknown ID : ");
|
||||
stringBuffer.append(j);
|
||||
throw new StreamException(stringBuffer.toString());
|
||||
}
|
||||
|
||||
public void put(long j, String str) {
|
||||
this.map.put(new Long(j), str);
|
||||
}
|
||||
}
|
||||
|
||||
public BinaryStreamReader(InputStream inputStream) {
|
||||
this.in = new DataInputStream(inputStream);
|
||||
moveDown();
|
||||
}
|
||||
|
||||
private Token readToken() {
|
||||
Token token = this.pushback;
|
||||
if (token != null) {
|
||||
this.pushback = null;
|
||||
return token;
|
||||
}
|
||||
try {
|
||||
Token read = this.tokenFormatter.read(this.in);
|
||||
if (read.getType() != 2) {
|
||||
return read;
|
||||
}
|
||||
this.idRegistry.put(read.getId(), read.getValue());
|
||||
return readToken();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@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() {
|
||||
try {
|
||||
this.in.close();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(String str) {
|
||||
return this.depthState.getAttribute(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public int getAttributeCount() {
|
||||
return this.depthState.getAttributeCount();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttributeName(int i) {
|
||||
return this.depthState.getAttributeName(i);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public Iterator getAttributeNames() {
|
||||
return this.depthState.getAttributeNames();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getNodeName() {
|
||||
return this.depthState.getName();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getValue() {
|
||||
return this.depthState.getValue();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public boolean hasMoreChildren() {
|
||||
return this.depthState.hasMoreChildren();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveDown() {
|
||||
this.depthState.push();
|
||||
Token readToken = readToken();
|
||||
if (readToken.getType() != 3) {
|
||||
throw new StreamException("Expected StartNode");
|
||||
}
|
||||
this.depthState.setName(this.idRegistry.get(readToken.getId()));
|
||||
while (true) {
|
||||
Token readToken2 = readToken();
|
||||
byte type = readToken2.getType();
|
||||
if (type == 3) {
|
||||
this.depthState.setHasMoreChildren(true);
|
||||
pushBack(readToken2);
|
||||
return;
|
||||
}
|
||||
if (type == 4) {
|
||||
this.depthState.setHasMoreChildren(false);
|
||||
pushBack(readToken2);
|
||||
return;
|
||||
} else if (type == 5) {
|
||||
this.depthState.addAttribute(this.idRegistry.get(readToken2.getId()), readToken2.getValue());
|
||||
} else {
|
||||
if (type != 6) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Unexpected token ");
|
||||
stringBuffer.append(readToken2);
|
||||
throw new StreamException(stringBuffer.toString());
|
||||
}
|
||||
this.depthState.setValue(readToken2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveUp() {
|
||||
this.depthState.pop();
|
||||
int i = 0;
|
||||
while (true) {
|
||||
byte type = readToken().getType();
|
||||
if (type == 3) {
|
||||
i++;
|
||||
} else if (type != 4) {
|
||||
continue;
|
||||
} else if (i == 0) {
|
||||
break;
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
}
|
||||
Token readToken = readToken();
|
||||
byte type2 = readToken.getType();
|
||||
if (type2 == 3) {
|
||||
this.depthState.setHasMoreChildren(true);
|
||||
} else {
|
||||
if (type2 != 4) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Unexpected token ");
|
||||
stringBuffer.append(readToken);
|
||||
throw new StreamException(stringBuffer.toString());
|
||||
}
|
||||
this.depthState.setHasMoreChildren(false);
|
||||
}
|
||||
pushBack(readToken);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamReader
|
||||
public String peekNextChild() {
|
||||
if (this.depthState.hasMoreChildren()) {
|
||||
return this.idRegistry.get(this.pushback.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void pushBack(Token token) {
|
||||
if (this.pushback != null) {
|
||||
throw new Error("Cannot push more than one token back");
|
||||
}
|
||||
this.pushback = token;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public HierarchicalStreamReader underlyingReader() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public String getAttribute(int i) {
|
||||
return this.depthState.getAttribute(i);
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
package com.thoughtworks.xstream.io.binary;
|
||||
|
||||
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import com.thoughtworks.xstream.io.binary.Token;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BinaryStreamWriter implements ExtendedHierarchicalStreamWriter {
|
||||
private final DataOutputStream out;
|
||||
private final IdRegistry idRegistry = new IdRegistry();
|
||||
private final Token.Formatter tokenFormatter = new Token.Formatter();
|
||||
|
||||
private class IdRegistry {
|
||||
private Map ids;
|
||||
private long nextId;
|
||||
|
||||
private IdRegistry() {
|
||||
this.nextId = 0L;
|
||||
this.ids = new HashMap();
|
||||
}
|
||||
|
||||
public long getId(String str) {
|
||||
Long l = (Long) this.ids.get(str);
|
||||
if (l == null) {
|
||||
long j = this.nextId + 1;
|
||||
this.nextId = j;
|
||||
l = new Long(j);
|
||||
this.ids.put(str, l);
|
||||
BinaryStreamWriter.this.write(new Token.MapIdToValue(l.longValue(), str));
|
||||
}
|
||||
return l.longValue();
|
||||
}
|
||||
}
|
||||
|
||||
public BinaryStreamWriter(OutputStream outputStream) {
|
||||
this.out = new DataOutputStream(outputStream);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void write(Token token) {
|
||||
try {
|
||||
this.tokenFormatter.write(this.out, token);
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
write(new Token.Attribute(this.idRegistry.getId(str), str2));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
try {
|
||||
this.out.close();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
write(new Token.EndNode());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
try {
|
||||
this.out.flush();
|
||||
} catch (IOException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
write(new Token.Value(str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
write(new Token.StartNode(this.idRegistry.getId(str)));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public HierarchicalStreamWriter underlyingWriter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
startNode(str);
|
||||
}
|
||||
}
|
141
sources/com/thoughtworks/xstream/io/binary/ReaderDepthState.java
Normal file
141
sources/com/thoughtworks/xstream/io/binary/ReaderDepthState.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package com.thoughtworks.xstream.io.binary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ReaderDepthState {
|
||||
private static final String EMPTY_STRING = "";
|
||||
private State current;
|
||||
|
||||
private static class Attribute {
|
||||
String name;
|
||||
String value;
|
||||
|
||||
private Attribute() {
|
||||
}
|
||||
}
|
||||
|
||||
private static class State {
|
||||
List attributes;
|
||||
boolean hasMoreChildren;
|
||||
String name;
|
||||
State parent;
|
||||
String value;
|
||||
|
||||
private State() {
|
||||
}
|
||||
}
|
||||
|
||||
ReaderDepthState() {
|
||||
}
|
||||
|
||||
public void addAttribute(String str, String str2) {
|
||||
Attribute attribute = new Attribute();
|
||||
attribute.name = str;
|
||||
attribute.value = str2;
|
||||
State state = this.current;
|
||||
if (state.attributes == null) {
|
||||
state.attributes = new ArrayList();
|
||||
}
|
||||
this.current.attributes.add(attribute);
|
||||
}
|
||||
|
||||
public String getAttribute(String str) {
|
||||
List<Attribute> list = this.current.attributes;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
for (Attribute attribute : list) {
|
||||
if (attribute.name.equals(str)) {
|
||||
return attribute.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getAttributeCount() {
|
||||
List list = this.current.attributes;
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public String getAttributeName(int i) {
|
||||
List list = this.current.attributes;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
return ((Attribute) list.get(i)).name;
|
||||
}
|
||||
|
||||
public Iterator getAttributeNames() {
|
||||
List list = this.current.attributes;
|
||||
if (list == null) {
|
||||
return Collections.EMPTY_SET.iterator();
|
||||
}
|
||||
final Iterator it = list.iterator();
|
||||
return new Iterator() { // from class: com.thoughtworks.xstream.io.binary.ReaderDepthState.1
|
||||
@Override // java.util.Iterator
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public Object next() {
|
||||
return ((Attribute) it.next()).name;
|
||||
}
|
||||
|
||||
@Override // java.util.Iterator
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.current.name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
String str = this.current.value;
|
||||
return str == null ? "" : str;
|
||||
}
|
||||
|
||||
public boolean hasMoreChildren() {
|
||||
return this.current.hasMoreChildren;
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
this.current = this.current.parent;
|
||||
}
|
||||
|
||||
public void push() {
|
||||
State state = new State();
|
||||
state.parent = this.current;
|
||||
this.current = state;
|
||||
}
|
||||
|
||||
public void setHasMoreChildren(boolean z) {
|
||||
this.current.hasMoreChildren = z;
|
||||
}
|
||||
|
||||
public void setName(String str) {
|
||||
this.current.name = str;
|
||||
}
|
||||
|
||||
public void setValue(String str) {
|
||||
this.current.value = str;
|
||||
}
|
||||
|
||||
public String getAttribute(int i) {
|
||||
List list = this.current.attributes;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
return ((Attribute) list.get(i)).value;
|
||||
}
|
||||
}
|
299
sources/com/thoughtworks/xstream/io/binary/Token.java
Normal file
299
sources/com/thoughtworks/xstream/io/binary/Token.java
Normal file
@@ -0,0 +1,299 @@
|
||||
package com.thoughtworks.xstream.io.binary;
|
||||
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Token {
|
||||
private static final byte ID_EIGHT_BYTES = 32;
|
||||
private static final byte ID_FOUR_BYTES = 24;
|
||||
private static final byte ID_MASK = 56;
|
||||
private static final byte ID_ONE_BYTE = 8;
|
||||
private static final String ID_SPLITTED = "\u0000‡\u0000";
|
||||
private static final byte ID_TWO_BYTES = 16;
|
||||
private static final int MAX_UTF8_LENGTH = 65535;
|
||||
public static final byte TYPE_ATTRIBUTE = 5;
|
||||
public static final byte TYPE_END_NODE = 4;
|
||||
public static final byte TYPE_MAP_ID_TO_VALUE = 2;
|
||||
private static final byte TYPE_MASK = 7;
|
||||
public static final byte TYPE_START_NODE = 3;
|
||||
public static final byte TYPE_VALUE = 6;
|
||||
public static final byte TYPE_VERSION = 1;
|
||||
protected long id = -1;
|
||||
private final byte type;
|
||||
protected String value;
|
||||
|
||||
public static class EndNode extends Token {
|
||||
public EndNode() {
|
||||
super((byte) 4);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void readFrom(DataInput dataInput, byte b) {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void writeTo(DataOutput dataOutput, byte b) {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Formatter {
|
||||
private Token contructToken(byte b) {
|
||||
if (b == 2) {
|
||||
return new MapIdToValue();
|
||||
}
|
||||
if (b == 3) {
|
||||
return new StartNode();
|
||||
}
|
||||
if (b == 4) {
|
||||
return new EndNode();
|
||||
}
|
||||
if (b == 5) {
|
||||
return new Attribute();
|
||||
}
|
||||
if (b == 6) {
|
||||
return new Value();
|
||||
}
|
||||
throw new StreamException("Unknown token type");
|
||||
}
|
||||
|
||||
public Token read(DataInput dataInput) throws IOException {
|
||||
byte readByte = dataInput.readByte();
|
||||
byte b = (byte) (readByte & Token.TYPE_MASK);
|
||||
byte b2 = (byte) (readByte & Token.ID_MASK);
|
||||
Token contructToken = contructToken(b);
|
||||
contructToken.readFrom(dataInput, b2);
|
||||
return contructToken;
|
||||
}
|
||||
|
||||
public void write(DataOutput dataOutput, Token token) throws IOException {
|
||||
long id = token.getId();
|
||||
byte b = id <= 255 ? Token.ID_ONE_BYTE : id <= 65535 ? Token.ID_TWO_BYTES : id <= 4294967295L ? Token.ID_FOUR_BYTES : Token.ID_EIGHT_BYTES;
|
||||
dataOutput.write(token.getType() + b);
|
||||
token.writeTo(dataOutput, b);
|
||||
}
|
||||
}
|
||||
|
||||
public Token(byte b) {
|
||||
this.type = b;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Token token = (Token) obj;
|
||||
if (this.id != token.id || this.type != token.type) {
|
||||
return false;
|
||||
}
|
||||
String str = this.value;
|
||||
String str2 = token.value;
|
||||
if (str != null) {
|
||||
if (str.equals(str2)) {
|
||||
return true;
|
||||
}
|
||||
} else if (str2 == null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public byte getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int i = this.type * 29;
|
||||
long j = this.id;
|
||||
int i2 = (i + ((int) (j ^ (j >>> 32)))) * 29;
|
||||
String str = this.value;
|
||||
return i2 + (str != null ? str.hashCode() : 0);
|
||||
}
|
||||
|
||||
public abstract void readFrom(DataInput dataInput, byte b) throws IOException;
|
||||
|
||||
protected long readId(DataInput dataInput, byte b) throws IOException {
|
||||
if (b == 8) {
|
||||
return dataInput.readByte() + 128;
|
||||
}
|
||||
if (b == 16) {
|
||||
return dataInput.readShort() - Short.MIN_VALUE;
|
||||
}
|
||||
if (b == 24) {
|
||||
return dataInput.readInt() - Integer.MIN_VALUE;
|
||||
}
|
||||
if (b == 32) {
|
||||
return dataInput.readLong() - Long.MIN_VALUE;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Unknown idType ");
|
||||
stringBuffer.append((int) b);
|
||||
throw new Error(stringBuffer.toString());
|
||||
}
|
||||
|
||||
protected String readString(DataInput dataInput) throws IOException {
|
||||
String readUTF = dataInput.readUTF();
|
||||
if (!ID_SPLITTED.equals(readUTF)) {
|
||||
return readUTF;
|
||||
}
|
||||
byte[] bArr = new byte[dataInput.readInt()];
|
||||
dataInput.readFully(bArr);
|
||||
return new String(bArr, "utf-8");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(getClass().getName());
|
||||
stringBuffer.append(" [id=");
|
||||
stringBuffer.append(this.id);
|
||||
stringBuffer.append(", value='");
|
||||
stringBuffer.append(this.value);
|
||||
stringBuffer.append("']");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
protected void writeId(DataOutput dataOutput, long j, byte b) throws IOException {
|
||||
if (j < 0) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("id must not be negative ");
|
||||
stringBuffer.append(j);
|
||||
throw new IOException(stringBuffer.toString());
|
||||
}
|
||||
if (b == 8) {
|
||||
dataOutput.writeByte(((byte) j) - 128);
|
||||
return;
|
||||
}
|
||||
if (b == 16) {
|
||||
dataOutput.writeShort(((short) j) - 32768);
|
||||
return;
|
||||
}
|
||||
if (b == 24) {
|
||||
dataOutput.writeInt(((int) j) - 2147483648);
|
||||
} else {
|
||||
if (b == 32) {
|
||||
dataOutput.writeLong(j - Long.MIN_VALUE);
|
||||
return;
|
||||
}
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
stringBuffer2.append("Unknown idType ");
|
||||
stringBuffer2.append((int) b);
|
||||
throw new Error(stringBuffer2.toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeString(DataOutput dataOutput, String str) throws IOException {
|
||||
byte[] bytes = str.length() > 16383 ? str.getBytes("utf-8") : new byte[0];
|
||||
if (bytes.length <= MAX_UTF8_LENGTH) {
|
||||
dataOutput.writeUTF(str);
|
||||
return;
|
||||
}
|
||||
dataOutput.writeUTF(ID_SPLITTED);
|
||||
dataOutput.writeInt(bytes.length);
|
||||
dataOutput.write(bytes);
|
||||
}
|
||||
|
||||
public abstract void writeTo(DataOutput dataOutput, byte b) throws IOException;
|
||||
|
||||
public static class StartNode extends Token {
|
||||
public StartNode(long j) {
|
||||
super((byte) 3);
|
||||
this.id = j;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void readFrom(DataInput dataInput, byte b) throws IOException {
|
||||
this.id = readId(dataInput, b);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void writeTo(DataOutput dataOutput, byte b) throws IOException {
|
||||
writeId(dataOutput, this.id, b);
|
||||
}
|
||||
|
||||
public StartNode() {
|
||||
super((byte) 3);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Value extends Token {
|
||||
public Value(String str) {
|
||||
super((byte) 6);
|
||||
this.value = str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void readFrom(DataInput dataInput, byte b) throws IOException {
|
||||
this.value = readString(dataInput);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void writeTo(DataOutput dataOutput, byte b) throws IOException {
|
||||
writeString(dataOutput, this.value);
|
||||
}
|
||||
|
||||
public Value() {
|
||||
super((byte) 6);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Attribute extends Token {
|
||||
public Attribute(long j, String str) {
|
||||
super((byte) 5);
|
||||
this.id = j;
|
||||
this.value = str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void readFrom(DataInput dataInput, byte b) throws IOException {
|
||||
this.id = readId(dataInput, b);
|
||||
this.value = readString(dataInput);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void writeTo(DataOutput dataOutput, byte b) throws IOException {
|
||||
writeId(dataOutput, this.id, b);
|
||||
writeString(dataOutput, this.value);
|
||||
}
|
||||
|
||||
public Attribute() {
|
||||
super((byte) 5);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapIdToValue extends Token {
|
||||
public MapIdToValue(long j, String str) {
|
||||
super((byte) 2);
|
||||
this.id = j;
|
||||
this.value = str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void readFrom(DataInput dataInput, byte b) throws IOException {
|
||||
this.id = readId(dataInput, b);
|
||||
this.value = readString(dataInput);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.binary.Token
|
||||
public void writeTo(DataOutput dataOutput, byte b) throws IOException {
|
||||
writeId(dataOutput, this.id, b);
|
||||
writeString(dataOutput, this.value);
|
||||
}
|
||||
|
||||
public MapIdToValue() {
|
||||
super((byte) 2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.thoughtworks.xstream.io.copy;
|
||||
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HierarchicalStreamCopier {
|
||||
public void copy(HierarchicalStreamReader hierarchicalStreamReader, HierarchicalStreamWriter hierarchicalStreamWriter) {
|
||||
hierarchicalStreamWriter.startNode(hierarchicalStreamReader.getNodeName());
|
||||
int attributeCount = hierarchicalStreamReader.getAttributeCount();
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
hierarchicalStreamWriter.addAttribute(hierarchicalStreamReader.getAttributeName(i), hierarchicalStreamReader.getAttribute(i));
|
||||
}
|
||||
String value = hierarchicalStreamReader.getValue();
|
||||
if (value != null && value.length() > 0) {
|
||||
hierarchicalStreamWriter.setValue(value);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
copy(hierarchicalStreamReader, hierarchicalStreamWriter);
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
374
sources/com/thoughtworks/xstream/io/json/AbstractJsonWriter.java
Normal file
374
sources/com/thoughtworks/xstream/io/json/AbstractJsonWriter.java
Normal file
@@ -0,0 +1,374 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastStack;
|
||||
import com.thoughtworks.xstream.io.AbstractWriter;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractJsonWriter extends AbstractWriter {
|
||||
public static final int DROP_ROOT_MODE = 1;
|
||||
public static final int EXPLICIT_MODE = 4;
|
||||
public static final int IEEE_754_MODE = 8;
|
||||
private static final Set NUMBER_TYPES;
|
||||
private static final int STATE_END_ATTRIBUTES = 32;
|
||||
private static final int STATE_END_ELEMENTS = 256;
|
||||
private static final int STATE_END_OBJECT = 2;
|
||||
private static final int STATE_NEXT_ATTRIBUTE = 16;
|
||||
private static final int STATE_NEXT_ELEMENT = 128;
|
||||
private static final int STATE_ROOT = 1;
|
||||
private static final int STATE_SET_VALUE = 512;
|
||||
private static final int STATE_START_ATTRIBUTES = 8;
|
||||
private static final int STATE_START_ELEMENTS = 64;
|
||||
private static final int STATE_START_OBJECT = 4;
|
||||
public static final int STRICT_MODE = 2;
|
||||
static /* synthetic */ Class class$com$thoughtworks$xstream$mapper$Mapper$Null;
|
||||
static /* synthetic */ Class class$java$io$Externalizable;
|
||||
static /* synthetic */ Class class$java$lang$Boolean;
|
||||
static /* synthetic */ Class class$java$lang$Byte;
|
||||
static /* synthetic */ Class class$java$lang$Character;
|
||||
static /* synthetic */ Class class$java$lang$Double;
|
||||
static /* synthetic */ Class class$java$lang$Float;
|
||||
static /* synthetic */ Class class$java$lang$Integer;
|
||||
static /* synthetic */ Class class$java$lang$Long;
|
||||
static /* synthetic */ Class class$java$lang$Short;
|
||||
static /* synthetic */ Class class$java$math$BigDecimal;
|
||||
static /* synthetic */ Class class$java$math$BigInteger;
|
||||
static /* synthetic */ Class class$java$util$Collection;
|
||||
static /* synthetic */ Class class$java$util$Map;
|
||||
static /* synthetic */ Class class$java$util$Map$Entry;
|
||||
private int expectedStates;
|
||||
private int mode;
|
||||
private FastStack stack;
|
||||
|
||||
private static class IllegalWriterStateException extends IllegalStateException {
|
||||
/* JADX WARN: Illegal instructions before constructor call */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public IllegalWriterStateException(int r3, int r4, java.lang.String r5) {
|
||||
/*
|
||||
r2 = this;
|
||||
java.lang.StringBuffer r0 = new java.lang.StringBuffer
|
||||
r0.<init>()
|
||||
java.lang.String r1 = "Cannot turn from state "
|
||||
r0.append(r1)
|
||||
java.lang.String r3 = getState(r3)
|
||||
r0.append(r3)
|
||||
java.lang.String r3 = " into state "
|
||||
r0.append(r3)
|
||||
java.lang.String r3 = getState(r4)
|
||||
r0.append(r3)
|
||||
if (r5 != 0) goto L22
|
||||
java.lang.String r3 = ""
|
||||
goto L33
|
||||
L22:
|
||||
java.lang.StringBuffer r3 = new java.lang.StringBuffer
|
||||
r3.<init>()
|
||||
java.lang.String r4 = " for property "
|
||||
r3.append(r4)
|
||||
r3.append(r5)
|
||||
java.lang.String r3 = r3.toString()
|
||||
L33:
|
||||
r0.append(r3)
|
||||
java.lang.String r3 = r0.toString()
|
||||
r2.<init>(r3)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.io.json.AbstractJsonWriter.IllegalWriterStateException.<init>(int, int, java.lang.String):void");
|
||||
}
|
||||
|
||||
private static String getState(int i) {
|
||||
if (i == 1) {
|
||||
return "ROOT";
|
||||
}
|
||||
if (i == 2) {
|
||||
return "END_OBJECT";
|
||||
}
|
||||
if (i == 4) {
|
||||
return "START_OBJECT";
|
||||
}
|
||||
if (i == 8) {
|
||||
return "START_ATTRIBUTES";
|
||||
}
|
||||
if (i == 16) {
|
||||
return "NEXT_ATTRIBUTE";
|
||||
}
|
||||
if (i == 32) {
|
||||
return "END_ATTRIBUTES";
|
||||
}
|
||||
if (i == 64) {
|
||||
return "START_ELEMENTS";
|
||||
}
|
||||
if (i == 128) {
|
||||
return "NEXT_ELEMENT";
|
||||
}
|
||||
if (i == 256) {
|
||||
return "END_ELEMENTS";
|
||||
}
|
||||
if (i == 512) {
|
||||
return "SET_VALUE";
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Unknown state provided: ");
|
||||
stringBuffer.append(i);
|
||||
stringBuffer.append(", cannot create message for IllegalWriterStateException");
|
||||
throw new IllegalArgumentException(stringBuffer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static class StackElement {
|
||||
int status;
|
||||
final Class type;
|
||||
|
||||
public StackElement(Class cls, int i) {
|
||||
this.type = cls;
|
||||
this.status = i;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Type {
|
||||
public static Type NULL = new Type();
|
||||
public static Type STRING = new Type();
|
||||
public static Type NUMBER = new Type();
|
||||
public static Type BOOLEAN = new Type();
|
||||
}
|
||||
|
||||
static {
|
||||
Class[] clsArr = new Class[14];
|
||||
clsArr[0] = Byte.TYPE;
|
||||
Class cls = class$java$lang$Byte;
|
||||
if (cls == null) {
|
||||
cls = class$("java.lang.Byte");
|
||||
class$java$lang$Byte = cls;
|
||||
}
|
||||
clsArr[1] = cls;
|
||||
clsArr[2] = Short.TYPE;
|
||||
Class cls2 = class$java$lang$Short;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Short");
|
||||
class$java$lang$Short = cls2;
|
||||
}
|
||||
clsArr[3] = cls2;
|
||||
clsArr[4] = Integer.TYPE;
|
||||
Class cls3 = class$java$lang$Integer;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.lang.Integer");
|
||||
class$java$lang$Integer = cls3;
|
||||
}
|
||||
clsArr[5] = cls3;
|
||||
clsArr[6] = Long.TYPE;
|
||||
Class cls4 = class$java$lang$Long;
|
||||
if (cls4 == null) {
|
||||
cls4 = class$("java.lang.Long");
|
||||
class$java$lang$Long = cls4;
|
||||
}
|
||||
clsArr[7] = cls4;
|
||||
clsArr[8] = Float.TYPE;
|
||||
Class cls5 = class$java$lang$Float;
|
||||
if (cls5 == null) {
|
||||
cls5 = class$("java.lang.Float");
|
||||
class$java$lang$Float = cls5;
|
||||
}
|
||||
clsArr[9] = cls5;
|
||||
clsArr[10] = Double.TYPE;
|
||||
Class cls6 = class$java$lang$Double;
|
||||
if (cls6 == null) {
|
||||
cls6 = class$("java.lang.Double");
|
||||
class$java$lang$Double = cls6;
|
||||
}
|
||||
clsArr[11] = cls6;
|
||||
Class cls7 = class$java$math$BigInteger;
|
||||
if (cls7 == null) {
|
||||
cls7 = class$("java.math.BigInteger");
|
||||
class$java$math$BigInteger = cls7;
|
||||
}
|
||||
clsArr[12] = cls7;
|
||||
Class cls8 = class$java$math$BigDecimal;
|
||||
if (cls8 == null) {
|
||||
cls8 = class$("java.math.BigDecimal");
|
||||
class$java$math$BigDecimal = cls8;
|
||||
}
|
||||
clsArr[13] = cls8;
|
||||
NUMBER_TYPES = new HashSet(Arrays.asList(clsArr));
|
||||
}
|
||||
|
||||
public AbstractJsonWriter() {
|
||||
this(new NoNameCoder());
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCheckedStateTransition(int i, String str, String str2) {
|
||||
StackElement stackElement = (StackElement) this.stack.peek();
|
||||
if ((this.expectedStates & i) == 0) {
|
||||
throw new IllegalWriterStateException(stackElement.status, i, str);
|
||||
}
|
||||
stackElement.status = handleStateTransition(stackElement.status, i, str, str2);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:111:0x0167, code lost:
|
||||
|
||||
if (r6 == r0) goto L113;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:177:0x023a, code lost:
|
||||
|
||||
if ((r17.mode & 4) != 0) goto L186;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private int handleStateTransition(int r18, int r19, java.lang.String r20, java.lang.String r21) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 887
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.io.json.AbstractJsonWriter.handleStateTransition(int, int, java.lang.String, java.lang.String):int");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void addAttribute(String str, String str2) {
|
||||
handleCheckedStateTransition(16, str, str2);
|
||||
this.expectedStates = 661;
|
||||
}
|
||||
|
||||
protected abstract void addLabel(String str);
|
||||
|
||||
protected abstract void addValue(String str, Type type);
|
||||
|
||||
protected abstract void endArray();
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
int size = this.stack.size();
|
||||
int i = size > 2 ? 128 : 1;
|
||||
handleCheckedStateTransition(i, null, null);
|
||||
this.stack.pop();
|
||||
((StackElement) this.stack.peek()).status = i;
|
||||
this.expectedStates = 4;
|
||||
if (size > 2) {
|
||||
this.expectedStates |= 129;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void endObject();
|
||||
|
||||
protected Type getType(Class cls) {
|
||||
Class cls2 = class$com$thoughtworks$xstream$mapper$Mapper$Null;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("com.thoughtworks.xstream.mapper.Mapper$Null");
|
||||
class$com$thoughtworks$xstream$mapper$Mapper$Null = cls2;
|
||||
}
|
||||
if (cls == cls2) {
|
||||
return Type.NULL;
|
||||
}
|
||||
Class cls3 = class$java$lang$Boolean;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.lang.Boolean");
|
||||
class$java$lang$Boolean = cls3;
|
||||
}
|
||||
return (cls == cls3 || cls == Boolean.TYPE) ? Type.BOOLEAN : NUMBER_TYPES.contains(cls) ? Type.NUMBER : Type.STRING;
|
||||
}
|
||||
|
||||
protected boolean isArray(Class cls) {
|
||||
if (cls != null) {
|
||||
if (!cls.isArray()) {
|
||||
Class cls2 = class$java$util$Collection;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.util.Collection");
|
||||
class$java$util$Collection = cls2;
|
||||
}
|
||||
if (!cls2.isAssignableFrom(cls)) {
|
||||
Class cls3 = class$java$io$Externalizable;
|
||||
if (cls3 == null) {
|
||||
cls3 = class$("java.io.Externalizable");
|
||||
class$java$io$Externalizable = cls3;
|
||||
}
|
||||
if (!cls3.isAssignableFrom(cls)) {
|
||||
Class cls4 = class$java$util$Map;
|
||||
if (cls4 == null) {
|
||||
cls4 = class$("java.util.Map");
|
||||
class$java$util$Map = cls4;
|
||||
}
|
||||
if (!cls4.isAssignableFrom(cls)) {
|
||||
Class cls5 = class$java$util$Map$Entry;
|
||||
if (cls5 == null) {
|
||||
cls5 = class$("java.util.Map$Entry");
|
||||
class$java$util$Map$Entry = cls5;
|
||||
}
|
||||
if (cls5.isAssignableFrom(cls)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void nextElement();
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void setValue(String str) {
|
||||
Class cls = ((StackElement) this.stack.peek()).type;
|
||||
Class cls2 = class$java$lang$Character;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Character");
|
||||
class$java$lang$Character = cls2;
|
||||
}
|
||||
if ((cls == cls2 || cls == Character.TYPE) && "".equals(str)) {
|
||||
str = "\u0000";
|
||||
}
|
||||
handleCheckedStateTransition(512, null, str);
|
||||
this.expectedStates = 129;
|
||||
}
|
||||
|
||||
protected abstract void startArray();
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractWriter, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
if (str == null) {
|
||||
throw new NullPointerException(MediationMetaData.KEY_NAME);
|
||||
}
|
||||
FastStack fastStack = this.stack;
|
||||
fastStack.push(new StackElement(cls, ((StackElement) fastStack.peek()).status));
|
||||
handleCheckedStateTransition(4, str, null);
|
||||
this.expectedStates = 661;
|
||||
}
|
||||
|
||||
protected abstract void startObject();
|
||||
|
||||
public AbstractJsonWriter(int i) {
|
||||
this(i, new NoNameCoder());
|
||||
}
|
||||
|
||||
public AbstractJsonWriter(NameCoder nameCoder) {
|
||||
this(0, nameCoder);
|
||||
}
|
||||
|
||||
public AbstractJsonWriter(int i, NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
this.stack = new FastStack(16);
|
||||
this.mode = (i & 4) > 0 ? 4 : i;
|
||||
this.stack.push(new StackElement(null, 1));
|
||||
this.expectedStates = 4;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
startNode(str, null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,154 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
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.xml.QNameMap;
|
||||
import com.thoughtworks.xstream.io.xml.StaxReader;
|
||||
import com.thoughtworks.xstream.io.xml.StaxWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
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.XMLStreamException;
|
||||
import org.codehaus.jettison.mapped.Configuration;
|
||||
import org.codehaus.jettison.mapped.MappedNamespaceConvention;
|
||||
import org.codehaus.jettison.mapped.MappedXMLInputFactory;
|
||||
import org.codehaus.jettison.mapped.MappedXMLOutputFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JettisonMappedXmlDriver extends AbstractDriver {
|
||||
protected final MappedNamespaceConvention convention;
|
||||
protected final MappedXMLInputFactory mif;
|
||||
protected final MappedXMLOutputFactory mof;
|
||||
protected final boolean useSerializeAsArray;
|
||||
|
||||
public JettisonMappedXmlDriver() {
|
||||
this(new Configuration());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
try {
|
||||
return new StaxReader(new QNameMap(), this.mif.createXMLStreamReader(reader), getNameCoder());
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
try {
|
||||
return this.useSerializeAsArray ? new JettisonStaxWriter(new QNameMap(), this.mof.createXMLStreamWriter(writer), getNameCoder(), this.convention) : new StaxWriter(new QNameMap(), this.mof.createXMLStreamWriter(writer), getNameCoder());
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
public JettisonMappedXmlDriver(Configuration configuration) {
|
||||
this(configuration, true);
|
||||
}
|
||||
|
||||
public JettisonMappedXmlDriver(Configuration configuration, boolean z) {
|
||||
this.mof = new MappedXMLOutputFactory(configuration);
|
||||
this.mif = new MappedXMLInputFactory(configuration);
|
||||
this.convention = new MappedNamespaceConvention(configuration);
|
||||
this.useSerializeAsArray = z;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
try {
|
||||
return new StaxReader(new QNameMap(), this.mif.createXMLStreamReader(inputStream), getNameCoder());
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
try {
|
||||
inputStream = url.openStream();
|
||||
StaxReader staxReader = new StaxReader(new QNameMap(), this.mif.createXMLStreamReader(url.toExternalForm(), inputStream), getNameCoder());
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
return staxReader;
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (IOException e2) {
|
||||
throw new StreamException(e2);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
try {
|
||||
if (this.useSerializeAsArray) {
|
||||
return new JettisonStaxWriter(new QNameMap(), this.mof.createXMLStreamWriter(outputStream), getNameCoder(), this.convention);
|
||||
}
|
||||
return new StaxWriter(new QNameMap(), this.mof.createXMLStreamWriter(outputStream), getNameCoder());
|
||||
} catch (XMLStreamException e) {
|
||||
throw new StreamException((Throwable) e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
FileInputStream fileInputStream;
|
||||
try {
|
||||
try {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
try {
|
||||
StaxReader staxReader = new StaxReader(new QNameMap(), this.mif.createXMLStreamReader(file.toURI().toASCIIString(), fileInputStream), getNameCoder());
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
return staxReader;
|
||||
} catch (XMLStreamException e) {
|
||||
e = e;
|
||||
throw new StreamException((Throwable) e);
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
throw new StreamException(e);
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (XMLStreamException e3) {
|
||||
e = e3;
|
||||
} catch (IOException e4) {
|
||||
e = e4;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream = null;
|
||||
}
|
||||
}
|
||||
}
|
103
sources/com/thoughtworks/xstream/io/json/JettisonStaxWriter.java
Normal file
103
sources/com/thoughtworks/xstream/io/json/JettisonStaxWriter.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.xml.QNameMap;
|
||||
import com.thoughtworks.xstream.io.xml.StaxWriter;
|
||||
import com.thoughtworks.xstream.io.xml.XmlFriendlyReplacer;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import org.codehaus.jettison.mapped.MappedNamespaceConvention;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JettisonStaxWriter extends StaxWriter {
|
||||
static /* synthetic */ Class class$java$util$Collection;
|
||||
static /* synthetic */ Class class$java$util$Map;
|
||||
private final MappedNamespaceConvention convention;
|
||||
|
||||
public JettisonStaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2, NameCoder nameCoder, MappedNamespaceConvention mappedNamespaceConvention) throws XMLStreamException {
|
||||
super(qNameMap, xMLStreamWriter, z, z2, nameCoder);
|
||||
this.convention = mappedNamespaceConvention;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:16:0x0032, code lost:
|
||||
|
||||
if (r6.isArray() == false) goto L21;
|
||||
*/
|
||||
@Override // com.thoughtworks.xstream.io.AbstractWriter, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void startNode(java.lang.String r5, java.lang.Class r6) {
|
||||
/*
|
||||
r4 = this;
|
||||
javax.xml.stream.XMLStreamWriter r0 = r4.getXMLStreamWriter()
|
||||
if (r6 == 0) goto L61
|
||||
boolean r1 = r0 instanceof org.codehaus.jettison.AbstractXMLStreamWriter
|
||||
if (r1 == 0) goto L61
|
||||
java.lang.Class r1 = com.thoughtworks.xstream.io.json.JettisonStaxWriter.class$java$util$Collection
|
||||
if (r1 != 0) goto L16
|
||||
java.lang.String r1 = "java.util.Collection"
|
||||
java.lang.Class r1 = class$(r1)
|
||||
com.thoughtworks.xstream.io.json.JettisonStaxWriter.class$java$util$Collection = r1
|
||||
L16:
|
||||
boolean r1 = r1.isAssignableFrom(r6)
|
||||
if (r1 != 0) goto L34
|
||||
java.lang.Class r1 = com.thoughtworks.xstream.io.json.JettisonStaxWriter.class$java$util$Map
|
||||
if (r1 != 0) goto L28
|
||||
java.lang.String r1 = "java.util.Map"
|
||||
java.lang.Class r1 = class$(r1)
|
||||
com.thoughtworks.xstream.io.json.JettisonStaxWriter.class$java$util$Map = r1
|
||||
L28:
|
||||
boolean r1 = r1.isAssignableFrom(r6)
|
||||
if (r1 != 0) goto L34
|
||||
boolean r6 = r6.isArray()
|
||||
if (r6 == 0) goto L61
|
||||
L34:
|
||||
com.thoughtworks.xstream.io.xml.QNameMap r6 = r4.getQNameMap()
|
||||
java.lang.String r1 = r4.encodeNode(r5)
|
||||
javax.xml.namespace.QName r6 = r6.getQName(r1)
|
||||
java.lang.String r1 = r6.getPrefix()
|
||||
java.lang.String r2 = r6.getNamespaceURI()
|
||||
org.codehaus.jettison.mapped.MappedNamespaceConvention r3 = r4.convention
|
||||
java.lang.String r6 = r6.getLocalPart()
|
||||
java.lang.String r6 = r3.createKey(r1, r2, r6)
|
||||
org.codehaus.jettison.AbstractXMLStreamWriter r0 = (org.codehaus.jettison.AbstractXMLStreamWriter) r0
|
||||
java.util.ArrayList r1 = r0.getSerializedAsArrays()
|
||||
boolean r1 = r1.contains(r6)
|
||||
if (r1 != 0) goto L61
|
||||
r0.seriliazeAsArray(r6)
|
||||
L61:
|
||||
r4.startNode(r5)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.io.json.JettisonStaxWriter.startNode(java.lang.String, java.lang.Class):void");
|
||||
}
|
||||
|
||||
public JettisonStaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2, XmlFriendlyReplacer xmlFriendlyReplacer, MappedNamespaceConvention mappedNamespaceConvention) throws XMLStreamException {
|
||||
this(qNameMap, xMLStreamWriter, z, z2, (NameCoder) xmlFriendlyReplacer, mappedNamespaceConvention);
|
||||
}
|
||||
|
||||
public JettisonStaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, boolean z, boolean z2, MappedNamespaceConvention mappedNamespaceConvention) throws XMLStreamException {
|
||||
super(qNameMap, xMLStreamWriter, z, z2);
|
||||
this.convention = mappedNamespaceConvention;
|
||||
}
|
||||
|
||||
public JettisonStaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, MappedNamespaceConvention mappedNamespaceConvention) throws XMLStreamException {
|
||||
super(qNameMap, xMLStreamWriter);
|
||||
this.convention = mappedNamespaceConvention;
|
||||
}
|
||||
|
||||
public JettisonStaxWriter(QNameMap qNameMap, XMLStreamWriter xMLStreamWriter, NameCoder nameCoder, MappedNamespaceConvention mappedNamespaceConvention) throws XMLStreamException {
|
||||
super(qNameMap, xMLStreamWriter, nameCoder);
|
||||
this.convention = mappedNamespaceConvention;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
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.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JsonHierarchicalStreamDriver extends AbstractDriver {
|
||||
public JsonHierarchicalStreamDriver() {
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(Reader reader) {
|
||||
throw new UnsupportedOperationException("The JsonHierarchicalStreamDriver can only write JSON");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(Writer writer) {
|
||||
return new JsonWriter(writer);
|
||||
}
|
||||
|
||||
public JsonHierarchicalStreamDriver(NameCoder nameCoder) {
|
||||
super(nameCoder);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(InputStream inputStream) {
|
||||
throw new UnsupportedOperationException("The JsonHierarchicalStreamDriver can only write JSON");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamWriter createWriter(OutputStream outputStream) {
|
||||
try {
|
||||
return createWriter(new OutputStreamWriter(outputStream, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new StreamException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(URL url) {
|
||||
throw new UnsupportedOperationException("The JsonHierarchicalStreamDriver can only write JSON");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractDriver, com.thoughtworks.xstream.io.HierarchicalStreamDriver
|
||||
public HierarchicalStreamReader createReader(File file) {
|
||||
throw new UnsupportedOperationException("The JsonHierarchicalStreamDriver can only write JSON");
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JsonHierarchicalStreamWriter extends JsonWriter {
|
||||
public JsonHierarchicalStreamWriter(Writer writer, char[] cArr, String str) {
|
||||
super(writer, cArr, str);
|
||||
}
|
||||
|
||||
public JsonHierarchicalStreamWriter(Writer writer, char[] cArr) {
|
||||
this(writer, cArr, "\n");
|
||||
}
|
||||
|
||||
public JsonHierarchicalStreamWriter(Writer writer, String str, String str2) {
|
||||
this(writer, str.toCharArray(), str2);
|
||||
}
|
||||
|
||||
public JsonHierarchicalStreamWriter(Writer writer, String str) {
|
||||
this(writer, str.toCharArray());
|
||||
}
|
||||
|
||||
public JsonHierarchicalStreamWriter(Writer writer) {
|
||||
this(writer, new char[]{' ', ' '});
|
||||
}
|
||||
}
|
253
sources/com/thoughtworks/xstream/io/json/JsonWriter.java
Normal file
253
sources/com/thoughtworks/xstream/io/json/JsonWriter.java
Normal file
@@ -0,0 +1,253 @@
|
||||
package com.thoughtworks.xstream.io.json;
|
||||
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.thoughtworks.xstream.core.util.QuickWriter;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.json.AbstractJsonWriter;
|
||||
import com.thoughtworks.xstream.io.naming.NameCoder;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
import java.io.Writer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JsonWriter extends AbstractJsonWriter {
|
||||
private int depth;
|
||||
protected final Format format;
|
||||
private boolean newLineProposed;
|
||||
protected final QuickWriter writer;
|
||||
|
||||
public static class Format {
|
||||
public static int COMPACT_EMPTY_ELEMENT = 2;
|
||||
public static int SPACE_AFTER_LABEL = 1;
|
||||
private char[] lineIndenter;
|
||||
private final int mode;
|
||||
private final NameCoder nameCoder;
|
||||
private char[] newLine;
|
||||
|
||||
public Format() {
|
||||
this(new char[]{' ', ' '}, new char[]{'\n'}, SPACE_AFTER_LABEL | COMPACT_EMPTY_ELEMENT);
|
||||
}
|
||||
|
||||
public char[] getLineIndenter() {
|
||||
return this.lineIndenter;
|
||||
}
|
||||
|
||||
public NameCoder getNameCoder() {
|
||||
return this.nameCoder;
|
||||
}
|
||||
|
||||
public char[] getNewLine() {
|
||||
return this.newLine;
|
||||
}
|
||||
|
||||
public int mode() {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public Format(char[] cArr, char[] cArr2, int i) {
|
||||
this(cArr, cArr2, i, new NoNameCoder());
|
||||
}
|
||||
|
||||
public Format(char[] cArr, char[] cArr2, int i, NameCoder nameCoder) {
|
||||
this.lineIndenter = cArr;
|
||||
this.newLine = cArr2;
|
||||
this.mode = i;
|
||||
this.nameCoder = nameCoder;
|
||||
}
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, char[] cArr, String str) {
|
||||
this(writer, 0, new Format(cArr, str.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
private void endNewLine() {
|
||||
int i = this.depth;
|
||||
this.depth = i - 1;
|
||||
if (i > 0) {
|
||||
if ((this.format.mode() & Format.COMPACT_EMPTY_ELEMENT) == 0 || !this.newLineProposed) {
|
||||
writeNewLine();
|
||||
} else {
|
||||
this.newLineProposed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startNewLine() {
|
||||
int i = this.depth + 1;
|
||||
this.depth = i;
|
||||
if (i > 0) {
|
||||
this.newLineProposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeNewLine() {
|
||||
int i = this.depth;
|
||||
this.writer.write(this.format.getNewLine());
|
||||
while (true) {
|
||||
int i2 = i - 1;
|
||||
if (i <= 0) {
|
||||
this.newLineProposed = false;
|
||||
return;
|
||||
} else {
|
||||
this.writer.write(this.format.getLineIndenter());
|
||||
i = i2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeText(String str) {
|
||||
int length = str.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
char charAt = str.charAt(i);
|
||||
if (charAt == '\f') {
|
||||
this.writer.write("\\f");
|
||||
} else if (charAt == '\r') {
|
||||
this.writer.write("\\r");
|
||||
} else if (charAt == '\"') {
|
||||
this.writer.write("\\\"");
|
||||
} else if (charAt != '\\') {
|
||||
switch (charAt) {
|
||||
case '\b':
|
||||
this.writer.write("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
this.writer.write("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
this.writer.write("\\n");
|
||||
break;
|
||||
default:
|
||||
if (charAt > 31) {
|
||||
this.writer.write(charAt);
|
||||
break;
|
||||
} else {
|
||||
this.writer.write("\\u");
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("000");
|
||||
stringBuffer.append(Integer.toHexString(charAt));
|
||||
this.writer.write(stringBuffer.toString().substring(r2.length() - 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.writer.write("\\\\");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void addLabel(String str) {
|
||||
if (this.newLineProposed) {
|
||||
writeNewLine();
|
||||
}
|
||||
this.writer.write('\"');
|
||||
writeText(str);
|
||||
this.writer.write("\":");
|
||||
if ((this.format.mode() & Format.SPACE_AFTER_LABEL) != 0) {
|
||||
this.writer.write(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void addValue(String str, AbstractJsonWriter.Type type) {
|
||||
if (this.newLineProposed) {
|
||||
writeNewLine();
|
||||
}
|
||||
if (type == AbstractJsonWriter.Type.STRING) {
|
||||
this.writer.write('\"');
|
||||
}
|
||||
writeText(str);
|
||||
if (type == AbstractJsonWriter.Type.STRING) {
|
||||
this.writer.write('\"');
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void close() {
|
||||
this.writer.close();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void endArray() {
|
||||
endNewLine();
|
||||
this.writer.write("]");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void endObject() {
|
||||
endNewLine();
|
||||
this.writer.write("}");
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void flush() {
|
||||
this.writer.flush();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void nextElement() {
|
||||
this.writer.write(",");
|
||||
writeNewLine();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void startArray() {
|
||||
if (this.newLineProposed) {
|
||||
writeNewLine();
|
||||
}
|
||||
this.writer.write("[");
|
||||
startNewLine();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.json.AbstractJsonWriter
|
||||
protected void startObject() {
|
||||
if (this.newLineProposed) {
|
||||
writeNewLine();
|
||||
}
|
||||
this.writer.write('{');
|
||||
startNewLine();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.AbstractWriter, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public HierarchicalStreamWriter underlyingWriter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, char[] cArr) {
|
||||
this(writer, 0, new Format(cArr, new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, String str, String str2) {
|
||||
this(writer, 0, new Format(str.toCharArray(), str2.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, String str) {
|
||||
this(writer, 0, new Format(str.toCharArray(), new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer) {
|
||||
this(writer, 0, new Format(new char[]{' ', ' '}, new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, char[] cArr, String str, int i) {
|
||||
this(writer, i, new Format(cArr, str.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT));
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, int i) {
|
||||
this(writer, i, new Format());
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, Format format) {
|
||||
this(writer, 0, format);
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, int i, Format format) {
|
||||
this(writer, i, format, DataDecryptTool.DECRYPT_SP_FILE);
|
||||
}
|
||||
|
||||
public JsonWriter(Writer writer, int i, Format format, int i2) {
|
||||
super(i, format.getNameCoder());
|
||||
this.writer = new QuickWriter(writer, i2);
|
||||
this.format = format;
|
||||
this.depth = (i & 1) == 0 ? -1 : 0;
|
||||
}
|
||||
}
|
12
sources/com/thoughtworks/xstream/io/naming/NameCoder.java
Normal file
12
sources/com/thoughtworks/xstream/io/naming/NameCoder.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.thoughtworks.xstream.io.naming;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface NameCoder {
|
||||
String decodeAttribute(String str);
|
||||
|
||||
String decodeNode(String str);
|
||||
|
||||
String encodeAttribute(String str);
|
||||
|
||||
String encodeNode(String str);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.thoughtworks.xstream.io.naming;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class NameCoderWrapper implements NameCoder {
|
||||
private final NameCoder wrapped;
|
||||
|
||||
public NameCoderWrapper(NameCoder nameCoder) {
|
||||
this.wrapped = nameCoder;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
return this.wrapped.decodeAttribute(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
return this.wrapped.decodeNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeAttribute(String str) {
|
||||
return this.wrapped.encodeAttribute(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeNode(String str) {
|
||||
return this.wrapped.encodeNode(str);
|
||||
}
|
||||
}
|
24
sources/com/thoughtworks/xstream/io/naming/NoNameCoder.java
Normal file
24
sources/com/thoughtworks/xstream/io/naming/NoNameCoder.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.thoughtworks.xstream.io.naming;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class NoNameCoder implements NameCoder {
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeAttribute(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeNode(String str) {
|
||||
return str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.thoughtworks.xstream.io.naming;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StaticNameCoder implements NameCoder {
|
||||
private transient Map attribute2Java;
|
||||
private final Map java2Attribute;
|
||||
private final Map java2Node;
|
||||
private transient Map node2Java;
|
||||
|
||||
public StaticNameCoder(Map map, Map map2) {
|
||||
this.java2Node = new HashMap(map);
|
||||
if (map == map2 || map2 == null) {
|
||||
this.java2Attribute = this.java2Node;
|
||||
} else {
|
||||
this.java2Attribute = new HashMap(map2);
|
||||
}
|
||||
readResolve();
|
||||
}
|
||||
|
||||
private Map invertMap(Map map) {
|
||||
HashMap hashMap = new HashMap(map.size());
|
||||
for (Map.Entry entry : map.entrySet()) {
|
||||
hashMap.put((String) entry.getValue(), (String) entry.getKey());
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
this.node2Java = invertMap(this.java2Node);
|
||||
Map map = this.java2Node;
|
||||
Map map2 = this.java2Attribute;
|
||||
if (map == map2) {
|
||||
this.attribute2Java = this.node2Java;
|
||||
} else {
|
||||
this.attribute2Java = invertMap(map2);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeAttribute(String str) {
|
||||
String str2 = (String) this.attribute2Java.get(str);
|
||||
return str2 == null ? str : str2;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String decodeNode(String str) {
|
||||
String str2 = (String) this.node2Java.get(str);
|
||||
return str2 == null ? str : str2;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeAttribute(String str) {
|
||||
String str2 = (String) this.java2Attribute.get(str);
|
||||
return str2 == null ? str : str2;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.naming.NameCoder
|
||||
public String encodeNode(String str) {
|
||||
String str2 = (String) this.java2Node.get(str);
|
||||
return str2 == null ? str : str2;
|
||||
}
|
||||
}
|
197
sources/com/thoughtworks/xstream/io/path/Path.java
Normal file
197
sources/com/thoughtworks/xstream/io/path/Path.java
Normal file
@@ -0,0 +1,197 @@
|
||||
package com.thoughtworks.xstream.io.path;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastStack;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Path {
|
||||
private static final Path DOT = new Path(new String[]{"."});
|
||||
private final String[] chunks;
|
||||
private transient String pathAsString;
|
||||
private transient String pathExplicit;
|
||||
|
||||
public Path(String str) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
this.pathAsString = str;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
int indexOf = str.indexOf(47, i);
|
||||
if (indexOf == -1) {
|
||||
arrayList.add(normalize(str, i, str.length()));
|
||||
String[] strArr = new String[arrayList.size()];
|
||||
arrayList.toArray(strArr);
|
||||
this.chunks = strArr;
|
||||
return;
|
||||
}
|
||||
arrayList.add(normalize(str, i, indexOf));
|
||||
i = indexOf + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int depthOfPathDivergence(String[] strArr, String[] strArr2) {
|
||||
int min = Math.min(strArr.length, strArr2.length);
|
||||
for (int i = 0; i < min; i++) {
|
||||
if (!strArr[i].equals(strArr2[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
private String normalize(String str, int i, int i2) {
|
||||
if (i2 - i > 3) {
|
||||
int i3 = i2 - 3;
|
||||
if (str.charAt(i3) == '[' && str.charAt(i2 - 2) == '1' && str.charAt(i2 - 1) == ']') {
|
||||
this.pathAsString = null;
|
||||
return str.substring(i, i3);
|
||||
}
|
||||
}
|
||||
return str.substring(i, i2);
|
||||
}
|
||||
|
||||
public Path apply(Path path) {
|
||||
FastStack fastStack = new FastStack(16);
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String[] strArr = this.chunks;
|
||||
if (i >= strArr.length) {
|
||||
break;
|
||||
}
|
||||
fastStack.push(strArr[i]);
|
||||
i++;
|
||||
}
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
String[] strArr2 = path.chunks;
|
||||
if (i2 >= strArr2.length) {
|
||||
break;
|
||||
}
|
||||
String str = strArr2[i2];
|
||||
if (str.equals("..")) {
|
||||
fastStack.pop();
|
||||
} else if (!str.equals(".")) {
|
||||
fastStack.push(str);
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
String[] strArr3 = new String[fastStack.size()];
|
||||
for (int i3 = 0; i3 < strArr3.length; i3++) {
|
||||
strArr3[i3] = (String) fastStack.get(i3);
|
||||
}
|
||||
return new Path(strArr3);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Path)) {
|
||||
return false;
|
||||
}
|
||||
Path path = (Path) obj;
|
||||
if (this.chunks.length != path.chunks.length) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String[] strArr = this.chunks;
|
||||
if (i >= strArr.length) {
|
||||
return true;
|
||||
}
|
||||
if (!strArr[i].equals(path.chunks[i])) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public String explicit() {
|
||||
char charAt;
|
||||
if (this.pathExplicit == null) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < this.chunks.length; i++) {
|
||||
if (i > 0) {
|
||||
stringBuffer.append('/');
|
||||
}
|
||||
String str = this.chunks[i];
|
||||
stringBuffer.append(str);
|
||||
int length = str.length();
|
||||
if (length > 0 && (charAt = str.charAt(length - 1)) != ']' && charAt != '.') {
|
||||
stringBuffer.append("[1]");
|
||||
}
|
||||
}
|
||||
this.pathExplicit = stringBuffer.toString();
|
||||
}
|
||||
return this.pathExplicit;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int i = 543645643;
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
String[] strArr = this.chunks;
|
||||
if (i2 >= strArr.length) {
|
||||
return i;
|
||||
}
|
||||
i = (i * 29) + strArr[i2].hashCode();
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAncestor(Path path) {
|
||||
if (path == null || path.chunks.length < this.chunks.length) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String[] strArr = this.chunks;
|
||||
if (i >= strArr.length) {
|
||||
return true;
|
||||
}
|
||||
if (!strArr[i].equals(path.chunks[i])) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public Path relativeTo(Path path) {
|
||||
int depthOfPathDivergence = depthOfPathDivergence(this.chunks, path.chunks);
|
||||
String[] strArr = new String[(this.chunks.length + path.chunks.length) - (depthOfPathDivergence * 2)];
|
||||
int i = depthOfPathDivergence;
|
||||
int i2 = 0;
|
||||
while (i < this.chunks.length) {
|
||||
strArr[i2] = "..";
|
||||
i++;
|
||||
i2++;
|
||||
}
|
||||
while (true) {
|
||||
String[] strArr2 = path.chunks;
|
||||
if (depthOfPathDivergence >= strArr2.length) {
|
||||
break;
|
||||
}
|
||||
strArr[i2] = strArr2[depthOfPathDivergence];
|
||||
depthOfPathDivergence++;
|
||||
i2++;
|
||||
}
|
||||
return i2 == 0 ? DOT : new Path(strArr);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (this.pathAsString == null) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < this.chunks.length; i++) {
|
||||
if (i > 0) {
|
||||
stringBuffer.append('/');
|
||||
}
|
||||
stringBuffer.append(this.chunks[i]);
|
||||
}
|
||||
this.pathAsString = stringBuffer.toString();
|
||||
}
|
||||
return this.pathAsString;
|
||||
}
|
||||
|
||||
public Path(String[] strArr) {
|
||||
this.chunks = strArr;
|
||||
}
|
||||
}
|
111
sources/com/thoughtworks/xstream/io/path/PathTracker.java
Normal file
111
sources/com/thoughtworks/xstream/io/path/PathTracker.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package com.thoughtworks.xstream.io.path;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PathTracker {
|
||||
private int capacity;
|
||||
private Path currentPath;
|
||||
private Map[] indexMapStack;
|
||||
private String[] pathStack;
|
||||
private int pointer;
|
||||
|
||||
public PathTracker() {
|
||||
this(16);
|
||||
}
|
||||
|
||||
private void resizeStacks(int i) {
|
||||
String[] strArr = new String[i];
|
||||
Map[] mapArr = new Map[i];
|
||||
int min = Math.min(this.capacity, i);
|
||||
System.arraycopy(this.pathStack, 0, strArr, 0, min);
|
||||
System.arraycopy(this.indexMapStack, 0, mapArr, 0, min);
|
||||
this.pathStack = strArr;
|
||||
this.indexMapStack = mapArr;
|
||||
this.capacity = i;
|
||||
}
|
||||
|
||||
public int depth() {
|
||||
return this.pointer;
|
||||
}
|
||||
|
||||
public Path getPath() {
|
||||
if (this.currentPath == null) {
|
||||
int i = this.pointer;
|
||||
String[] strArr = new String[i + 1];
|
||||
strArr[0] = "";
|
||||
int i2 = -i;
|
||||
while (true) {
|
||||
i2++;
|
||||
if (i2 > 0) {
|
||||
break;
|
||||
}
|
||||
strArr[this.pointer + i2] = peekElement(i2);
|
||||
}
|
||||
this.currentPath = new Path(strArr);
|
||||
}
|
||||
return this.currentPath;
|
||||
}
|
||||
|
||||
public String peekElement() {
|
||||
return peekElement(0);
|
||||
}
|
||||
|
||||
public void popElement() {
|
||||
Map[] mapArr = this.indexMapStack;
|
||||
int i = this.pointer;
|
||||
mapArr[i] = null;
|
||||
this.pathStack[i] = null;
|
||||
this.currentPath = null;
|
||||
this.pointer = i - 1;
|
||||
}
|
||||
|
||||
public void pushElement(String str) {
|
||||
int i = this.pointer + 1;
|
||||
int i2 = this.capacity;
|
||||
if (i >= i2) {
|
||||
resizeStacks(i2 * 2);
|
||||
}
|
||||
String[] strArr = this.pathStack;
|
||||
int i3 = this.pointer;
|
||||
strArr[i3] = str;
|
||||
Map map = this.indexMapStack[i3];
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
this.indexMapStack[this.pointer] = map;
|
||||
}
|
||||
if (map.containsKey(str)) {
|
||||
map.put(str, new Integer(((Integer) map.get(str)).intValue() + 1));
|
||||
} else {
|
||||
map.put(str, new Integer(1));
|
||||
}
|
||||
this.pointer++;
|
||||
this.currentPath = null;
|
||||
}
|
||||
|
||||
public PathTracker(int i) {
|
||||
this.capacity = Math.max(1, i);
|
||||
int i2 = this.capacity;
|
||||
this.pathStack = new String[i2];
|
||||
this.indexMapStack = new Map[i2];
|
||||
}
|
||||
|
||||
public String peekElement(int i) {
|
||||
int i2 = this.pointer;
|
||||
if (i < (-i2) || i > 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(i);
|
||||
}
|
||||
int i3 = (i2 + i) - 1;
|
||||
int intValue = ((Integer) this.indexMapStack[i3].get(this.pathStack[i3])).intValue();
|
||||
if (intValue <= 1) {
|
||||
return this.pathStack[i3];
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer(this.pathStack[i3].length() + 6);
|
||||
stringBuffer.append(this.pathStack[i3]);
|
||||
stringBuffer.append('[');
|
||||
stringBuffer.append(intValue);
|
||||
stringBuffer.append(']');
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.thoughtworks.xstream.io.path;
|
||||
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.thoughtworks.xstream.converters.ErrorWriter;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.ReaderWrapper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PathTrackingReader extends ReaderWrapper {
|
||||
private final PathTracker pathTracker;
|
||||
|
||||
public PathTrackingReader(HierarchicalStreamReader hierarchicalStreamReader, PathTracker pathTracker) {
|
||||
super(hierarchicalStreamReader);
|
||||
this.pathTracker = pathTracker;
|
||||
pathTracker.pushElement(getNodeName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ReaderWrapper, com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.ErrorReporter
|
||||
public void appendErrors(ErrorWriter errorWriter) {
|
||||
errorWriter.add(FileDownloadModel.PATH, this.pathTracker.getPath().toString());
|
||||
super.appendErrors(errorWriter);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ReaderWrapper, com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveDown() {
|
||||
super.moveDown();
|
||||
this.pathTracker.pushElement(getNodeName());
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.ReaderWrapper, com.thoughtworks.xstream.io.HierarchicalStreamReader
|
||||
public void moveUp() {
|
||||
super.moveUp();
|
||||
this.pathTracker.popElement();
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.thoughtworks.xstream.io.path;
|
||||
|
||||
import com.thoughtworks.xstream.io.AbstractWriter;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.thoughtworks.xstream.io.WriterWrapper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PathTrackingWriter extends WriterWrapper {
|
||||
private final boolean isNameEncoding;
|
||||
private final PathTracker pathTracker;
|
||||
|
||||
public PathTrackingWriter(HierarchicalStreamWriter hierarchicalStreamWriter, PathTracker pathTracker) {
|
||||
super(hierarchicalStreamWriter);
|
||||
this.isNameEncoding = hierarchicalStreamWriter.underlyingWriter() instanceof AbstractWriter;
|
||||
this.pathTracker = pathTracker;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void endNode() {
|
||||
super.endNode();
|
||||
this.pathTracker.popElement();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.HierarchicalStreamWriter
|
||||
public void startNode(String str) {
|
||||
this.pathTracker.pushElement(this.isNameEncoding ? ((AbstractWriter) this.wrapped.underlyingWriter()).encodeNode(str) : str);
|
||||
super.startNode(str);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.io.WriterWrapper, com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
|
||||
public void startNode(String str, Class cls) {
|
||||
this.pathTracker.pushElement(this.isNameEncoding ? ((AbstractWriter) this.wrapped.underlyingWriter()).encodeNode(str) : str);
|
||||
super.startNode(str, cls);
|
||||
}
|
||||
}
|
@@ -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