Class jQuery.sap.VersionModule: jquery.sap.global


Represents a version consisting of major, minor, patch version and suffix, e.g. '1.2.7-SNAPSHOT'.
Since: 1.15.0.
Constructor Summary
new jQuery.sap.Version(vMajor, iMinor, iPatch, sSuffix)Returns a Version instance created from the given parameters.
Method Summary
compareTo()Compares this version with a given one.
getMajor()Returns the major version part of this version.
getMinor()Returns the minor version part of this version.
getPatch()Returns the patch (or micro) version part of this version.
getSuffix()Returns the version suffix of this version.
inRange(vMin, vMax)Checks whether this version is in the range of the given interval (start inclusive, end exclusive).
toString()Returns a string representation of this version.
Constructor Detail
new jQuery.sap.Version(vMajor, iMinor, iPatch, sSuffix)

Returns a Version instance created from the given parameters.

This function can either be called as a constructor (using new) or as a normal function. It always returns an immutable Version instance.

The parts of the version number (major, minor, patch, suffix) can be provided in several ways:

  • Version("1.2.3-SNAPSHOT") - as a dot-separated string. Any non-numerical char or a dot followed by a non-numerical char starts the suffix portion. Any missing major, minor or patch versions will be set to 0.
  • Version(1,2,3,"-SNAPSHOT") - as individual parameters. Major, minor and patch must be integer numbers or empty, suffix must be a string not starting with digits.
  • Version([1,2,3,"-SNAPSHOT"]) - as an array with the individual parts. The same type restrictions apply as before.
  • Version(otherVersion) - as a Version instance (cast operation). Returns the given instance instead of creating a new one.

To keep the code size small, this implementation mainly validates the single string variant. All other variants are only validated to some degree. It is the responsibility of the caller to provide proper parts.

Parameters:
int|string|any[]|jQuery.sap.VersionvMajorthe major part of the version (int) or any of the single parameter variants explained above.
intiMinorthe minor part of the version number
intiPatchthe patch part of the version number
stringsSuffixthe suffix part of the version number
Method Detail
compareTo(): int

Compares this version with a given one.

The version with which this version should be compared can be given as a jQuery.sap.Version instance, as a string (e.g. v.compareto("1.4.5")). Or major, minor, patch and suffix values can be given as separate parameters (e.g. v.compareTo(1, 4, 5)) or in an array (e.g. v.compareTo([1, 4, 5])).

Returns:
int0, if the given version is equal to this version, a negative value if the given other version is greater and a positive value otherwise
Since:
1.15.0
getMajor(): int
Returns the major version part of this version.
Returns:
intthe major version part of this version
Since:
1.15.0
getMinor(): int
Returns the minor version part of this version.
Returns:
intthe minor version part of this version
Since:
1.15.0
getPatch(): int
Returns the patch (or micro) version part of this version.
Returns:
intthe patch version part of this version
Since:
1.15.0
getSuffix(): string
Returns the version suffix of this version.
Returns:
stringthe version suffix of this version
Since:
1.15.0
inRange(vMin, vMax): boolean

Checks whether this version is in the range of the given interval (start inclusive, end exclusive).

The boundaries against which this version should be checked can be given as jQuery.sap.Version instances (e.g. v.inRange(v1, v2)), as strings (e.g. v.inRange("1.4", "2.7")) or as arrays (e.g. v.inRange([1,4], [2,7])).

Parameters:
string|any[]|jQuery.sap.VersionvMinthe start of the range (inclusive)
string|any[]|jQuery.sap.VersionvMaxthe end of the range (exclusive)
Returns:
booleantrue if this version is greater or equal to vMin and smaller than vMax, false otherwise.
Since:
1.15.0
toString(): string
Returns a string representation of this version.
Returns:
stringa string representation of this version.
Since:
1.15.0