Method from org.apache.http.ProtocolVersion Detail: |
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
|
public int compareToVersion(ProtocolVersion that) {
if (that == null) {
throw new IllegalArgumentException
("Protocol version must not be null.");
}
if (!this.protocol.equals(that.protocol)) {
throw new IllegalArgumentException
("Versions for different protocols cannot be compared. " +
this + " " + that);
}
int delta = getMajor() - that.getMajor();
if (delta == 0) {
delta = getMinor() - that.getMinor();
}
return delta;
}
Compares this protocol version with another one.
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 . |
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ProtocolVersion)) {
return false;
}
ProtocolVersion that = (ProtocolVersion) obj;
return ((this.protocol.equals(that.protocol)) &&
(this.major == that.major) &&
(this.minor == that.minor));
}
Checks equality of this protocol version with an object.
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. |
public ProtocolVersion forVersion(int major,
int minor) {
if ((major == this.major) && (minor == this.minor)) {
return this;
}
// argument checking is done in the constructor
return new ProtocolVersion(this.protocol, major, minor);
}
Obtains a specific version of this protocol.
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. |
public final int getMajor() {
return major;
}
Returns the major version number of the protocol. |
public final int getMinor() {
return minor;
}
Returns the minor version number of the HTTP protocol. |
public final String getProtocol() {
return protocol;
}
Returns the name of the protocol. |
public final boolean greaterEquals(ProtocolVersion version) {
return isComparable(version) && (compareToVersion(version) >= 0);
}
Tests if this protocol version is greater or equal to the given one. |
public final int hashCode() {
return this.protocol.hashCode() ^ (this.major * 100000) ^ this.minor;
}
Obtains a hash code consistent with #equals . |
public boolean isComparable(ProtocolVersion that) {
return (that != null) && this.protocol.equals(that.protocol);
}
Checks whether this protocol can be compared to another one.
Only protocol versions with the same protocol name can be
compared . |
public final boolean lessEquals(ProtocolVersion version) {
return isComparable(version) && (compareToVersion(version) < = 0);
}
Tests if this protocol version is less or equal to the given one. |
public String toString() {
CharArrayBuffer buffer = new CharArrayBuffer(16);
buffer.append(this.protocol);
buffer.append('/');
buffer.append(Integer.toString(this.major));
buffer.append('.');
buffer.append(Integer.toString(this.minor));
return buffer.toString();
}
Converts this protocol version to a string. |