java.net
Class Proxy

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.net.Proxy

public class Proxy
extends Object sample code for java.lang.Object definition code for java.lang.Object

This class represents a proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object.

Since:
1.5
See Also:
ProxySelector sample code for java.net.ProxySelector definition code for java.net.ProxySelector

Nested Class Summary
static class Proxy.Type sample code for java.net.Proxy.Type definition code for java.net.Proxy.Type
          Represents the proxy type.
 
Field Summary
static Proxy sample code for java.net.Proxy definition code for java.net.Proxy NO_PROXY sample code for java.net.Proxy.NO_PROXY definition code for java.net.Proxy.NO_PROXY
          A proxy setting that represents a DIRECT connection, basically telling the protocol handler not to use any proxying.
 
Constructor Summary
Proxy sample code for java.net.Proxy.Proxy(java.net.Proxy.Type, java.net.SocketAddress) definition code for java.net.Proxy.Proxy(java.net.Proxy.Type, java.net.SocketAddress) (Proxy.Type sample code for java.net.Proxy.Type definition code for java.net.Proxy.Type  type, SocketAddress sample code for java.net.SocketAddress definition code for java.net.SocketAddress  sa)
          Creates an entry representing a PROXY connection.
 
Method Summary
 SocketAddress sample code for java.net.SocketAddress definition code for java.net.SocketAddress address sample code for java.net.Proxy.address() definition code for java.net.Proxy.address() ()
          Returns the socket address of the proxy, or null if its a direct connection.
 boolean equals sample code for java.net.Proxy.equals(java.lang.Object) definition code for java.net.Proxy.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares this object against the specified object.
 int hashCode sample code for java.net.Proxy.hashCode() definition code for java.net.Proxy.hashCode() ()
          Returns a hashcode for this Proxy.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.net.Proxy.toString() definition code for java.net.Proxy.toString() ()
          Constructs a string representation of this Proxy.
 Proxy.Type sample code for java.net.Proxy.Type definition code for java.net.Proxy.Type type sample code for java.net.Proxy.type() definition code for java.net.Proxy.type() ()
          Returns the proxy type.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

NO_PROXY sample code for java.net.Proxy.NO_PROXY

public static final Proxy sample code for java.net.Proxy definition code for java.net.Proxy  NO_PROXY
A proxy setting that represents a DIRECT connection, basically telling the protocol handler not to use any proxying. Used, for instance, to create sockets bypassing any other global proxy settings (like SOCKS):

Socket s = new Socket(Proxy.NO_PROXY);

Constructor Detail

Proxy sample code for java.net.Proxy(java.net.Proxy.Type, java.net.SocketAddress) definition code for java.net.Proxy(java.net.Proxy.Type, java.net.SocketAddress)

public Proxy(Proxy.Type sample code for java.net.Proxy.Type definition code for java.net.Proxy.Type  type,
             SocketAddress sample code for java.net.SocketAddress definition code for java.net.SocketAddress  sa)
Creates an entry representing a PROXY connection. Certain combinations are illegal. For instance, for types Http, and Socks, a SocketAddress must be provided.

Use the Proxy.NO_PROXY constant for representing a direct connection.

Parameters:
type - the Type of the proxy
sa - the SocketAddress for that proxy
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - when the type and the address are incompatible
Method Detail

type sample code for java.net.Proxy.type() definition code for java.net.Proxy.type()

public Proxy.Type sample code for java.net.Proxy.Type definition code for java.net.Proxy.Type  type()
Returns the proxy type.

Returns:
a Type representing the proxy type

address sample code for java.net.Proxy.address() definition code for java.net.Proxy.address()

public SocketAddress sample code for java.net.SocketAddress definition code for java.net.SocketAddress  address()
Returns the socket address of the proxy, or null if its a direct connection.

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

toString sample code for java.net.Proxy.toString() definition code for java.net.Proxy.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Constructs a string representation of this Proxy. This String is constructed by calling toString() on its type and concatenating the toString() result from its address if any.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this object.

equals sample code for java.net.Proxy.equals(java.lang.Object) definition code for java.net.Proxy.equals(java.lang.Object)

public final boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares this object against the specified object. The result is true if and only if the argument is not null and it represents the same proxy as this object.

Two instances of Proxy represent the same address if both the SocketAddresses and type are equal.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the object to compare against.
Returns:
true if the objects are the same; false otherwise.
See Also:
InetSocketAddress.equals(java.lang.Object) sample code for java.net.InetSocketAddress.equals(java.lang.Object) definition code for java.net.InetSocketAddress.equals(java.lang.Object)

hashCode sample code for java.net.Proxy.hashCode() definition code for java.net.Proxy.hashCode()

public final int hashCode()
Returns a hashcode for this Proxy.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a hash code value for this Proxy.
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable