|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.module.Version
public class Version
This class represents a version in the module system. The version must be in the following format:
For example,major[.minor[.micro[.update]]][-qualifier]
The version format is described by the following grammar:1 1.7 1.7-b61 1.7.0 1.7.0-b61 1.7.0.0 1.7.0.1 1.7.1.3-b32-beta-1 1.7.1.3-b56_rc
whereversion := simple-version ('-' qualifier)? simple-version:= major ('.' minor ('.' micro ('.' update)?)?)? major := digit+ minor := digit+ micro := digit+ update := digit+ qualifier := (alpha | digit | '-' | '_')+
alpha
is an alphabetic character, e.g. a-z, A-Z.
digit
is a decimal digit, e.g. 0-9.
Instances of this class are immutable and safe for concurrent use by multiple threads.
Query
,
VersionConstraint
Field Summary | |
---|---|
static Version |
DEFAULT
A Version object that represents the default version
"0.0.0.0-default". |
Constructor Summary | |
---|---|
protected |
Version(int major,
int minor,
int micro,
int update,
String qualifier)
Constructs a new Version instance. |
Method Summary | |
---|---|
int |
compareTo(Version version)
Compare two Version objects. |
boolean |
equals(Object obj)
Compare two Version objects for equality. |
int |
getMajorNumber()
Returns the major number in the version. |
int |
getMicroNumber()
Returns the micro number in the version. |
int |
getMinorNumber()
Returns the minor number in the version. |
String |
getQualifier()
Returns the qualifier in the version. |
int |
getUpdateNumber()
Returns the update number in the version. |
int |
hashCode()
Returns a hash code for this Version . |
static boolean |
isVersion(String source)
Returns true if the string is a version in valid format. |
String |
toString()
Returns a String object representing this
Version 's value. |
VersionConstraint |
toVersionConstraint()
Return a VersionConstraint object that represents this version. |
Version |
trimQualifier()
Returns a Version instance, with the qualifier omitted. |
static Version |
valueOf(int major,
int minor,
int micro)
Returns a Version object holding the specified version number. |
static Version |
valueOf(int major,
int minor,
int micro,
int update)
Returns a Version object holding the specified version number. |
static Version |
valueOf(int major,
int minor,
int micro,
int update,
String qualifier)
Returns a Version object holding the specified version number. |
static Version |
valueOf(int major,
int minor,
int micro,
String qualifier)
Returns a Version object holding the specified version number. |
static Version |
valueOf(String version)
Returns a Version object holding the value of the specified string. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Version DEFAULT
Version
object that represents the default version
"0.0.0.0-default".
Constructor Detail |
---|
protected Version(int major, int minor, int micro, int update, String qualifier)
Version
instance.
This constructor is for use by subclasses. Applications should use
one of the valueOf()
factory methods to
obtain Version
instances.
major
- the major version number.minor
- the minor version number.micro
- the micro version number.update
- the update version number.qualifier
- the qualifier
IllegalArgumentException
- if major, minor, micro,
or update are negative, or if qualifier contains illegal character.Method Detail |
---|
public static Version valueOf(String version)
Version
object holding the value of the specified string.
The string must be in the version format and must not
contain any leading or trailing whitespace.
version
- the string to be parsed.
Version
parsed from the string.
IllegalArgumentException
- if
the string cannot be parsed.public static Version valueOf(int major, int minor, int micro)
Version
object holding the specified version number.
Equivalent to valueOf(major, minor, micro, 0, null);
.
major
- the major version number.minor
- the minor version number.micro
- the micro version number.
IllegalArgumentException
- if major, minor, or micro
is negative.public static Version valueOf(int major, int minor, int micro, String qualifier)
Version
object holding the specified version number.
Equivalent to valueOf(major, minor, micro, 0, qualifier);
.
major
- the major version number.minor
- the minor version number.micro
- the micro version number.qualifier
- the qualifier
IllegalArgumentException
- if major or minor or micro
is negative, or qualifier contains illegal character.public static Version valueOf(int major, int minor, int micro, int update)
Version
object holding the specified version number.
Equivalent to valueOf(major, minor, micro, update, null);
.
major
- the major version number.minor
- the minor version number.micro
- the micro version number.update
- the update version number.
IllegalArgumentException
- if major or minor or micro
or update is negative.public static Version valueOf(int major, int minor, int micro, int update, String qualifier)
Version
object holding the specified version number.
major
- the major version number.minor
- the minor version number.micro
- the micro version number.update
- the update version number.qualifier
- the qualifier
IllegalArgumentException
- if major, minor, micro,
or update is negative, or if qualifier contains illegal characters.public int getMajorNumber()
public int getMinorNumber()
public int getMicroNumber()
public int getUpdateNumber()
public String getQualifier()
public static boolean isVersion(String source)
public VersionConstraint toVersionConstraint()
VersionConstraint
object that represents this version.
VersionConstraint
object.public int compareTo(Version version)
Version
objects.
compareTo
in interface Comparable<Version>
version
- the Version
to be compared.
Version
is equal to this Version
; a value
less than 0 if this Version
is less
than the Version
argument; and a
value greater than 0 if this Version
is greater than the Version
argument.public Version trimQualifier()
Version
instance, with the qualifier omitted.
public boolean equals(Object obj)
Version
objects for equality.
The result is true
if and only if the
argument is not null
and is a
Version
object that the major, minor,
micro, update, and qualifier the same as those of this
Version
.
equals
in class Object
obj
- the object to compare with.
public int hashCode()
Version
.
hashCode
in class Object
public String toString()
String
object representing this
Version
's value. The value is converted to the version
format and returned as a string.
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |