Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}

View 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]);
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}