Package org.apache.http.conn.scheme
Class Scheme
java.lang.Object
org.apache.http.conn.scheme.Scheme
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);
- Author:
- Roland Weber, Michael Becke, Jeff Dever, Mike Bowler
-
Constructor Summary
Constructors Constructor Description Scheme(String name, SocketFactory factory, int port)Creates a new scheme. -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)Compares this scheme to an object.intgetDefaultPort()Obtains the default port.StringgetName()Obtains the scheme name.SocketFactorygetSocketFactory()Obtains the socket factory.inthashCode()Obtains a hash code for this scheme.booleanisLayered()Indicates whether this scheme allows for layered connections.intresolvePort(int port)Resolves the correct port for this scheme.StringtoString()Return a string representation of this object.
-
Constructor Details
-
Scheme
Creates a new scheme. Whether the created scheme allows for layered connections depends on the class offactory.- 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 schemeport- the default port for this scheme
-
-
Method Details
-
getDefaultPort
public final int getDefaultPort()Obtains the default port.- Returns:
- the default port for this scheme
-
getSocketFactory
Obtains the socket factory. If this scheme islayered, the factory implementsLayeredSocketFactory.- Returns:
- the socket factory for this scheme
-
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:
trueif layered connections are possible,falseotherwise
-
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
Return a string representation of this object. -
equals
Compares this scheme to an object.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with- Returns:
trueiff the argument is equal to this scheme- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Obtains a hash code for this scheme.- Overrides:
hashCodein classObject- Returns:
- the hash code
- See Also:
Object.equals(java.lang.Object)
-