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

Represents a protocol version, as specified in RFC 2616. More...

Inheritance diagram for ProtocolVersion:
HttpVersion

Description

RFC 2616 specifies only HTTP versions, like "HTTP/1.1" and "HTTP/1.0". RFC 3261 specifies a message format that is identical to HTTP except for the protocol name. It defines a protocol version "SIP/2.0". There are some nitty-gritty differences between the interpretation of versions in HTTP and SIP. In those cases, HTTP takes precedence.

This class defines a protocol version as a combination of protocol name, major version number, and minor version number. Note that equals and hashCode are defined as final here, they cannot be overridden in derived classes.

Author
Oleg Kalnichevski
Roland Weber
Version
Revision
609106

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

 ProtocolVersion (String protocol, int major, int minor)
 Create a protocol version designator. More...
 
final String getProtocol ()
 Returns the name of the protocol. More...
 
final int getMajor ()
 Returns the major version number of the protocol. More...
 
final int getMinor ()
 Returns the minor version number of the HTTP protocol. More...
 
ProtocolVersion forVersion (int major, int minor)
 Obtains a specific version of this protocol. More...
 
final int hashCode ()
 Obtains a hash code consistent with equals. More...
 
final boolean equals (Object obj)
 Checks equality of this protocol version with an object. More...
 
boolean isComparable (ProtocolVersion that)
 Checks whether this protocol can be compared to another one. More...
 
int compareToVersion (ProtocolVersion that)
 Compares this protocol version with another one. More...
 
final boolean greaterEquals (ProtocolVersion version)
 Tests if this protocol version is greater or equal to the given one. More...
 
final boolean lessEquals (ProtocolVersion version)
 Tests if this protocol version is less or equal to the given one. More...
 
String toString ()
 Converts this protocol version to a string. More...
 

Protected Attributes

final String protocol
 Name of the protocol. More...
 
final int major
 Major version number of the protocol.
 
final int minor
 Minor version number of the protocol.
 

Constructor & Destructor Documentation

◆ ProtocolVersion()

ProtocolVersion ( String  protocol,
int  major,
int  minor 
)
Parameters
protocolthe name of the protocol, for example "HTTP"
majorthe major version number of the protocol
minorthe minor version number of the protocol

Member Function Documentation

◆ getProtocol()

final String getProtocol ( )
Returns
the protocol name

◆ getMajor()

final int getMajor ( )
Returns
the major version number.

◆ getMinor()

final int getMinor ( )
Returns
the minor version number.

◆ forVersion()

ProtocolVersion forVersion ( int  major,
int  minor 
)

This can be used by derived classes to instantiate themselves instead of the base class, and to define constants for commonly used versions.
The default implementation in this class returns this if the version matches, and creates a new ProtocolVersion otherwise.

Parameters
majorthe major version
minorthe minor version
Returns
a protocol version with the same protocol name and the argument version

Reimplemented in HttpVersion.

◆ hashCode()

final int hashCode ( )
Returns
the hashcode of this protocol version

◆ equals()

final boolean equals ( Object  obj)

The object is equal if it is a protocl version with the same protocol name, major version number, and minor version number. The specific class of the object is not relevant, instances of derived classes with identical attributes are equal to instances of the base class and vice versa.

Parameters
objthe object to compare with
Returns
true if the argument is the same protocol version, false otherwise

◆ isComparable()

boolean isComparable ( ProtocolVersion  that)

Only protocol versions with the same protocol name can be compared .

Parameters
thatthe protocol version to consider
Returns
true if compareToVersion can be called with the argument, false otherwise

◆ compareToVersion()

int compareToVersion ( ProtocolVersion  that)

Only protocol versions with the same protocol name can be compared. This method does not define a total ordering, as it would be required for java.lang.Comparable.

Parameters
thatthe protocl version to compare with
Returns
a negative integer, zero, or a positive integer as this version is less than, equal to, or greater than the argument version.
Exceptions
IllegalArgumentExceptionif the argument has a different protocol name than this object, or if the argument is null

◆ greaterEquals()

final boolean greaterEquals ( ProtocolVersion  version)
Parameters
versionthe version against which to check this version
Returns
true if this protocol version is comparable to the argument and compares as greater or equal, false otherwise

◆ lessEquals()

final boolean lessEquals ( ProtocolVersion  version)
Parameters
versionthe version against which to check this version
Returns
true if this protocol version is comparable to the argument and compares as less or equal, false otherwise

◆ toString()

String toString ( )
Returns
a protocol version string, like "HTTP/1.1"

Member Data Documentation

◆ protocol

final String protocol
protected