ByteString.java
6.43 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
package com.crashlytics.android.core;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
final class ByteString
{
public static final ByteString EMPTY = new ByteString(new byte[0]);
private final byte[] bytes;
private volatile int hash = 0;
private ByteString(byte[] paramArrayOfByte)
{
this.bytes = paramArrayOfByte;
}
public static ByteString copyFrom(String paramString1, String paramString2)
throws UnsupportedEncodingException
{
return new ByteString(paramString1.getBytes(paramString2));
}
public static ByteString copyFrom(ByteBuffer paramByteBuffer)
{
return copyFrom(paramByteBuffer, paramByteBuffer.remaining());
}
public static ByteString copyFrom(ByteBuffer paramByteBuffer, int paramInt)
{
byte[] arrayOfByte = new byte[paramInt];
paramByteBuffer.get(arrayOfByte);
return new ByteString(arrayOfByte);
}
public static ByteString copyFrom(List<ByteString> paramList)
{
if (paramList.size() == 0) {
return EMPTY;
}
if (paramList.size() == 1) {
return (ByteString)paramList.get(0);
}
Object localObject = paramList.iterator();
for (int i = 0; ((Iterator)localObject).hasNext(); i = ((ByteString)((Iterator)localObject).next()).size() + i) {}
localObject = new byte[i];
paramList = paramList.iterator();
ByteString localByteString;
for (i = 0; paramList.hasNext(); i = localByteString.size() + i)
{
localByteString = (ByteString)paramList.next();
System.arraycopy(localByteString.bytes, 0, localObject, i, localByteString.size());
}
return new ByteString((byte[])localObject);
}
public static ByteString copyFrom(byte[] paramArrayOfByte)
{
return copyFrom(paramArrayOfByte, 0, paramArrayOfByte.length);
}
public static ByteString copyFrom(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
byte[] arrayOfByte = new byte[paramInt2];
System.arraycopy(paramArrayOfByte, paramInt1, arrayOfByte, 0, paramInt2);
return new ByteString(arrayOfByte);
}
public static ByteString copyFromUtf8(String paramString)
{
try
{
paramString = new ByteString(paramString.getBytes("UTF-8"));
return paramString;
}
catch (UnsupportedEncodingException paramString)
{
throw new RuntimeException("UTF-8 not supported.", paramString);
}
}
static CodedBuilder newCodedBuilder(int paramInt)
{
return new CodedBuilder(paramInt, null);
}
public static Output newOutput()
{
return newOutput(32);
}
public static Output newOutput(int paramInt)
{
return new Output(new ByteArrayOutputStream(paramInt), null);
}
public final ByteBuffer asReadOnlyByteBuffer()
{
return ByteBuffer.wrap(this.bytes).asReadOnlyBuffer();
}
public final byte byteAt(int paramInt)
{
return this.bytes[paramInt];
}
public final void copyTo(ByteBuffer paramByteBuffer)
{
paramByteBuffer.put(this.bytes, 0, this.bytes.length);
}
public final void copyTo(byte[] paramArrayOfByte, int paramInt)
{
System.arraycopy(this.bytes, 0, paramArrayOfByte, paramInt, this.bytes.length);
}
public final void copyTo(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3)
{
System.arraycopy(this.bytes, paramInt1, paramArrayOfByte, paramInt2, paramInt3);
}
public final boolean equals(Object paramObject)
{
if (paramObject == this) {}
for (;;)
{
return true;
if (!(paramObject instanceof ByteString)) {
return false;
}
Object localObject = (ByteString)paramObject;
int j = this.bytes.length;
if (j != ((ByteString)localObject).bytes.length) {
return false;
}
paramObject = this.bytes;
localObject = ((ByteString)localObject).bytes;
int i = 0;
while (i < j)
{
if (paramObject[i] != localObject[i]) {
return false;
}
i += 1;
}
}
}
public final int hashCode()
{
int i = this.hash;
int j = i;
if (i == 0)
{
byte[] arrayOfByte = this.bytes;
int k = this.bytes.length;
j = 0;
int m;
for (i = k; j < k; i = m + i * 31)
{
m = arrayOfByte[j];
j += 1;
}
j = i;
if (i == 0) {
j = 1;
}
this.hash = j;
}
return j;
}
public final boolean isEmpty()
{
return this.bytes.length == 0;
}
public final InputStream newInput()
{
return new ByteArrayInputStream(this.bytes);
}
public final int size()
{
return this.bytes.length;
}
public final byte[] toByteArray()
{
int i = this.bytes.length;
byte[] arrayOfByte = new byte[i];
System.arraycopy(this.bytes, 0, arrayOfByte, 0, i);
return arrayOfByte;
}
public final String toString(String paramString)
throws UnsupportedEncodingException
{
return new String(this.bytes, paramString);
}
public final String toStringUtf8()
{
try
{
String str = new String(this.bytes, "UTF-8");
return str;
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
throw new RuntimeException("UTF-8 not supported?", localUnsupportedEncodingException);
}
}
static final class CodedBuilder
{
private final byte[] buffer;
private final CodedOutputStream output;
private CodedBuilder(int paramInt)
{
this.buffer = new byte[paramInt];
this.output = CodedOutputStream.newInstance(this.buffer);
}
public final ByteString build()
{
this.output.checkNoSpaceLeft();
return new ByteString(this.buffer, null);
}
public final CodedOutputStream getCodedOutput()
{
return this.output;
}
}
static final class Output
extends FilterOutputStream
{
private final ByteArrayOutputStream bout;
private Output(ByteArrayOutputStream paramByteArrayOutputStream)
{
super();
this.bout = paramByteArrayOutputStream;
}
public final ByteString toByteString()
{
return new ByteString(this.bout.toByteArray(), null);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/crashlytics/android/core/ByteString.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/