first commit
[bylock.git] / sources / com / google / android / gms / internal / ds.java
blob7f61bc9dfc8cedd471a12e3bc690619ce9606499
1 package com.google.android.gms.internal;
3 public final class ds {
4 private final byte[] a;
5 private int b;
6 private int c;
7 private int d;
8 private int e;
9 private int f;
10 private int g = Integer.MAX_VALUE;
11 private int h;
12 private int i = 64;
13 private int j = 67108864;
15 private ds(byte[] bArr, int i2, int i3) {
16 this.a = bArr;
17 this.b = i2;
18 this.c = i2 + i3;
19 this.e = i2;
22 public static long a(long j2) {
23 return (j2 >>> 1) ^ (-(1 & j2));
26 public static ds a(byte[] bArr) {
27 return a(bArr, 0, bArr.length);
30 public static ds a(byte[] bArr, int i2, int i3) {
31 return new ds(bArr, i2, i3);
34 private void q() {
35 this.c += this.d;
36 int i2 = this.c;
37 if (i2 > this.g) {
38 this.d = i2 - this.g;
39 this.c -= this.d;
40 return;
42 this.d = 0;
45 public int a() {
46 if (n()) {
47 this.f = 0;
48 return 0;
50 this.f = i();
51 if (this.f != 0) {
52 return this.f;
54 throw dz.d();
57 public void a(int i2) {
58 if (this.f != i2) {
59 throw dz.e();
63 public void a(ea eaVar) {
64 int i2 = i();
65 if (this.h >= this.i) {
66 throw dz.g();
68 int c2 = c(i2);
69 this.h++;
70 eaVar.b(this);
71 a(0);
72 this.h--;
73 d(c2);
76 public void a(ea eaVar, int i2) {
77 if (this.h >= this.i) {
78 throw dz.g();
80 this.h++;
81 eaVar.b(this);
82 a(ed.a(i2, 4));
83 this.h--;
86 public byte[] a(int i2, int i3) {
87 if (i3 == 0) {
88 return ed.h;
90 byte[] bArr = new byte[i3];
91 System.arraycopy(this.a, this.b + i2, bArr, 0, i3);
92 return bArr;
95 public void b() {
96 int a2;
97 do {
98 a2 = a();
99 if (a2 == 0) {
100 return;
102 } while (b(a2));
105 public boolean b(int i2) {
106 switch (ed.a(i2)) {
107 case 0:
108 e();
109 return true;
110 case 1:
111 l();
112 return true;
113 case 2:
114 g(i());
115 return true;
116 case 3:
117 b();
118 a(ed.a(ed.b(i2), 4));
119 return true;
120 case 4:
121 return false;
122 case 5:
123 k();
124 return true;
125 default:
126 throw dz.f();
130 public float c() {
131 return Float.intBitsToFloat(k());
134 public int c(int i2) {
135 if (i2 < 0) {
136 throw dz.b();
138 int i3 = this.e + i2;
139 int i4 = this.g;
140 if (i3 > i4) {
141 throw dz.a();
143 this.g = i3;
144 q();
145 return i4;
148 public long d() {
149 return j();
152 public void d(int i2) {
153 this.g = i2;
154 q();
157 public int e() {
158 return i();
161 public void e(int i2) {
162 if (i2 > this.e - this.b) {
163 throw new IllegalArgumentException("Position " + i2 + " is beyond current " + (this.e - this.b));
164 } else if (i2 < 0) {
165 throw new IllegalArgumentException("Bad position " + i2);
166 } else {
167 this.e = this.b + i2;
171 public boolean f() {
172 return i() != 0;
175 public byte[] f(int i2) {
176 if (i2 < 0) {
177 throw dz.b();
178 } else if (this.e + i2 > this.g) {
179 g(this.g - this.e);
180 throw dz.a();
181 } else if (i2 <= this.c - this.e) {
182 byte[] bArr = new byte[i2];
183 System.arraycopy(this.a, this.e, bArr, 0, i2);
184 this.e += i2;
185 return bArr;
186 } else {
187 throw dz.a();
191 public String g() {
192 int i2 = i();
193 if (i2 > this.c - this.e || i2 <= 0) {
194 return new String(f(i2), "UTF-8");
196 String str = new String(this.a, this.e, i2, "UTF-8");
197 this.e = i2 + this.e;
198 return str;
201 public void g(int i2) {
202 if (i2 < 0) {
203 throw dz.b();
204 } else if (this.e + i2 > this.g) {
205 g(this.g - this.e);
206 throw dz.a();
207 } else if (i2 <= this.c - this.e) {
208 this.e += i2;
209 } else {
210 throw dz.a();
214 public long h() {
215 return a(j());
218 public int i() {
219 byte p = p();
220 if (p >= 0) {
221 return p;
223 int i2 = p & Byte.MAX_VALUE;
224 byte p2 = p();
225 if (p2 >= 0) {
226 return i2 | (p2 << 7);
228 int i3 = i2 | ((p2 & Byte.MAX_VALUE) << 7);
229 byte p3 = p();
230 if (p3 >= 0) {
231 return i3 | (p3 << 14);
233 int i4 = i3 | ((p3 & Byte.MAX_VALUE) << 14);
234 byte p4 = p();
235 if (p4 >= 0) {
236 return i4 | (p4 << 21);
238 int i5 = i4 | ((p4 & Byte.MAX_VALUE) << 21);
239 byte p5 = p();
240 int i6 = i5 | (p5 << 28);
241 if (p5 >= 0) {
242 return i6;
244 for (int i7 = 0; i7 < 5; i7++) {
245 if (p() >= 0) {
246 return i6;
249 throw dz.c();
252 public long j() {
253 long j2 = 0;
254 for (int i2 = 0; i2 < 64; i2 += 7) {
255 byte p = p();
256 j2 |= ((long) (p & Byte.MAX_VALUE)) << i2;
257 if ((p & 128) == 0) {
258 return j2;
261 throw dz.c();
264 public int k() {
265 return (p() & 255) | ((p() & 255) << 8) | ((p() & 255) << 16) | ((p() & 255) << 24);
268 public long l() {
269 byte p = p();
270 byte p2 = p();
271 return ((((long) p2) & 255) << 8) | (((long) p) & 255) | ((((long) p()) & 255) << 16) | ((((long) p()) & 255) << 24) | ((((long) p()) & 255) << 32) | ((((long) p()) & 255) << 40) | ((((long) p()) & 255) << 48) | ((((long) p()) & 255) << 56);
274 public int m() {
275 if (this.g == Integer.MAX_VALUE) {
276 return -1;
278 return this.g - this.e;
281 public boolean n() {
282 return this.e == this.c;
285 public int o() {
286 return this.e - this.b;
289 public byte p() {
290 if (this.e == this.c) {
291 throw dz.a();
293 byte[] bArr = this.a;
294 int i2 = this.e;
295 this.e = i2 + 1;
296 return bArr[i2];