Package org.apache.pivot.util
Class Version
- java.lang.Object
-
- org.apache.pivot.util.Version
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Version>
public class Version extends java.lang.Object implements java.lang.Comparable<Version>, java.io.Serializable
Represents a version number. Version numbers are defined as:major.minor.maintenance_update
for example, "JDK 1.6.0_10".
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Version
ZERO_VERSION
The default version object (0, 0, 0, 0).
-
Constructor Summary
Constructors Constructor Description Version(int major, int minor, int maintenance, long update)
Construct a version given all the numeric values.Version(int major, int minor, int maintenance, long update, java.lang.String buildString)
Construct a version given all the information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Version version)
static Version
decode(java.lang.String string)
Decode a string into the version parts.boolean
equals(java.lang.Object object)
short
getMaintenanceRevision()
short
getMajorRevision()
short
getMinorRevision()
long
getNumber()
long
getUpdateRevision()
int
hashCode()
static Version
implementationVersion()
Decode the implementation version found in our jar file manifest into aVersion
object.static Version
safelyDecode(java.lang.String versionString)
Added so that any unexpected version string formats that might cause an error will not also cause the application to fail to start.java.lang.String
simpleToString()
java.lang.String
toString()
-
-
-
Field Detail
-
ZERO_VERSION
public static final Version ZERO_VERSION
The default version object (0, 0, 0, 0).
-
-
Constructor Detail
-
Version
public Version(int major, int minor, int maintenance, long update)
Construct a version given all the numeric values.- Parameters:
major
- The new major version.minor
- The new minor version.maintenance
- The new maintenance version.update
- The new update version.
-
Version
public Version(int major, int minor, int maintenance, long update, java.lang.String buildString)
Construct a version given all the information.- Parameters:
major
- The new major version.minor
- The new minor version.maintenance
- The new maintenance version.update
- The new update version.buildString
- The new build string.
-
-
Method Detail
-
getMajorRevision
public short getMajorRevision()
- Returns:
- The major version number.
-
getMinorRevision
public short getMinorRevision()
- Returns:
- The minor version number.
-
getMaintenanceRevision
public short getMaintenanceRevision()
- Returns:
- The maintenance version number.
-
getUpdateRevision
public long getUpdateRevision()
- Returns:
- The update revision number.
-
getNumber
public long getNumber()
- Returns:
- A composite value, consisting of all the numeric components shifted into parts of a long.
-
compareTo
public int compareTo(Version version)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Version>
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
simpleToString
public java.lang.String simpleToString()
- Returns:
- A three-component string with "major.minor.maintenance".
-
decode
public static Version decode(java.lang.String string)
Decode a string into the version parts.- Parameters:
string
- The input string in a format recognizable as a version string.- Returns:
- The new version object constructed from the string information.
-
safelyDecode
public static Version safelyDecode(java.lang.String versionString)
Added so that any unexpected version string formats that might cause an error will not also cause the application to fail to start.- Parameters:
versionString
- A potential version string to parse/decode.- Returns:
- The parsed version information (if possible), or an empty version (that will look like: "0.0.0_00") if there was a parsing problem of any kind.
-
-