@Contract(threading=IMMUTABLE) public class ProtocolVersion extends Object implements Serializable
This class defines a protocol version as a combination of
protocol name, major version number, and minor version number.
Note that equals(int, int)
and hashCode()
are defined as
final here, they cannot be overridden in derived classes.
Constructor and Description |
---|
ProtocolVersion(String protocol,
int major,
int minor)
Create a protocol version designator.
|
Modifier and Type | Method and Description |
---|---|
int |
compareToVersion(ProtocolVersion that)
Compares this protocol version with another one.
|
boolean |
equals(int major,
int minor)
Checks whether this instance has the same major and minor version as the arguments.
|
boolean |
equals(Object obj)
Checks equality of this protocol version with an object.
|
String |
format()
Formats this protocol version as a string.
|
int |
getMajor()
Returns the major version number of the protocol.
|
int |
getMinor()
Returns the minor version number of the HTTP protocol.
|
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(int, int) . |
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.
|
static ProtocolVersion |
parse(CharSequence buffer,
Tokenizer.Cursor cursor,
Tokenizer.Delimiter delimiterPredicate) |
static ProtocolVersion |
parse(String s) |
String |
toString()
Converts this protocol version to a string.
|
public ProtocolVersion(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 String getProtocol()
public final int getMajor()
public final int getMinor()
public final int hashCode()
equals(int, int)
.public final boolean equals(int major, int minor)
major
- the major version to check.minor
- the minor version to check.public final boolean equals(Object obj)
public String format()
public 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 withIllegalArgumentException
- if the argument has a different protocol name than this object,
or if the argument is null
public 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
otherwise@Internal public static ProtocolVersion parse(CharSequence buffer, Tokenizer.Cursor cursor, Tokenizer.Delimiter delimiterPredicate) throws ParseException
ParseException
public static ProtocolVersion parse(String s) throws ParseException
ParseException
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.