public class Proxy extends Object
Proxy stores a type and an address and is immutable. There are three types
of proxies:
| Modifier and Type | Class and Description |
|---|---|
static class |
Proxy.Type
Enum class for the proxy type. |
| Modifier and Type | Field and Description |
|---|---|
static Proxy |
NO_PROXY
Represents the proxy type setting
Proxy.Type.DIRECT. |
| Constructor and Description |
|---|
Proxy(Proxy.Type type,
SocketAddress sa)
Creates a new
Proxy instance. |
| Modifier and Type | Method and Description |
|---|---|
SocketAddress |
address()
Gets the address of this
Proxy instance. |
boolean |
equals(Object obj)
Compares the specified
obj to this Proxy instance and
returns whether they are equal or not. |
int |
hashCode()
Gets the hashcode for this
Proxy instance. |
String |
toString()
Gets a textual representation of this
Proxy instance. |
Proxy.Type |
type()
Gets the type of this
Proxy instance. |
public static final Proxy NO_PROXY
Proxy.Type.DIRECT. It tells
protocol handlers that there is no proxy to be used. The address is set
to null.public Proxy(Proxy.Type type, SocketAddress sa)
Proxy instance. SocketAddress must NOT be
null when type is either Proxy.Type.HTTP or
Proxy.Type.SOCKS. To create a Proxy instance representing
the proxy type Proxy.Type.DIRECT, use Proxy.NO_PROXY
instead of this constructor.type - the proxy type of this instance.sa - the proxy address of this instance.IllegalArgumentException - if the parameter type is set to Proxy.Type.DIRECT or the value for SocketAddress is
null.public Proxy.Type type()
Proxy instance.public SocketAddress address()
Proxy instance.null if the proxy type is
DIRECT.public String toString()
Proxy instance. The string
includes the two parts type.toString() and address.toString() if address is not null.public final boolean equals(Object obj)
obj to this Proxy instance and
returns whether they are equal or not. The given object must be an
instance of Proxy with the same address and the same type value
to be equal.equals in class Objectobj - the object to compare with this instance.true if the given object represents the same Proxy as this instance, false otherwise.hashCode()public final int hashCode()
Proxy instance.hashCode in class ObjectObject.equals(java.lang.Object)