Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Proxy

public class Proxy
extends Object

java.lang.Object
   ↳ java.net.Proxy


This class represents proxy server settings. A created instance of Proxy stores a type and an address and is immutable. There are three types of proxies:

Summary

Nested classes

enum Proxy.Type

Enum class for the proxy type. 

Fields

public static final Proxy NO_PROXY

Represents the proxy type setting Proxy.Type.DIRECT.

Public constructors

Proxy(Proxy.Type type, SocketAddress sa)

Creates a new Proxy instance.

Public methods

SocketAddress address()

Gets the address of this Proxy instance.

final boolean equals(Object obj)

Compares the specified obj to this Proxy instance and returns whether they are equal or not.

final 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.

Inherited methods

From class java.lang.Object

Fields

NO_PROXY

Added in API level 1
Proxy NO_PROXY

Represents the proxy type setting Proxy.Type.DIRECT. It tells protocol handlers that there is no proxy to be used. The address is set to null.

Public constructors

Proxy

Added in API level 1
Proxy (Proxy.Type type, 
                SocketAddress sa)

Creates a new 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.

Parameters
type Proxy.Type: the proxy type of this instance.
sa SocketAddress: the proxy address of this instance.
Throws
IllegalArgumentException if the parameter type is set to Proxy.Type.DIRECT or the value for SocketAddress is null.

Public methods

address

Added in API level 1
SocketAddress address ()

Gets the address of this Proxy instance.

Returns
SocketAddress the stored proxy address or null if the proxy type is DIRECT.

equals

Added in API level 1
boolean equals (Object obj)

Compares the specified 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.

Parameters
obj Object: the object to compare with this instance.
Returns
boolean true if the given object represents the same Proxy as this instance, false otherwise.

See also:

hashCode

Added in API level 1
int hashCode ()

Gets the hashcode for this Proxy instance.

Returns
int the hashcode value for this Proxy instance.

toString

Added in API level 1
String toString ()

Gets a textual representation of this Proxy instance. The string includes the two parts type.toString() and address.toString() if address is not null.

Returns
String the representing string of this proxy.

type

Added in API level 1
Proxy.Type type ()

Gets the type of this Proxy instance.

Returns
Proxy.Type the stored proxy type.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.