HashCode.java
8.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
package com.google.common.hash;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Ints;
import com.google.common.primitives.UnsignedInts;
import java.io.Serializable;
import java.security.MessageDigest;
import javax.annotation.Nullable;
@Beta
public abstract class HashCode
{
private static final char[] a = "0123456789abcdef".toCharArray();
private static int a(char paramChar)
{
if ((paramChar >= '0') && (paramChar <= '9')) {
return paramChar - '0';
}
if ((paramChar >= 'a') && (paramChar <= 'f')) {
return paramChar - 'a' + 10;
}
throw new IllegalArgumentException(32 + "Illegal hexadecimal character: " + paramChar);
}
public static HashCode a(byte[] paramArrayOfByte)
{
return new a(paramArrayOfByte);
}
public static HashCode fromBytes(byte[] paramArrayOfByte)
{
if (paramArrayOfByte.length > 0) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "A HashCode must contain at least 1 byte.");
return a((byte[])paramArrayOfByte.clone());
}
}
public static HashCode fromInt(int paramInt)
{
return new b(paramInt);
}
public static HashCode fromLong(long paramLong)
{
return new c(paramLong);
}
public static HashCode fromString(String paramString)
{
int i = 0;
if (paramString.length() >= 2)
{
bool = true;
Preconditions.checkArgument(bool, "input string (%s) must have at least 2 characters", new Object[] { paramString });
if (paramString.length() % 2 != 0) {
break label118;
}
}
byte[] arrayOfByte;
label118:
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "input string (%s) must have an even number of characters", new Object[] { paramString });
arrayOfByte = new byte[paramString.length() / 2];
while (i < paramString.length())
{
int j = a(paramString.charAt(i));
int k = a(paramString.charAt(i + 1));
arrayOfByte[(i / 2)] = ((byte)((j << 4) + k));
i += 2;
}
bool = false;
break;
}
return a(arrayOfByte);
}
abstract void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2);
abstract boolean a(HashCode paramHashCode);
public byte[] a()
{
return asBytes();
}
public abstract byte[] asBytes();
public abstract int asInt();
public abstract long asLong();
public abstract int bits();
public final boolean equals(@Nullable Object paramObject)
{
boolean bool2 = false;
boolean bool1 = bool2;
if ((paramObject instanceof HashCode))
{
paramObject = (HashCode)paramObject;
bool1 = bool2;
if (bits() == ((HashCode)paramObject).bits())
{
bool1 = bool2;
if (a((HashCode)paramObject)) {
bool1 = true;
}
}
}
return bool1;
}
public final int hashCode()
{
int k;
if (bits() >= 32)
{
k = asInt();
return k;
}
byte[] arrayOfByte = asBytes();
int i = arrayOfByte[0] & 0xFF;
int j = 1;
for (;;)
{
k = i;
if (j >= arrayOfByte.length) {
break;
}
i |= (arrayOfByte[j] & 0xFF) << j * 8;
j += 1;
}
}
public abstract long padToLong();
public final String toString()
{
byte[] arrayOfByte = asBytes();
StringBuilder localStringBuilder = new StringBuilder(arrayOfByte.length * 2);
int j = arrayOfByte.length;
int i = 0;
while (i < j)
{
int k = arrayOfByte[i];
localStringBuilder.append(a[(k >> 4 & 0xF)]).append(a[(k & 0xF)]);
i += 1;
}
return localStringBuilder.toString();
}
public int writeBytesTo(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
paramInt2 = Ints.min(new int[] { paramInt2, bits() / 8 });
Preconditions.checkPositionIndexes(paramInt1, paramInt1 + paramInt2, paramArrayOfByte.length);
a(paramArrayOfByte, paramInt1, paramInt2);
return paramInt2;
}
static final class a
extends HashCode
implements Serializable
{
private static final long serialVersionUID = 0L;
final byte[] a;
a(byte[] paramArrayOfByte)
{
this.a = ((byte[])Preconditions.checkNotNull(paramArrayOfByte));
}
final void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
System.arraycopy(this.a, 0, paramArrayOfByte, paramInt1, paramInt2);
}
final boolean a(HashCode paramHashCode)
{
return MessageDigest.isEqual(this.a, paramHashCode.a());
}
final byte[] a()
{
return this.a;
}
public final byte[] asBytes()
{
return (byte[])this.a.clone();
}
public final int asInt()
{
if (this.a.length >= 4) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkState(bool, "HashCode#asInt() requires >= 4 bytes (it only has %s bytes).", new Object[] { Integer.valueOf(this.a.length) });
return this.a[0] & 0xFF | (this.a[1] & 0xFF) << 8 | (this.a[2] & 0xFF) << 16 | (this.a[3] & 0xFF) << 24;
}
}
public final long asLong()
{
if (this.a.length >= 8) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkState(bool, "HashCode#asLong() requires >= 8 bytes (it only has %s bytes).", new Object[] { Integer.valueOf(this.a.length) });
return padToLong();
}
}
public final int bits()
{
return this.a.length * 8;
}
public final long padToLong()
{
long l = this.a[0] & 0xFF;
int i = 1;
while (i < Math.min(this.a.length, 8))
{
l |= (this.a[i] & 0xFF) << i * 8;
i += 1;
}
return l;
}
}
static final class b
extends HashCode
implements Serializable
{
private static final long serialVersionUID = 0L;
final int a;
b(int paramInt)
{
this.a = paramInt;
}
final void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
int i = 0;
while (i < paramInt2)
{
paramArrayOfByte[(paramInt1 + i)] = ((byte)(this.a >> i * 8));
i += 1;
}
}
final boolean a(HashCode paramHashCode)
{
return this.a == paramHashCode.asInt();
}
public final byte[] asBytes()
{
return new byte[] { (byte)this.a, (byte)(this.a >> 8), (byte)(this.a >> 16), (byte)(this.a >> 24) };
}
public final int asInt()
{
return this.a;
}
public final long asLong()
{
throw new IllegalStateException("this HashCode only has 32 bits; cannot create a long");
}
public final int bits()
{
return 32;
}
public final long padToLong()
{
return UnsignedInts.toLong(this.a);
}
}
static final class c
extends HashCode
implements Serializable
{
private static final long serialVersionUID = 0L;
final long a;
c(long paramLong)
{
this.a = paramLong;
}
final void a(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
int i = 0;
while (i < paramInt2)
{
paramArrayOfByte[(paramInt1 + i)] = ((byte)(int)(this.a >> i * 8));
i += 1;
}
}
final boolean a(HashCode paramHashCode)
{
return this.a == paramHashCode.asLong();
}
public final byte[] asBytes()
{
return new byte[] { (byte)(int)this.a, (byte)(int)(this.a >> 8), (byte)(int)(this.a >> 16), (byte)(int)(this.a >> 24), (byte)(int)(this.a >> 32), (byte)(int)(this.a >> 40), (byte)(int)(this.a >> 48), (byte)(int)(this.a >> 56) };
}
public final int asInt()
{
return (int)this.a;
}
public final long asLong()
{
return this.a;
}
public final int bits()
{
return 64;
}
public final long padToLong()
{
return this.a;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/hash/HashCode.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/