org.apache.http.conn.scheme
Class Scheme

java.lang.Object
  extended by org.apache.http.conn.scheme.Scheme

@Immutable
public final class Scheme
extends Object

Encapsulates specifics of a protocol scheme such as "http" or "https". Schemes are identified by lowercase names. Supported schemes are typically collected in a SchemeRegistry.

For example, to configure support for "https://" URLs, you could write code like the following:

 Scheme https = new Scheme("https", new MySecureSocketFactory(), 443);
 SchemeRegistry.DEFAULT.register(https);
 

Since:
4.0

Constructor Summary
Scheme(String name, SocketFactory factory, int port)
          Creates a new scheme.
 
Method Summary
 boolean equals(Object obj)
          Compares this scheme to an object.
 int getDefaultPort()
          Obtains the default port.
 String getName()
          Obtains the scheme name.
 SocketFactory getSocketFactory()
          Obtains the socket factory.
 int hashCode()
          Obtains a hash code for this scheme.
 boolean isLayered()
          Indicates whether this scheme allows for layered connections.
 int resolvePort(int port)
          Resolves the correct port for this scheme.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scheme

public Scheme(String name,
              SocketFactory factory,
              int port)
Creates a new scheme. Whether the created scheme allows for layered connections depends on the class of factory.

Parameters:
name - the scheme name, for example "http". The name will be converted to lowercase.
factory - the factory for creating sockets for communication with this scheme
port - the default port for this scheme
Method Detail

getDefaultPort

public final int getDefaultPort()
Obtains the default port.

Returns:
the default port for this scheme

getSocketFactory

public final SocketFactory getSocketFactory()
Obtains the socket factory. If this scheme is layered, the factory implements LayeredSocketFactory.

Returns:
the socket factory for this scheme

getName

public final String getName()
Obtains the scheme name.

Returns:
the name of this scheme, in lowercase

isLayered

public final boolean isLayered()
Indicates whether this scheme allows for layered connections.

Returns:
true if layered connections are possible, false otherwise

resolvePort

public final int resolvePort(int port)
Resolves the correct port for this scheme. Returns the given port if it is valid, the default port otherwise.

Parameters:
port - the port to be resolved, a negative number to obtain the default port
Returns:
the given port or the defaultPort

toString

public final String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Returns:
a human-readable string description of this scheme

equals

public final boolean equals(Object obj)
Compares this scheme to an object.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true iff the argument is equal to this scheme

hashCode

public int hashCode()
Obtains a hash code for this scheme.

Overrides:
hashCode in class Object
Returns:
the hash code


Copyright © 1999-2010 Apache Software Foundation. All Rights Reserved.