org.apache.commons.httpclient
Class HostConfiguration

java.lang.Object
  |
  +--org.apache.commons.httpclient.HostConfiguration

public class HostConfiguration
extends Object
implements Cloneable

Since:
2.0
Author:
Michael Becke, Mike Bowler, Oleg Kalnichevski, Laura Werner

Constructor Summary
HostConfiguration()
          Constructor for HostConfiguration.
HostConfiguration(HostConfiguration hostConfiguration)
          Copy constructor for HostConfiguration
 
Method Summary
 Object clone()
           
 boolean equals(Object o)
           
 String getHost()
          Returns the host.
 String getHostURL()
          Return the host url.
 InetAddress getLocalAddress()
          Return the local address to be used when creating connections.
 int getPort()
          Returns the port.
 Protocol getProtocol()
          Returns the protocol.
 String getProxyHost()
          Returns the proxyHost.
 int getProxyPort()
          Returns the proxyPort.
 String getVirtualHost()
          Returns the virtual host.
 int hashCode()
           
 boolean hostEquals(HttpConnection connection)
          Tests if the host configuration equals the configuraiton set on the connection.
 boolean isHostSet()
          Return true if the host is set.
 boolean isProxySet()
           
 boolean proxyEquals(HttpConnection connection)
          Tests if the proxy configuration equals the configuraiton set on the connection.
 void setHost(String host)
          Set the given host.
 void setHost(String host, int port)
          Set the given host and port.
 void setHost(String host, int port, Protocol protocol)
          Set the given host, port and protocol.
 void setHost(String host, int port, String protocol)
          Set the given host, port and protocol
 void setHost(String host, String virtualHost, int port, Protocol protocol)
          Set the given host, virtual host, port and protocol.
 void setHost(URI uri)
          Sets the protocol, host and port from the given URI.
 void setLocalAddress(InetAddress localAddress)
          Set the local address to be used when creating connections.
 void setProxy(String proxyHost, int proxyPort)
          Set the proxy settings.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HostConfiguration

public HostConfiguration()
Constructor for HostConfiguration.

HostConfiguration

public HostConfiguration(HostConfiguration hostConfiguration)
Copy constructor for HostConfiguration
Parameters:
hostConfiguration - the hostConfiguration to copy
Method Detail

clone

public Object clone()
Overrides:
clone in class Object
See Also:
Object.clone()

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

hostEquals

public boolean hostEquals(HttpConnection connection)
Tests if the host configuration equals the configuraiton set on the connection. True only if the host, port and protocol are equal. If no host configuration has been set false will be returned.
Parameters:
connection - the connection to test against
Returns:
true if the connection's host information equals that of this configuration
See Also:
proxyEquals(HttpConnection)

proxyEquals

public boolean proxyEquals(HttpConnection connection)
Tests if the proxy configuration equals the configuraiton set on the connection. True only if the proxyHost and proxyPort are equal.
Parameters:
connection - the connection to test against
Returns:
true if the connection's proxy information equals that of this configuration
See Also:
hostEquals(HttpConnection)

isHostSet

public boolean isHostSet()
Return true if the host is set.
Returns:
boolean True if the host is set.

setHost

public void setHost(String host,
                    int port,
                    String protocol)
Set the given host, port and protocol
Parameters:
host - the host, IP or DNS name
port - The port
protocol - The protocol.

setHost

public void setHost(String host,
                    String virtualHost,
                    int port,
                    Protocol protocol)
Set the given host, virtual host, port and protocol.
Parameters:
host - the host, IP or DNS name
virtualHost - the virtual host name
port - the host port or -1 to use protocol default
protocol - the protocol

setHost

public void setHost(String host,
                    int port,
                    Protocol protocol)
Set the given host, port and protocol.
Parameters:
host - the host, IP or DNS name
port - The port
protocol - the protocol

setHost

public void setHost(String host,
                    int port)
Set the given host and port. Select default protocol.
Parameters:
host - the host, IP or DNS name
port - The port

setHost

public void setHost(String host)
Set the given host. Select default protocol and port.
Parameters:
host - The host.

setHost

public void setHost(URI uri)
Sets the protocol, host and port from the given URI.
Parameters:
uri - the URI.

getHostURL

public String getHostURL()
Return the host url.
Returns:
String The host url.

getHost

public String getHost()
Returns the host.
Returns:
String

getVirtualHost

public String getVirtualHost()
Returns the virtual host.
Returns:
String

getPort

public int getPort()
Returns the port.
Returns:
int

getProtocol

public Protocol getProtocol()
Returns the protocol.
Returns:
String The protocol.

isProxySet

public boolean isProxySet()
Returns:
boolean True if a proxy server has been set.

setProxy

public void setProxy(String proxyHost,
                     int proxyPort)
Set the proxy settings.
Parameters:
proxyHost - The proxy host
proxyPort - The proxy port

getProxyHost

public String getProxyHost()
Returns the proxyHost.
Returns:
String

getProxyPort

public int getProxyPort()
Returns the proxyPort.
Returns:
int

setLocalAddress

public void setLocalAddress(InetAddress localAddress)
Set the local address to be used when creating connections. If this is unset, the default address will be used. This is useful for specifying the interface to use on multi-homed or clustered systems.
Parameters:
localAddress - the local address to use

getLocalAddress

public InetAddress getLocalAddress()
Return the local address to be used when creating connections. If this is unset, the default address should be used.
Returns:
InetAddress the local address to be used when creating Sockets

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.