375 lines
14 KiB
Java
375 lines
14 KiB
Java
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);
|
|
}
|
|
}
|