|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.Version
This class is used to hold version information pertaining to a Component or interface.
The version number of aComponent
is made up of three
dot-separated fields:
"major.minor.micro"
The major, minor and micro fields are
integer numbers represented in decimal notation and have the
following meaning:
Constructor Summary | |
Version(int major,
int minor,
int micro)
Create a new instance of a Version object with the
specified version numbers. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compare two versions together according to the Comparable interface. |
boolean |
complies(Version other)
Check this Version against another for compliancy
(compatibility). |
boolean |
equals(java.lang.Object other)
Indicates whether some other object is "equal to" this Version . |
boolean |
equals(Version other)
Check this Version against another for equality. |
int |
getMajor()
Retrieve major component of version. |
int |
getMicro()
Retrieve micro component of version. |
int |
getMinor()
Retrieve minor component of version. |
static Version |
getVersion(java.lang.String version)
Parse a version out of a string. |
int |
hashCode()
Add a hashing function to ensure the Version object is treated as expected in hashmaps and sets. |
java.lang.String |
toString()
Overload toString to report version correctly. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Version(int major, int minor, int micro)
Version
object with the
specified version numbers.
major
- This Version
major number.minor
- This Version
minor number.micro
- This Version
micro number.Method Detail |
public static Version getVersion(java.lang.String version) throws java.lang.NumberFormatException, java.lang.IllegalArgumentException
version
- The input version string
java.lang.NumberFormatException
- if an error occurs
java.lang.IllegalArgumentException
- if an error occurs
java.lang.NullPointerException
- if the provided string is null
public int getMajor()
public int getMinor()
public int getMicro()
public boolean equals(Version other)
Version
against another for equality.
If this Version
is compatible with the specified one, then
true is returned, otherwise false.
other
- The other Version
object to be compared with this
for equality.
Version
is compatible with the specified onepublic boolean equals(java.lang.Object other)
Version
.
Returns true if the other object is an instance of Version
and has the same major, minor, and micro components.
other
- an Object
value
Version
public int hashCode()
public boolean complies(Version other)
Version
against another for compliancy
(compatibility).
If this Version
is compatible with the specified one, then
true is returned, otherwise false. Be careful when using
this method since, in example, version 1.3.7 is compliant to version
1.3.6, while the opposite is not.
The following example displays the expected behaviour and results of version.
final Version v1 = new Version( 1, 3 , 6 ); final Version v2 = new Version( 1, 3 , 7 ); final Version v3 = new Version( 1, 4 , 0 ); final Version v4 = new Version( 2, 0 , 1 ); assert( v1.complies( v1 ) ); assert( ! v1.complies( v2 ) ); assert( v2.complies( v1 ) ); assert( ! v1.complies( v3 ) ); assert( v3.complies( v1 ) ); assert( ! v1.complies( v4 ) ); assert( ! v4.complies( v1 ) );
other
- The other Version
object to be compared with this
for compliancy (compatibility).
Version
is compatible with the specified onepublic java.lang.String toString()
public int compareTo(java.lang.Object o)
Comparable
interface.
compareTo
in interface java.lang.Comparable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |