Most visited

Recently visited

Added in API level 1

Proxy

public class Proxy
extends Object

java.lang.Object
   ↳ java.net.Proxy


这个类表示一个代理设置,通常是一个类型(http,socks)和一个套接字地址。 一个Proxy是一个不可变的对象。

也可以看看:

Summary

Nested classes

枚举 Proxy.Type

代表代理类型。

Fields

public static final Proxy NO_PROXY

代理设置代表 DIRECT连接,基本上告诉协议处理程序不要使用任何代理。

Public constructors

Proxy(Proxy.Type type, SocketAddress sa)

创建一个代表PROXY连接的条目。

Public methods

SocketAddress address()

返回代理的套接字地址,如果是直接连接,则返回 null 。

final boolean equals(Object obj)

将此对象与指定的对象进行比较。

final int hashCode()

返回此代理的哈希码。

String toString()

构造此代理的字符串表示形式。

Proxy.Type type()

返回代理类型。

Inherited methods

From class java.lang.Object

Fields

NO_PROXY

Added in API level 1
Proxy NO_PROXY

表示DIRECT连接的代理设置,基本上告诉协议处理程序不要使用任何代理。 例如,用于创建绕过任何其他全局代理设置(如SOCKS)的套接字:

Socket s = new Socket(Proxy.NO_PROXY);

Public constructors

Proxy

Added in API level 1
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

Public methods

address

Added in API level 1
SocketAddress address ()

返回代理的套接字地址,如果是直接连接,则返回 null 。

Returns
SocketAddress a SocketAddress representing the socket end point of the proxy

equals

Added in API level 1
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.

也可以看看:

hashCode

Added in API level 1
int hashCode ()

返回此代理的哈希码。

Returns
int a hash code value for this Proxy.

toString

Added in API level 1
String toString ()

构造此代理的字符串表示形式。 这个字符串是通过在其类型上调用toString()并且如果它的类型不是DIRECT来连接它的地址的“@”和toString()结果来DIRECT 。

Returns
String a string representation of this object.

type

Added in API level 1
Proxy.Type type ()

返回代理类型。

Returns
Proxy.Type a Type representing the proxy type

Hooray!