Class 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 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 interface java.lang.Comparable<Version>
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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.
      • implementationVersion

        public static Version implementationVersion()
        Decode the implementation version found in our jar file manifest into a Version object.
        Returns:
        Our version.