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

344 lines
11 KiB
Java

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