public class Proxy
extends Object
| java.lang.Object | |
| java.net.Proxy | |
这个类表示一个代理设置,通常是一个类型(http,socks)和一个套接字地址。 一个Proxy是一个不可变的对象。
也可以看看:
Nested classes |
|
|---|---|
枚举 |
Proxy.Type 代表代理类型。 |
Fields |
|
|---|---|
public static final Proxy |
NO_PROXY 代理设置代表 |
Public constructors |
|
|---|---|
Proxy(Proxy.Type type, SocketAddress sa) 创建一个代表PROXY连接的条目。 |
|
公共方法(Public methods) |
|
|---|---|
SocketAddress |
address() 返回代理的套接字地址,如果是直接连接,则返回 |
final boolean |
equals(Object obj) 将此对象与指定的对象进行比较。 |
final int |
hashCode() 返回此代理的哈希码。 |
String |
toString() 构造此代理的字符串表示形式。 |
Proxy.Type |
type() 返回代理类型。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
Proxy NO_PROXY
表示DIRECT连接的代理设置,基本上告诉协议处理程序不要使用任何代理。 例如,用于创建绕过任何其他全局代理设置(如SOCKS)的套接字:
Socket s = new Socket(Proxy.NO_PROXY);
Proxy (Proxy.Type type, SocketAddress sa)
创建一个代表PROXY连接的条目。 某些组合是非法的。 例如,对于类型Http和Socks, 必须提供一个SocketAddress。
使用 Proxy.NO_PROXY常量表示直接连接。
| 参数(Parameters) | |
|---|---|
type |
Proxy.Type: the Type of the proxy |
sa |
SocketAddress: the SocketAddress for that proxy |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
when the type and the address are incompatible |
SocketAddress address ()
返回代理的套接字地址,如果是直接连接,则返回 null 。
| 返回(Returns) | |
|---|---|
SocketAddress |
a SocketAddress representing the socket end point of the proxy |
boolean equals (Object obj)
将此对象与指定的对象进行比较。 当且仅当参数不是null且它表示与此对象相同的代理时,结果为true 。
如果SocketAddresses和type都相等,则 Proxy两个实例表示相同的地址。
| 参数(Parameters) | |
|---|---|
obj |
Object: the object to compare against. |
| 返回(Returns) | |
|---|---|
boolean |
true if the objects are the same; false otherwise. |
也可以看看:
int hashCode ()
返回此代理的哈希码。
| 返回(Returns) | |
|---|---|
int |
a hash code value for this Proxy. |
String toString ()
构造此代理的字符串表示形式。 这个字符串是通过在其类型上调用toString()并且如果它的类型不是DIRECT来连接它的地址的“@”和toString()结果来DIRECT 。
| 返回(Returns) | |
|---|---|
String |
a string representation of this object. |
Proxy.Type type ()
返回代理类型。
| 返回(Returns) | |
|---|---|
Proxy.Type |
a Type representing the proxy type |