Package com.xmlmind.util
Class VersionNumber
- java.lang.Object
-
- com.xmlmind.util.VersionNumber
-
- All Implemented Interfaces:
Comparable<VersionNumber>
public final class VersionNumber extends Object implements Comparable<VersionNumber>
Structured version numbers similar to those used for the JavaTM runtime (example: 1.5.0_06).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVersionNumber.LevelTypeType of the release: alpha, beta, release candidate or patch.
-
Field Summary
Fields Modifier and Type Field Description intlevelAlpha, beta, release candidate or patch level.VersionNumber.LevelTypelevelTypeType of the release: alpha, beta, release candidate or patch.intmajorMajor version number.intmicroMicro version number.static VersionNumberMIN_VERSION_NUMBERMinimal version number: 0.0.0-alpha00.intminorMinor version number.
-
Constructor Summary
Constructors Constructor Description VersionNumber()Constructs a minimal version number: 0.0.0-alpha00.VersionNumber(int major, int minor, int micro)Constructs version number major.minor.micro.VersionNumber(int major, int minor, int micro, int patch)Constructs version number major.minor.micro_patch.VersionNumber(int major, int minor, int micro, VersionNumber.LevelType levelType, int level)Constructs version number major.minor.micro (-alpha|-beta|-rc|_)level.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(VersionNumber other)booleanequals(Object other)static VersionNumberfromString(String s)Equivalent tofromString(s, false).static VersionNumberfromString(String s, boolean lenient)Parses specified string as a version number.inthashCode()VersionNumbernoLevel()Returns a copy of this VersionNumber but with all level info (alpha, beta, release candidate, patch) cleared.static voidparse(String s, VersionNumber version)Parses specified string and returns the result in the specified version number object.StringtoString()Returns a string having the following format: major.minor.micro if this version number is not an alpha, beta, Release candidate or patch release.
-
-
-
Field Detail
-
major
public int major
Major version number. Example: 1 in 1.5.0_06.
-
minor
public int minor
Minor version number. Example: 5 in 1.5.0_06.
-
micro
public int micro
Micro version number. Example: 0 in 1.5.0_06.
-
levelType
public VersionNumber.LevelType levelType
Type of the release: alpha, beta, release candidate or patch.
-
level
public int level
Alpha, beta, release candidate or patch level. Example: 6 in 1.5.0_06.
-
MIN_VERSION_NUMBER
public static final VersionNumber MIN_VERSION_NUMBER
Minimal version number: 0.0.0-alpha00.
-
-
Constructor Detail
-
VersionNumber
public VersionNumber()
Constructs a minimal version number: 0.0.0-alpha00.- See Also:
MIN_VERSION_NUMBER
-
VersionNumber
public VersionNumber(int major, int minor, int micro)Constructs version number major.minor.micro. Example: 1.1.2.
-
VersionNumber
public VersionNumber(int major, int minor, int micro, int patch)Constructs version number major.minor.micro_patch. Example: 3.1.0_01.
-
VersionNumber
public VersionNumber(int major, int minor, int micro, VersionNumber.LevelType levelType, int level)Constructs version number major.minor.micro (-alpha|-beta|-rc|_)level. Example: 3.1.0-beta02.
-
-
Method Detail
-
fromString
public static VersionNumber fromString(String s)
Equivalent tofromString(s, false).
-
fromString
public static VersionNumber fromString(String s, boolean lenient)
Parses specified string as a version number.- Parameters:
s- string to be parsedlenient- iftrue, any string starting with "\d+(\.\d+)?(\.\d+)?(_\d+)?" will be successfully parsed.- Returns:
- parsed version number or
nullif it cannot be parsed.
-
parse
public static void parse(String s, VersionNumber version) throws IllegalArgumentException
Parses specified string and returns the result in the specified version number object.- Parameters:
s- string to be parsedversion- the parsed version number is stored in this object- Throws:
IllegalArgumentException- ifscannot be parsed
-
noLevel
public VersionNumber noLevel()
Returns a copy of this VersionNumber but with all level info (alpha, beta, release candidate, patch) cleared.
-
compareTo
public int compareTo(VersionNumber other)
- Specified by:
compareToin interfaceComparable<VersionNumber>
-
toString
public String toString()
Returns a string having the following format: major.minor.micro if this version number is not an alpha, beta, Release candidate or patch release. Otherwise, returns a string having the following format: major.minor.micro (-alpha|-beta|-rc|_)level.
-
-