@Immutable public class ProtocolVersion extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable
This class defines a protocol version as a combination of
protocol name, major version number, and minor version number.
Note that equals(java.lang.Object) and hashCode() are defined as
final here, they cannot be overridden in derived classes.
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
major
Major version number of the protocol
|
protected int |
minor
Minor version number of the protocol
|
protected java.lang.String |
protocol
Name of the protocol.
|
| 构造器和说明 |
|---|
ProtocolVersion(java.lang.String protocol,
int major,
int minor)
Create a protocol version designator.
|
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.Object |
clone() |
int |
compareToVersion(ProtocolVersion that)
Compares this protocol version with another one.
|
boolean |
equals(java.lang.Object obj)
Checks equality of this protocol version with an object.
|
ProtocolVersion |
forVersion(int major,
int minor)
Obtains a specific version of this protocol.
|
int |
getMajor()
Returns the major version number of the protocol.
|
int |
getMinor()
Returns the minor version number of the HTTP protocol.
|
java.lang.String |
getProtocol()
Returns the name of the protocol.
|
boolean |
greaterEquals(ProtocolVersion version)
Tests if this protocol version is greater or equal to the given one.
|
int |
hashCode()
Obtains a hash code consistent with
equals(java.lang.Object). |
boolean |
isComparable(ProtocolVersion that)
Checks whether this protocol can be compared to another one.
|
boolean |
lessEquals(ProtocolVersion version)
Tests if this protocol version is less or equal to the given one.
|
java.lang.String |
toString()
Converts this protocol version to a string.
|
protected final java.lang.String protocol
protected final int major
protected final int minor
public ProtocolVersion(java.lang.String protocol,
int major,
int minor)
protocol - the name of the protocol, for example "HTTP"major - the major version number of the protocolminor - the minor version number of the protocolpublic final java.lang.String getProtocol()
public final int getMajor()
public final int getMinor()
public ProtocolVersion forVersion(int major, int minor)
this
if the version matches, and creates a new ProtocolVersion
otherwise.major - the major versionminor - the minor versionpublic final int hashCode()
equals(java.lang.Object).hashCode 在类中 java.lang.Objectpublic final boolean equals(java.lang.Object obj)
equals 在类中 java.lang.Objectobj - the object to compare withtrue if the argument is the same protocol version,
false otherwisepublic boolean isComparable(ProtocolVersion that)
compared.that - the protocol version to considertrue if compareToVersion
can be called with the argument, false otherwisepublic int compareToVersion(ProtocolVersion that)
Comparable.that - the protocol version to compare withjava.lang.IllegalArgumentException - if the argument has a different protocol name than this object,
or if the argument is nullpublic final boolean greaterEquals(ProtocolVersion version)
version - the version against which to check this versiontrue if this protocol version is
comparable to the argument
and compares as greater or equal,
false otherwisepublic final boolean lessEquals(ProtocolVersion version)
version - the version against which to check this versiontrue if this protocol version is
comparable to the argument
and compares as less or equal,
false otherwisepublic java.lang.String toString()
toString 在类中 java.lang.Objectpublic java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone 在类中 java.lang.Objectjava.lang.CloneNotSupportedException