| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectorg.apache.avalon.framework.Versionpublic final class Versionextends java.lang.Objectimplements Comparable, SerializableComponent 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 | |
| |
Method Summary | |
int |
|
boolean |
|
boolean |
|
boolean |
|
int |
|
int |
|
int |
|
static Version |
|
int |
|
String |
|
public Version(int major,
int minor,
int micro)Create a new instance of aVersionobject with the specified version numbers.
- Parameters:
major- ThisVersionmajor number.minor- ThisVersionminor number.micro- ThisVersionmicro number.
public int compareTo(Object o)
Compare two versions together according to theComparableinterface.
- Returns:
- number indicating relative value (-1, 0, 1)
public boolean complies(Version other)
Check thisVersionagainst another for compliancy (compatibility). If thisVersionis 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 ) );
- Parameters:
other- The otherVersionobject to be compared with this for compliancy (compatibility).
- Returns:
- true if this
Versionis compatible with the specified one
public boolean equals(Object other)
Indicates whether some other object is "equal to" thisVersion. Returns true if the other object is an instance ofVersionand has the same major, minor, and micro components.
- Parameters:
other- anObjectvalue
- Returns:
- true if the other object is equal to this
Version
public boolean equals(Version other)
Check thisVersionagainst another for equality. If thisVersionis compatible with the specified one, then true is returned, otherwise false.
- Parameters:
other- The otherVersionobject to be compared with this for equality.
- Returns:
- true if this
Versionis compatible with the specified one
- Since:
- 4.1
public int getMajor()
Retrieve major component of version.
- Returns:
- the major component of version
- Since:
- 4.1
public int getMicro()
Retrieve micro component of version.
- Returns:
- the micro component of version.
- Since:
- 4.1
public int getMinor()
Retrieve minor component of version.
- Returns:
- the minor component of version
- Since:
- 4.1
public static Version getVersion(String version)
throws NumberFormatException,
IllegalArgumentExceptionParse a version out of a string. The version string format is. . where both minor and micro are optional.
- Parameters:
version- The input version string
- Returns:
- the new Version object
- Since:
- 4.1
public int hashCode()
Add a hashing function to ensure the Version object is treated as expected in hashmaps and sets. NOTE: any time the equals() is overridden, hashCode() should also be overridden.
- Returns:
- the hashCode
public String toString()
Overload toString to report version correctly.
- Returns:
- the dot seperated version string