package com.ta.utdid2.b.a; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; import org.xmlpull.v1.XmlSerializer; class a implements XmlSerializer { /* renamed from: a reason: collision with root package name */ private static final String[] f12792a = {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, """, null, null, null, "&", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "<", null, ">", null}; /* renamed from: a reason: collision with other field name */ private OutputStream f2a; /* renamed from: a reason: collision with other field name */ private Writer f3a; /* renamed from: a reason: collision with other field name */ private ByteBuffer f4a = ByteBuffer.allocate(8192); /* renamed from: a reason: collision with other field name */ private CharsetEncoder f5a; /* renamed from: a reason: collision with other field name */ private final char[] f6a = new char[8192]; /* renamed from: b reason: collision with root package name */ private boolean f12793b; private int mPos; a() { } private void a() throws IOException { int position = this.f4a.position(); if (position > 0) { this.f4a.flip(); this.f2a.write(this.f4a.array(), 0, position); this.f4a.clear(); } } private void a(String str) throws IOException { String str2; int length = str.length(); String[] strArr = f12792a; char length2 = (char) strArr.length; int i = 0; int i2 = 0; while (i < length) { char charAt = str.charAt(i); if (charAt < length2 && (str2 = strArr[charAt]) != null) { if (i2 < i) { a(str, i2, i - i2); } i2 = i + 1; append(str2); } i++; } if (i2 < i) { a(str, i2, i - i2); } } private void a(String str, int i, int i2) throws IOException { if (i2 > 8192) { int i3 = i2 + i; while (i < i3) { int i4 = i + 8192; a(str, i, i4 < i3 ? 8192 : i3 - i); i = i4; } return; } int i5 = this.mPos; if (i5 + i2 > 8192) { flush(); i5 = this.mPos; } str.getChars(i, i + i2, this.f6a, i5); this.mPos = i5 + i2; } private void a(char[] cArr, int i, int i2) throws IOException { String str; String[] strArr = f12792a; char length = (char) strArr.length; int i3 = i2 + i; int i4 = i; while (i < i3) { char c2 = cArr[i]; if (c2 < length && (str = strArr[c2]) != null) { if (i4 < i) { append(cArr, i4, i - i4); } i4 = i + 1; append(str); } i++; } if (i4 < i) { append(cArr, i4, i - i4); } } private void append(char c2) throws IOException { int i = this.mPos; if (i >= 8191) { flush(); i = this.mPos; } this.f6a[i] = c2; this.mPos = i + 1; } private void append(String str) throws IOException { a(str, 0, str.length()); } private void append(char[] cArr, int i, int i2) throws IOException { if (i2 > 8192) { int i3 = i2 + i; while (i < i3) { int i4 = i + 8192; append(cArr, i, i4 < i3 ? 8192 : i3 - i); i = i4; } return; } int i5 = this.mPos; if (i5 + i2 > 8192) { flush(); i5 = this.mPos; } System.arraycopy(cArr, i, this.f6a, i5, i2); this.mPos = i5 + i2; } @Override // org.xmlpull.v1.XmlSerializer public XmlSerializer attribute(String str, String str2, String str3) throws IOException, IllegalArgumentException, IllegalStateException { append(' '); if (str != null) { append(str); append(':'); } append(str2); append("=\""); a(str3); append('\"'); return this; } @Override // org.xmlpull.v1.XmlSerializer public void cdsect(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void comment(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void docdecl(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void endDocument() throws IOException, IllegalArgumentException, IllegalStateException { flush(); } @Override // org.xmlpull.v1.XmlSerializer public XmlSerializer endTag(String str, String str2) throws IOException, IllegalArgumentException, IllegalStateException { String str3; if (this.f12793b) { str3 = " />\n"; } else { append("</"); if (str != null) { append(str); append(':'); } append(str2); str3 = ">\n"; } append(str3); this.f12793b = false; return this; } @Override // org.xmlpull.v1.XmlSerializer public void entityRef(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void flush() throws IOException { int i = this.mPos; if (i > 0) { if (this.f2a != null) { CharBuffer wrap = CharBuffer.wrap(this.f6a, 0, i); CharsetEncoder charsetEncoder = this.f5a; ByteBuffer byteBuffer = this.f4a; while (true) { CoderResult encode = charsetEncoder.encode(wrap, byteBuffer, true); if (!encode.isError()) { if (!encode.isOverflow()) { a(); this.f2a.flush(); break; } a(); charsetEncoder = this.f5a; byteBuffer = this.f4a; } else { throw new IOException(encode.toString()); } } } else { this.f3a.write(this.f6a, 0, i); this.f3a.flush(); } this.mPos = 0; } } public int getDepth() { throw new UnsupportedOperationException(); } public boolean getFeature(String str) { throw new UnsupportedOperationException(); } public String getName() { throw new UnsupportedOperationException(); } public String getNamespace() { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public String getPrefix(String str, boolean z) throws IllegalArgumentException { throw new UnsupportedOperationException(); } public Object getProperty(String str) { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void ignorableWhitespace(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void processingInstruction(String str) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void setFeature(String str, boolean z) throws IllegalArgumentException, IllegalStateException { if (!str.equals("http://xmlpull.org/v1/doc/features.html#indent-output")) { throw new UnsupportedOperationException(); } } @Override // org.xmlpull.v1.XmlSerializer public void setOutput(OutputStream outputStream, String str) throws IOException, IllegalArgumentException, IllegalStateException { if (outputStream != null) { try { this.f5a = Charset.forName(str).newEncoder(); this.f2a = outputStream; } catch (IllegalCharsetNameException e2) { throw ((UnsupportedEncodingException) new UnsupportedEncodingException(str).initCause(e2)); } catch (UnsupportedCharsetException e3) { throw ((UnsupportedEncodingException) new UnsupportedEncodingException(str).initCause(e3)); } } else { throw new IllegalArgumentException(); } } @Override // org.xmlpull.v1.XmlSerializer public void setOutput(Writer writer) throws IOException, IllegalArgumentException, IllegalStateException { this.f3a = writer; } @Override // org.xmlpull.v1.XmlSerializer public void setPrefix(String str, String str2) throws IOException, IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void setProperty(String str, Object obj) throws IllegalArgumentException, IllegalStateException { throw new UnsupportedOperationException(); } @Override // org.xmlpull.v1.XmlSerializer public void startDocument(String str, Boolean bool) throws IOException, IllegalArgumentException, IllegalStateException { StringBuilder sb = new StringBuilder(); sb.append("<?xml version='1.0' encoding='utf-8' standalone='"); sb.append(bool.booleanValue() ? "yes" : "no"); sb.append("' ?>\n"); append(sb.toString()); } @Override // org.xmlpull.v1.XmlSerializer public XmlSerializer startTag(String str, String str2) throws IOException, IllegalArgumentException, IllegalStateException { if (this.f12793b) { append(">\n"); } append('<'); if (str != null) { append(str); append(':'); } append(str2); this.f12793b = true; return this; } @Override // org.xmlpull.v1.XmlSerializer public XmlSerializer text(String str) throws IOException, IllegalArgumentException, IllegalStateException { if (this.f12793b) { append(">"); this.f12793b = false; } a(str); return this; } @Override // org.xmlpull.v1.XmlSerializer public XmlSerializer text(char[] cArr, int i, int i2) throws IOException, IllegalArgumentException, IllegalStateException { if (this.f12793b) { append(">"); this.f12793b = false; } a(cArr, i, i2); return this; } }