Represents a protocol version, as specified in RFC 2616. More...
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.
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. | |
ProtocolVersion | ( | String | protocol, |
int | major, | ||
int | minor | ||
) |
protocol | the name of the protocol, for example "HTTP" |
major | the major version number of the protocol |
minor | the minor version number of the protocol |
final String getProtocol | ( | ) |
final int getMajor | ( | ) |
final int getMinor | ( | ) |
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.
major | the major version |
minor | the minor version |
Reimplemented in HttpVersion.
final int hashCode | ( | ) |
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.
obj | the object to compare with |
true
if the argument is the same protocol version, false
otherwise boolean isComparable | ( | ProtocolVersion | that | ) |
Only protocol versions with the same protocol name can be compared .
that | the protocol version to consider |
true
if compareToVersion can be called with the argument, false
otherwise 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.
that | the protocl version to compare with |
IllegalArgumentException | if the argument has a different protocol name than this object, or if the argument is null |
final boolean greaterEquals | ( | ProtocolVersion | version | ) |
version | the version against which to check this version |
true
if this protocol version is comparable to the argument and compares as greater or equal, false
otherwise final boolean lessEquals | ( | ProtocolVersion | version | ) |
version | the version against which to check this version |
true
if this protocol version is comparable to the argument and compares as less or equal, false
otherwise String toString | ( | ) |
|
protected |