|
OSGi™ Service Platform Core Specification Release 4 Version 4.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.osgi.framework.Version
public class Version
Version identifier for bundles and packages.
Version identifiers have four components.
Version(String)
for the
format of the qualifier string.
Version
objects are immutable.
Field Summary | |
---|---|
static Version |
emptyVersion
The empty version "0.0.0". |
Constructor Summary | |
---|---|
Version(int major,
int minor,
int micro)
Creates a version identifier from the specified numerical components. |
|
Version(int major,
int minor,
int micro,
java.lang.String qualifier)
Creates a version identifier from the specified components. |
|
Version(java.lang.String version)
Created a version identifier from the specified string. |
Method Summary | |
---|---|
int |
compareTo(Version other)
Compares this Version object to another Version . |
boolean |
equals(java.lang.Object object)
Compares this Version object to another object. |
int |
getMajor()
Returns the major component of this version identifier. |
int |
getMicro()
Returns the micro component of this version identifier. |
int |
getMinor()
Returns the minor component of this version identifier. |
java.lang.String |
getQualifier()
Returns the qualifier component of this version identifier. |
int |
hashCode()
Returns a hash code value for the object. |
static Version |
parseVersion(java.lang.String version)
Parses a version identifier from the specified string. |
java.lang.String |
toString()
Returns the string representation of this version identifier. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Version emptyVersion
Constructor Detail |
---|
public Version(int major, int minor, int micro)
The qualifier is set to the empty string.
major
- Major component of the version identifier.minor
- Minor component of the version identifier.micro
- Micro component of the version identifier.
java.lang.IllegalArgumentException
- If the numerical components are
negative.public Version(int major, int minor, int micro, java.lang.String qualifier)
major
- Major component of the version identifier.minor
- Minor component of the version identifier.micro
- Micro component of the version identifier.qualifier
- Qualifier component of the version identifier. If
null
is specified, then the qualifier will be set to
the empty string.
java.lang.IllegalArgumentException
- If the numerical components are negative
or the qualifier string is invalid.public Version(java.lang.String version)
Here is the grammar for version strings.
version ::= major('.'minor('.'micro('.'qualifier)?)?)? major ::= digit+ minor ::= digit+ micro ::= digit+ qualifier ::= (alpha|digit|'_'|'-')+ digit ::= [0..9] alpha ::= [a..zA..Z]There must be no whitespace in version.
version
- String representation of the version identifier.
java.lang.IllegalArgumentException
- If version
is improperly
formatted.Method Detail |
---|
public static Version parseVersion(java.lang.String version)
See Version(String)
for the format of the version string.
version
- String representation of the version identifier. Leading
and trailing whitespace will be ignored.
Version
object representing the version
identifier. If version
is null
or
the empty string then emptyVersion
will be
returned.
java.lang.IllegalArgumentException
- If version
is improperly
formatted.public int getMajor()
public int getMinor()
public int getMicro()
public java.lang.String getQualifier()
public java.lang.String toString()
The format of the version string will be major.minor.micro
if qualifier is the empty string or
major.minor.micro.qualifier
otherwise.
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
Version
object to another object.
A version is considered to be equal to another version if the
major, minor and micro components are equal and the qualifier component
is equal (using String.equals
).
equals
in class java.lang.Object
object
- The Version
object to be compared.
true
if object
is a
Version
and is equal to this object;
false
otherwise.public int compareTo(Version other)
Version
object to another Version
.
A version is considered to be less than another version if its
major component is less than the other version's major component, or the
major components are equal and its minor component is less than the other
version's minor component, or the major and minor components are equal
and its micro component is less than the other version's micro component,
or the major, minor and micro components are equal and it's qualifier
component is less than the other version's qualifier component (using
String.compareTo
).
A version is considered to be equal to another version if the
major, minor and micro components are equal and the qualifier component
is equal (using String.compareTo
).
compareTo
in interface java.lang.Comparable<Version>
other
- The Version
object to be compared.
Version
object.
java.lang.ClassCastException
- If the specified object is not a
Version
object.
|
OSGi™ Service Platform Core Specification Release 4 Version 4.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |