Okio.java
7.3 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
package okio;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import tv;
import tw;
import tx;
import ty;
import ua;
public final class Okio
{
private static final Logger a = Logger.getLogger(Okio.class.getName());
private static AsyncTimeout a(Socket paramSocket)
{
new AsyncTimeout()
{
protected final IOException newTimeoutException(IOException paramAnonymousIOException)
{
SocketTimeoutException localSocketTimeoutException = new SocketTimeoutException("timeout");
if (paramAnonymousIOException != null) {
localSocketTimeoutException.initCause(paramAnonymousIOException);
}
return localSocketTimeoutException;
}
protected final void timedOut()
{
try
{
this.a.close();
return;
}
catch (Exception localException)
{
Okio.a().log(Level.WARNING, "Failed to close timed out socket " + this.a, localException);
return;
}
catch (AssertionError localAssertionError)
{
if ((localAssertionError.getCause() != null) && (localAssertionError.getMessage() != null) && (localAssertionError.getMessage().contains("getsockname failed")))
{
Okio.a().log(Level.WARNING, "Failed to close timed out socket " + this.a, localAssertionError);
return;
}
throw localAssertionError;
}
}
};
}
private static Sink a(final OutputStream paramOutputStream, Timeout paramTimeout)
{
if (paramOutputStream == null) {
throw new IllegalArgumentException("out == null");
}
if (paramTimeout == null) {
throw new IllegalArgumentException("timeout == null");
}
new Sink()
{
public final void close()
throws IOException
{
paramOutputStream.close();
}
public final void flush()
throws IOException
{
paramOutputStream.flush();
}
public final Timeout timeout()
{
return this.a;
}
public final String toString()
{
return "sink(" + paramOutputStream + ")";
}
public final void write(Buffer paramAnonymousBuffer, long paramAnonymousLong)
throws IOException
{
ua.a(paramAnonymousBuffer.b, 0L, paramAnonymousLong);
while (paramAnonymousLong > 0L)
{
this.a.throwIfReached();
tx localtx = paramAnonymousBuffer.a;
int i = (int)Math.min(paramAnonymousLong, localtx.c - localtx.b);
paramOutputStream.write(localtx.a, localtx.b, i);
localtx.b += i;
long l = paramAnonymousLong - i;
paramAnonymousBuffer.b -= i;
paramAnonymousLong = l;
if (localtx.b == localtx.c)
{
paramAnonymousBuffer.a = localtx.a();
ty.a(localtx);
paramAnonymousLong = l;
}
}
}
};
}
private static Source a(final InputStream paramInputStream, Timeout paramTimeout)
{
if (paramInputStream == null) {
throw new IllegalArgumentException("in == null");
}
if (paramTimeout == null) {
throw new IllegalArgumentException("timeout == null");
}
new Source()
{
public final void close()
throws IOException
{
paramInputStream.close();
}
public final long read(Buffer paramAnonymousBuffer, long paramAnonymousLong)
throws IOException
{
if (paramAnonymousLong < 0L) {
throw new IllegalArgumentException("byteCount < 0: " + paramAnonymousLong);
}
if (paramAnonymousLong == 0L) {
return 0L;
}
this.a.throwIfReached();
tx localtx = paramAnonymousBuffer.a(1);
int i = (int)Math.min(paramAnonymousLong, 2048 - localtx.c);
i = paramInputStream.read(localtx.a, localtx.c, i);
if (i == -1) {
return -1L;
}
localtx.c += i;
paramAnonymousBuffer.b += i;
return i;
}
public final Timeout timeout()
{
return this.a;
}
public final String toString()
{
return "source(" + paramInputStream + ")";
}
};
}
public static Sink appendingSink(File paramFile)
throws FileNotFoundException
{
if (paramFile == null) {
throw new IllegalArgumentException("file == null");
}
return sink(new FileOutputStream(paramFile, true));
}
public static BufferedSink buffer(Sink paramSink)
{
if (paramSink == null) {
throw new IllegalArgumentException("sink == null");
}
return new tv(paramSink);
}
public static BufferedSource buffer(Source paramSource)
{
if (paramSource == null) {
throw new IllegalArgumentException("source == null");
}
return new tw(paramSource);
}
public static Sink sink(File paramFile)
throws FileNotFoundException
{
if (paramFile == null) {
throw new IllegalArgumentException("file == null");
}
return sink(new FileOutputStream(paramFile));
}
public static Sink sink(OutputStream paramOutputStream)
{
return a(paramOutputStream, new Timeout());
}
public static Sink sink(Socket paramSocket)
throws IOException
{
if (paramSocket == null) {
throw new IllegalArgumentException("socket == null");
}
AsyncTimeout localAsyncTimeout = a(paramSocket);
return localAsyncTimeout.sink(a(paramSocket.getOutputStream(), localAsyncTimeout));
}
@IgnoreJRERequirement
public static Sink sink(Path paramPath, OpenOption... paramVarArgs)
throws IOException
{
if (paramPath == null) {
throw new IllegalArgumentException("path == null");
}
return sink(Files.newOutputStream(paramPath, paramVarArgs));
}
public static Source source(File paramFile)
throws FileNotFoundException
{
if (paramFile == null) {
throw new IllegalArgumentException("file == null");
}
return source(new FileInputStream(paramFile));
}
public static Source source(InputStream paramInputStream)
{
return a(paramInputStream, new Timeout());
}
public static Source source(Socket paramSocket)
throws IOException
{
if (paramSocket == null) {
throw new IllegalArgumentException("socket == null");
}
AsyncTimeout localAsyncTimeout = a(paramSocket);
return localAsyncTimeout.source(a(paramSocket.getInputStream(), localAsyncTimeout));
}
@IgnoreJRERequirement
public static Source source(Path paramPath, OpenOption... paramVarArgs)
throws IOException
{
if (paramPath == null) {
throw new IllegalArgumentException("path == null");
}
return source(Files.newInputStream(paramPath, paramVarArgs));
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/okio/Okio.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/