Top Description Fields Constructors Methods
org.apache.http.conn.scheme

public final Class Scheme

extends Object
Class Inheritance
Annotations
@Contract
threading:IMMUTABLE
@Deprecated
Imports
java.util.Locale, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.util.Args, .LangUtils

Deprecated

(4.3) use org.apache.http.conn.SchemePortResolver for default port resolution and org.apache.http.config.Registry for socket factory lookups.

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", 443, new MySecureSocketFactory());
SchemeRegistry registry = new SchemeRegistry();
registry.register(https);
Since
4.0

Field Summary

Modifier and TypeField and Description
private final int
defaultPort

The default port for this scheme

private final boolean
layered

Indicates whether this scheme allows for layered connections

private final String
name

The name of this scheme, in lowercase.

private final SchemeSocketFactory
socketFactory

The socket factory for this scheme

private String
stringRep

A string representation, for toString.

Constructor Summary

AccessConstructor and Description
public
Scheme(final String
the scheme name, for example "http". The name will be converted to lowercase.
name
,
final int
the default port for this scheme
port
,
final SchemeSocketFactory
the factory for creating sockets for communication with this scheme
factory
)

Deprecated as a consequence of SchemeSocketFactory being deprecated.
Creates a new scheme.
public
Scheme(final String
the scheme name, for example "http". The name will be converted to lowercase.
name
,
final SocketFactory
the factory for creating sockets for communication with this scheme
factory
,
final int
the default port for this scheme
port
)

Creates a new scheme.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int

Returns:

the default port for this scheme
getDefaultPort
()

Obtains the default port.

public String

Returns:

the name of this scheme, in lowercase
getName
()

Obtains the scheme name.

public SchemeSocketFactory

Returns:

the socket factory for this scheme
getSchemeSocketFactory
()

Deprecated as a consequence of SchemeSocketFactory being deprecated.
Obtains the socket factory.
public SocketFactory

Returns:

the socket factory for this scheme
getSocketFactory
()

Deprecated (4.1) Use getSchemeSocketFactory()
Obtains the socket factory.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if layered connections are possible, false otherwise
isLayered
()

Indicates whether this scheme allows for layered connections.

public int

Returns:

the given port or the defaultPort
resolvePort
(final int
the port to be resolved, a negative number to obtain the default port
port
)

Resolves the correct port for this scheme.

public String

Returns:

a human-readable string description of this scheme
toString
()

Overrides java.lang.Object.toString.

Return a string representation of this object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

defaultPortback to summary
private final int defaultPort

The default port for this scheme

layeredback to summary
private final boolean layered

Indicates whether this scheme allows for layered connections

nameback to summary
private final String name

The name of this scheme, in lowercase. (e.g. http, https)

socketFactoryback to summary
private final SchemeSocketFactory socketFactory

Deprecated

as a consequence of SchemeSocketFactory being deprecated. See corresponding docs for further information.

The socket factory for this scheme

stringRepback to summary
private String stringRep

A string representation, for toString.

Constructor Detail

Schemeback to summary
public Scheme(final String name, final int port, final SchemeSocketFactory factory)

Deprecated

as a consequence of SchemeSocketFactory being deprecated. See corresponding docs for further information.

Creates a new scheme. Whether the created scheme allows for layered connections depends on the class of factory.

Parameters
name:String

the scheme name, for example "http". The name will be converted to lowercase.

port:int

the default port for this scheme

factory:SchemeSocketFactory

the factory for creating sockets for communication with this scheme

Since
4.1
Schemeback to summary
public Scheme(final String name, final SocketFactory factory, final int port)

Creates a new scheme. Whether the created scheme allows for layered connections depends on the class of factory.

Parameters
name:String

the scheme name, for example "http". The name will be converted to lowercase.

factory:SocketFactory

the factory for creating sockets for communication with this scheme

port:int

the default port for this scheme

Annotations
@Deprecated

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDefaultPortback to summary
public int getDefaultPort()

Obtains the default port.

Returns:int

the default port for this scheme

getNameback to summary
public String getName()

Obtains the scheme name.

Returns:String

the name of this scheme, in lowercase

getSchemeSocketFactoryback to summary
public SchemeSocketFactory getSchemeSocketFactory()

Deprecated

as a consequence of SchemeSocketFactory being deprecated. See corresponding docs for further information.

Obtains the socket factory. If this scheme is layered, the factory implements LayeredSchemeSocketFactory.

Returns:SchemeSocketFactory

the socket factory for this scheme

Since
4.1
getSocketFactoryback to summary
public SocketFactory getSocketFactory()

Deprecated

(4.1) Use getSchemeSocketFactory()

Obtains the socket factory. If this scheme is layered, the factory implements LayeredSocketFactory.

Returns:SocketFactory

the socket factory for this scheme

Annotations
@Deprecated
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isLayeredback to summary
public boolean isLayered()

Indicates whether this scheme allows for layered connections.

Returns:boolean

true if layered connections are possible, false otherwise

resolvePortback to summary
public int resolvePort(final int port)

Resolves the correct port for this scheme. Returns the given port if it is valid, the default port otherwise.

Parameters
port:int

the port to be resolved, a negative number to obtain the default port

Returns:int

the given port or the defaultPort

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a string representation of this object.

Returns:String

a human-readable string description of this scheme

Annotations
@Override