Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.http
Class Scheme  view Scheme download Scheme.java

java.lang.Object
  extended byorg.apache.http.Scheme

public class Scheme
extends java.lang.Object

A class to encapsulate the specifics of a protocol scheme. This class also provides the ability to customize the set and characteristics of the schemes used.

One use case for modifying the default set of protocols would be to set a custom SSL socket factory. This would look something like the following:

 
 Scheme myHTTPS = new Scheme( "https", new MySSLSocketFactory(), 443 );
 
 Scheme.registerScheme( "https", myHTTPS );
 

Since:
2.0

Field Summary
private  int defaultPort
          The default port for this scheme
private  java.lang.String name
          the scheme of this scheme (e.g.
private static java.util.Map SCHEMES
          The available schemes
private  boolean secure
          True if this scheme is secure
private  org.apache.http.io.SocketFactory socketFactory
          The socket factory for this scheme
 
Constructor Summary
Scheme(java.lang.String name, org.apache.http.io.SocketFactory factory, int defaultPort)
          Constructs a new Protocol.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Return true if the specified object equals this object.
 int getDefaultPort()
          Returns the defaultPort.
 java.lang.String getName()
          Returns the scheme.
static Scheme getScheme(java.lang.String id)
          Gets the scheme with the given ID.
 org.apache.http.io.SocketFactory getSocketFactory()
          Returns the socketFactory.
 int hashCode()
          Return a hash code for this object
 boolean isSecure()
          Returns true if this scheme is secure
static void registerScheme(java.lang.String id, Scheme scheme)
          Registers a new scheme with the given identifier.
 int resolvePort(int port)
          Resolves the correct port for this scheme.
 java.lang.String toString()
          Return a string representation of this object.
static void unregisterScheme(java.lang.String id)
          Unregisters the scheme with the given ID.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SCHEMES

private static final java.util.Map SCHEMES
The available schemes


name

private java.lang.String name
the scheme of this scheme (e.g. http, https)


socketFactory

private org.apache.http.io.SocketFactory socketFactory
The socket factory for this scheme


defaultPort

private int defaultPort
The default port for this scheme


secure

private boolean secure
True if this scheme is secure

Constructor Detail

Scheme

public Scheme(java.lang.String name,
              org.apache.http.io.SocketFactory factory,
              int defaultPort)
Constructs a new Protocol. Whether the created scheme is secure depends on the class of factory.

Method Detail

registerScheme

public static void registerScheme(java.lang.String id,
                                  Scheme scheme)
Registers a new scheme with the given identifier. If a scheme with the given ID already exists it will be overridden. This ID is the same one used to retrieve the scheme from getScheme(String).


unregisterScheme

public static void unregisterScheme(java.lang.String id)
Unregisters the scheme with the given ID.


getScheme

public static Scheme getScheme(java.lang.String id)
                        throws java.lang.IllegalStateException
Gets the scheme with the given ID.


getDefaultPort

public int getDefaultPort()
Returns the defaultPort.


getSocketFactory

public org.apache.http.io.SocketFactory getSocketFactory()
Returns the socketFactory. If secure the factory is a SecureSocketFactory.


getName

public java.lang.String getName()
Returns the scheme.


isSecure

public boolean isSecure()
Returns true if this scheme is secure


resolvePort

public int resolvePort(int port)
Resolves the correct port for this scheme. Returns the given port if valid or the default port otherwise.


toString

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


equals

public boolean equals(java.lang.Object obj)
Return true if the specified object equals this object.


hashCode

public int hashCode()
Return a hash code for this object