Part.java
8.25 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
package com.squareup.mimecraft;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.LinkedHashMap;
import java.util.Map;
import sd;
public abstract interface Part
{
public abstract Map<String, String> getHeaders();
public abstract void writeBodyTo(OutputStream paramOutputStream)
throws IOException;
public static class Builder
{
int a;
private String b;
private String c;
private String d;
private String e;
private File f;
private InputStream g;
private byte[] h;
private Multipart i;
private boolean j = false;
private void a()
{
if (this.j) {
throw new IllegalStateException("Only one body per part.");
}
this.j = true;
}
public Builder body(Multipart paramMultipart)
{
sd.a(paramMultipart, "Multipart body must not be null.");
if (this.b != null) {
throw new IllegalStateException("Content type must not be explicitly set for multipart body.");
}
a();
this.b = null;
this.i = paramMultipart;
return this;
}
public Builder body(File paramFile)
{
sd.a(paramFile, "File body must not be null.");
a();
this.f = paramFile;
return this;
}
public Builder body(InputStream paramInputStream)
{
sd.a(paramInputStream, "Stream body must not be null.");
a();
this.g = paramInputStream;
return this;
}
public Builder body(String paramString)
{
sd.a(paramString, "String body must not be null.");
a();
try
{
byte[] arrayOfByte = paramString.getBytes("UTF-8");
this.h = arrayOfByte;
this.a = arrayOfByte.length;
return this;
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
throw new IllegalArgumentException("Unable to convert input to UTF-8: " + paramString, localUnsupportedEncodingException);
}
}
public Builder body(byte[] paramArrayOfByte)
{
sd.a(paramArrayOfByte, "Byte array body must not be null.");
a();
this.h = paramArrayOfByte;
this.a = paramArrayOfByte.length;
return this;
}
public Part build()
{
LinkedHashMap localLinkedHashMap = new LinkedHashMap();
if (this.e != null) {
localLinkedHashMap.put("Content-Disposition", this.e);
}
if (this.b != null) {
localLinkedHashMap.put("Content-Type", this.b);
}
if (this.a != 0) {
localLinkedHashMap.put("Content-Length", Integer.toString(this.a));
}
if (this.c != null) {
localLinkedHashMap.put("Content-Language", this.c);
}
if (this.d != null) {
localLinkedHashMap.put("Content-Transfer-Encoding", this.d);
}
if (this.h != null) {
return new a(localLinkedHashMap, this.h);
}
if (this.g != null) {
return new e(localLinkedHashMap, this.g, (byte)0);
}
if (this.f != null) {
return new b(localLinkedHashMap, this.f, (byte)0);
}
if (this.i != null)
{
localLinkedHashMap.putAll(this.i.getHeaders());
return new d(localLinkedHashMap, this.i);
}
throw new IllegalStateException("Part required body to be set.");
}
public Builder contentDisposition(String paramString)
{
sd.a(paramString, "Disposition must not be empty.");
sd.b(this.e, "Disposition header already set.");
this.e = paramString;
return this;
}
public Builder contentEncoding(String paramString)
{
sd.a(paramString, "Encoding must not be empty.");
sd.b(this.d, "Encoding header already set.");
this.d = paramString;
return this;
}
public Builder contentLanguage(String paramString)
{
sd.a(paramString, "Language must not be empty.");
sd.b(this.c, "Language header already set.");
this.c = paramString;
return this;
}
public Builder contentLength(int paramInt)
{
if (paramInt <= 0) {
throw new IllegalStateException("Length must be greater than zero.");
}
if (this.a != 0) {
throw new IllegalStateException("Length header already set.");
}
this.a = paramInt;
return this;
}
public Builder contentType(String paramString)
{
sd.a(paramString, "Type must not be empty.");
sd.b(this.b, "Type header already set.");
sd.b(this.i, "Type cannot be set with multipart body.");
this.b = paramString;
return this;
}
static final class a
extends Part.Builder.c
{
private final byte[] a;
a(Map<String, String> paramMap, byte[] paramArrayOfByte)
{
super();
this.a = paramArrayOfByte;
}
public final void writeBodyTo(OutputStream paramOutputStream)
throws IOException
{
paramOutputStream.write(this.a);
}
}
static final class b
extends Part.Builder.c
{
private final File a;
private final byte[] b = new byte['က'];
private b(Map<String, String> paramMap, File paramFile)
{
super();
this.a = paramFile;
}
/* Error */
public final void writeBodyTo(OutputStream paramOutputStream)
throws IOException
{
// Byte code:
// 0: new 34 java/io/FileInputStream
// 3: dup
// 4: aload_0
// 5: getfield 22 com/squareup/mimecraft/Part$Builder$b:a Ljava/io/File;
// 8: invokespecial 37 java/io/FileInputStream:<init> (Ljava/io/File;)V
// 11: astore_2
// 12: aload_2
// 13: aload_1
// 14: aload_0
// 15: getfield 20 com/squareup/mimecraft/Part$Builder$b:b [B
// 18: invokestatic 42 sd:a (Ljava/io/InputStream;Ljava/io/OutputStream;[B)V
// 21: aload_2
// 22: invokevirtual 48 java/io/InputStream:close ()V
// 25: return
// 26: astore_1
// 27: aconst_null
// 28: astore_2
// 29: aload_2
// 30: ifnull +7 -> 37
// 33: aload_2
// 34: invokevirtual 48 java/io/InputStream:close ()V
// 37: aload_1
// 38: athrow
// 39: astore_1
// 40: return
// 41: astore_2
// 42: goto -5 -> 37
// 45: astore_1
// 46: goto -17 -> 29
// Local variable table:
// start length slot name signature
// 0 49 0 this b
// 0 49 1 paramOutputStream OutputStream
// 11 23 2 localFileInputStream java.io.FileInputStream
// 41 1 2 localIOException IOException
// Exception table:
// from to target type
// 0 12 26 finally
// 21 25 39 java/io/IOException
// 33 37 41 java/io/IOException
// 12 21 45 finally
}
}
static abstract class c
implements Part
{
private final Map<String, String> a;
protected c(Map<String, String> paramMap)
{
this.a = paramMap;
}
public Map<String, String> getHeaders()
{
return this.a;
}
}
static final class d
extends Part.Builder.c
{
private final Part a;
protected d(Map<String, String> paramMap, Part paramPart)
{
super();
this.a = paramPart;
}
public final void writeBodyTo(OutputStream paramOutputStream)
throws IOException
{
this.a.writeBodyTo(paramOutputStream);
}
}
static final class e
extends Part.Builder.c
{
private final InputStream a;
private final byte[] b = new byte['က'];
private e(Map<String, String> paramMap, InputStream paramInputStream)
{
super();
this.a = paramInputStream;
}
public final void writeBodyTo(OutputStream paramOutputStream)
throws IOException
{
sd.a(this.a, paramOutputStream, this.b);
}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/mimecraft/Part.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/