HostAndPort.java
7.02 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
package com.google.common.net;
import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.io.Serializable;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@Beta
@GwtCompatible
@Immutable
public final class HostAndPort
implements Serializable
{
private static final long serialVersionUID = 0L;
private final String a;
private final int b;
private final boolean c;
private HostAndPort(String paramString, int paramInt, boolean paramBoolean)
{
this.a = paramString;
this.b = paramInt;
this.c = paramBoolean;
}
private static boolean a(int paramInt)
{
return (paramInt >= 0) && (paramInt <= 65535);
}
public static HostAndPort fromHost(String paramString)
{
HostAndPort localHostAndPort = fromString(paramString);
if (!localHostAndPort.hasPort()) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "Host has a port: %s", new Object[] { paramString });
return localHostAndPort;
}
}
public static HostAndPort fromParts(String paramString, int paramInt)
{
Preconditions.checkArgument(a(paramInt), "Port out of range: %s", new Object[] { Integer.valueOf(paramInt) });
HostAndPort localHostAndPort = fromString(paramString);
if (!localHostAndPort.hasPort()) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "Host has a port: %s", new Object[] { paramString });
return new HostAndPort(localHostAndPort.a, paramInt, localHostAndPort.c);
}
}
public static HostAndPort fromString(String paramString)
{
Preconditions.checkNotNull(paramString);
Object localObject = null;
boolean bool1;
int i;
int j;
label68:
String str;
label118:
label132:
boolean bool2;
if (paramString.startsWith("[")) {
if (paramString.charAt(0) == '[')
{
bool1 = true;
Preconditions.checkArgument(bool1, "Bracketed host-port string must start with a bracket: %s", new Object[] { paramString });
i = paramString.indexOf(':');
j = paramString.lastIndexOf(']');
if ((i < 0) || (j <= i)) {
break label208;
}
bool1 = true;
Preconditions.checkArgument(bool1, "Invalid bracketed host/port: %s", new Object[] { paramString });
str = paramString.substring(1, j);
if (j + 1 != paramString.length()) {
break label213;
}
localObject = new String[2];
localObject[0] = str;
localObject[1] = "";
str = localObject[0];
localObject = localObject[1];
bool1 = false;
if (Strings.isNullOrEmpty((String)localObject)) {
break label424;
}
if (((String)localObject).startsWith("+")) {
break label375;
}
bool2 = true;
label153:
Preconditions.checkArgument(bool2, "Unparseable port number: %s", new Object[] { paramString });
}
}
for (;;)
{
try
{
i = Integer.parseInt((String)localObject);
Preconditions.checkArgument(a(i), "Port number out of range: %s", new Object[] { paramString });
return new HostAndPort(str, i, bool1);
}
catch (NumberFormatException localNumberFormatException)
{
label208:
label213:
label375:
paramString = String.valueOf(paramString);
if (paramString.length() == 0) {
break label411;
}
}
bool1 = false;
break;
bool1 = false;
break label68;
if (paramString.charAt(j + 1) == ':')
{
bool1 = true;
Preconditions.checkArgument(bool1, "Only a colon may follow a close bracket: %s", new Object[] { paramString });
i = j + 2;
if (i < paramString.length())
{
Preconditions.checkArgument(Character.isDigit(paramString.charAt(i)), "Port must be numeric: %s", new Object[] { paramString });
i += 1;
continue;
}
}
else
{
bool1 = false;
continue;
}
localObject = new String[2];
localObject[0] = str;
localObject[1] = paramString.substring(j + 2);
break label118;
i = paramString.indexOf(':');
if ((i >= 0) && (paramString.indexOf(':', i + 1) == -1))
{
str = paramString.substring(0, i);
localObject = paramString.substring(i + 1);
bool1 = false;
break label132;
}
if (i >= 0)
{
bool1 = true;
str = paramString;
break label132;
}
bool1 = false;
continue;
bool2 = false;
break label153;
label411:
for (paramString = "Unparseable port number: ".concat(paramString);; paramString = new String("Unparseable port number: ")) {
throw new IllegalArgumentException(paramString);
}
label424:
i = -1;
}
}
public final boolean equals(@Nullable Object paramObject)
{
if (this == paramObject) {}
do
{
return true;
if (!(paramObject instanceof HostAndPort)) {
break;
}
paramObject = (HostAndPort)paramObject;
} while ((Objects.equal(this.a, ((HostAndPort)paramObject).a)) && (this.b == ((HostAndPort)paramObject).b) && (this.c == ((HostAndPort)paramObject).c));
return false;
return false;
}
public final String getHostText()
{
return this.a;
}
public final int getPort()
{
Preconditions.checkState(hasPort());
return this.b;
}
public final int getPortOrDefault(int paramInt)
{
if (hasPort()) {
paramInt = this.b;
}
return paramInt;
}
public final boolean hasPort()
{
return this.b >= 0;
}
public final int hashCode()
{
return Objects.hashCode(new Object[] { this.a, Integer.valueOf(this.b), Boolean.valueOf(this.c) });
}
public final HostAndPort requireBracketsForIPv6()
{
if (!this.c) {}
for (boolean bool = true;; bool = false)
{
Preconditions.checkArgument(bool, "Possible bracketless IPv6 literal: %s", new Object[] { this.a });
return this;
}
}
public final String toString()
{
StringBuilder localStringBuilder = new StringBuilder(this.a.length() + 8);
if (this.a.indexOf(':') >= 0) {
localStringBuilder.append('[').append(this.a).append(']');
}
for (;;)
{
if (hasPort()) {
localStringBuilder.append(':').append(this.b);
}
return localStringBuilder.toString();
localStringBuilder.append(this.a);
}
}
public final HostAndPort withDefaultPort(int paramInt)
{
Preconditions.checkArgument(a(paramInt));
if ((hasPort()) || (this.b == paramInt)) {
return this;
}
return new HostAndPort(this.a, paramInt, this.c);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/net/HostAndPort.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/