|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrebuild.util.Version
public final class Version
Represents the version number.
Constructor Summary | |
---|---|
Version()
Initializes a new instance of the Version class. |
|
Version(int major,
int minor)
Initializes a new instance of the Version class using the specified major and minor values. |
|
Version(int major,
int minor,
int build)
Initializes a new instance of the Version class using the specified major, minor, and build values. |
|
Version(int major,
int minor,
int build,
int revision)
Initializes a new instance of the Version class with the specified major, minor, build, and revision numbers. |
|
Version(java.lang.String version)
Initializes a new instance of the Version class using the specified string. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Compares the current Version object to a specified object and returns an indication of their relative values. |
int |
compareTo(Version o)
Compares the current Version object to a specified Version object and returns an indication of their relative values. |
boolean |
equals(java.lang.Object obj)
Returns a value indicating whether the current Version object is equal to a specified object. |
boolean |
equals(Version obj)
Returns a value indicating whether the current Version object and a specified Version object represent the same value. |
int |
getBuild()
Gets the value of the build component of the version number for the current Version object. |
int |
getMajor()
Gets the value of the major component of the version number for the current Version object. |
short |
getMajorRevision()
Gets the high 16 bits of the revision number. |
int |
getMinor()
Gets the value of the minor component of the version number for the current Version object. |
short |
getMinorRevision()
Gets the low 16 bits of the revision number. |
int |
getRevision()
Gets the value of the revision component of the version number for the current Version object. |
static boolean |
greaterThan(Version v1,
Version v2)
Determines whether the first specified Version object is greater than the second specified Version object. |
static boolean |
greaterThanOrEqual(Version v1,
Version v2)
Determines whether the first specified Version object is greater than or equal to the second specified Version object. |
int |
hashCode()
Returns a hash code for the current Version object. |
static boolean |
lessThan(Version v1,
Version v2)
Determines whether the first specified Version object is less than the second specified Version object. |
static boolean |
lessThanOrEqual(Version v1,
Version v2)
Determines whether the first specified Version object is less than or equal to the second specified Version object. |
java.lang.String |
toString()
Converts the value of the current Version object to its equivalent String representation. |
java.lang.String |
toString(int fieldCount)
Converts the value of the current Version object to its equivalent String representation. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Version()
Version
class.
public Version(java.lang.String version)
Version
class using the specified string.
version
- A string containing the major, minor, build, and revision numbers, where each number is delimited with a period character ('.').
java.lang.NullPointerException
- version
is null.
java.lang.IllegalArgumentException
- version
has fewer than two components or more than four componentspublic Version(int major, int minor)
Version
class using the specified major and minor values.
major
- The major version number.minor
- The minor version number.
java.lang.IllegalArgumentException
- major
or minor
is less than zero.public Version(int major, int minor, int build)
Version
class using the specified major, minor, and build values.
major
- The major version number.minor
- The minor version number.build
- The build number.
java.lang.IllegalArgumentException
- major
, minor
, or build
is less than zero.public Version(int major, int minor, int build, int revision)
Version
class with the specified major, minor, build, and revision numbers.
major
- The major version number.minor
- The minor version number.build
- The build number.revision
- The revision number.
java.lang.IllegalArgumentException
- major
, minor
, build
, or revision
is less than zero.Method Detail |
---|
public int compareTo(java.lang.Object o)
Version
object to a specified object and returns an indication of their relative values.
compareTo
in interface java.lang.Comparable
o
- An object to compare, or null.
Return Value | Description |
---|---|
Less than zero | The current Version object is a version before o . |
Zero | The current Version object is the same version as o . |
Greater than zero | The current Version object is a version subsequent to -or-
|
java.lang.IllegalArgumentException
- version
is not of type Version
.public int compareTo(Version o)
Version
object to a specified Version
object and returns an indication of their relative values.
o
- A Version
object to compare to the current Version
object, or null.
Return Value | Description |
---|---|
Less than zero | The current Version object is a version before o . |
Zero | The current Version object is the same version as o . |
Greater than zero | The current Version object is a version subsequent to -or-
|
public boolean equals(java.lang.Object obj)
Version
object is equal to a specified object.
equals
in class java.lang.Object
obj
- An object to compare with the current Version
object, or null
.
true
if the current Version
object and obj
are both Version
objects, and every component of the current Version
object matches the corresponding component of obj
; otherwise, false
.public boolean equals(Version obj)
Version
object and a specified Version
object represent the same value.
obj
- A Version
object to compare to the current Version
object, or null
.
true
if every component of the current Version
object matches the corresponding component of the obj
parameter; otherwise, false
.public int hashCode()
Version
object.
hashCode
in class java.lang.Object
public static boolean greaterThan(Version v1, Version v2)
Version
object is greater than the second specified Version
object.
v1
- The first Version
object.v2
- The second Version
object.
true
if v1
is greater than v2
; otherwise, false
.public static boolean greaterThanOrEqual(Version v1, Version v2)
Version
object is greater than or equal to the second specified Version
object.
v1
- The first Version
object.v2
- The second Version
object.
true
if v1
is greater than or equal to v2
; otherwise, false
.public static boolean lessThan(Version v1, Version v2)
Version
object is less than the second specified Version
object.
v1
- The first Version
object.v2
- The second Version
object.
true
if v1
is less than v2
; otherwise, false
.public static boolean lessThanOrEqual(Version v1, Version v2)
Version
object is less than or equal to the second specified Version
object.
v1
- The first Version
object.v2
- The second Version
object.
true
if v1
is less than or equal to v2
; otherwise, false
.public java.lang.String toString()
Version
object to its equivalent String
representation.
toString
in class java.lang.Object
String
representation of the values of the major, minor, build, and revision components of the current Version
object, as depicted in the following format. Each component is separated by a period character ('.'). Square brackets ('[' and ']') indicate a component that will not appear in the return value if the component is not defined: major.minor[.build[.revision]] For example, if you create a Version
object using the constructor Version(1,1)
, the returned string is "1.1". If you create a Version
object using the constructor Version(1,3,4,2)
, the returned string is "1.3.4.2".public java.lang.String toString(int fieldCount)
Version
object to its equivalent String
representation. A specified count indicates the number of components to return.
fieldCount
- The number of components to return. The fieldCount
ranges from 0 to 4.
The String
representation of the values of the major, minor, build, and revision components of the current Version
object, each separated by a period character ('.'). The fieldCount
parameter determines how many components are returned.
fieldCount | Return Value |
---|---|
0 | An empty string (""). |
1 | major |
2 | major.minor |
3 | major.minor.build |
4 | major.minor.build.revision |
For example, if you create Version
object using the constructor Version(1,3,5)
, ToString(2)
returns "1.3" and ToString(4)
throws an exception.
java.lang.IllegalArgumentException
- fieldCount
is less than 0, or more than 4.
-or-
fieldCount
is more than the number of components defined in the current Version
object.
public int getBuild()
Version
object.
public int getMajor()
Version
object.
public short getMajorRevision()
public int getMinor()
Version
object.
public short getMinorRevision()
public int getRevision()
Version
object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |