• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
Scheme Class Reference

Encapsulates specifics of a protocol scheme such as "http" or "https". More...

Description

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

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 Scheme (final String name, final SocketFactory factory, final int port)
 Creates a new scheme. More...
 
final int getDefaultPort ()
 Obtains the default port. More...
 
final SocketFactory getSocketFactory ()
 Obtains the socket factory. More...
 
final String getName ()
 Obtains the scheme name. More...
 
final boolean isLayered ()
 Indicates whether this scheme allows for layered connections. More...
 
final int resolvePort (int port)
 Resolves the correct port for this scheme. More...
 
final String toString ()
 Return a string representation of this object. More...
 
final boolean equals (Object obj)
 Compares this scheme to an object. More...
 
int hashCode ()
 Obtains a hash code for this scheme. More...
 

Constructor & Destructor Documentation

◆ Scheme()

Scheme ( final String  name,
final SocketFactory  factory,
final int  port 
)

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

Parameters
namethe scheme name, for example "http". The name will be converted to lowercase.
factorythe factory for creating sockets for communication with this scheme
portthe default port for this scheme

Member Function Documentation

◆ getDefaultPort()

final int getDefaultPort ( )
Returns
the default port for this scheme

◆ getSocketFactory()

final SocketFactory getSocketFactory ( )

If this scheme is layered , the factory implements LayeredSocketFactory .

Returns
the socket factory for this scheme

◆ getName()

final String getName ( )
Returns
the name of this scheme, in lowercase

◆ isLayered()

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

◆ resolvePort()

final int resolvePort ( int  port)

Returns the given port if it is valid, the default port otherwise.

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

◆ toString()

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

◆ equals()

final boolean equals ( Object  obj)
Parameters
objthe object to compare with
Returns
true iff the argument is equal to this scheme

◆ hashCode()

int hashCode ( )
Returns
the hash code