Package org.apache.sis.util
Class Version
Object
Version
- All Implemented Interfaces:
- Serializable,- CharSequence,- Comparable<Version>
Holds a version number as a sequence of strings separated by either a dot or a dash.
 The first three strings, usually numbers, are called respectively major,
 minor and revision.
 For example, a version code such as 
"6.11.2" will have major number 6, minor
 number 11 and revision number 2. Alternatively, a version code such as "3.18-SNAPSHOT"
 will have major version number 3, minor version number 18 and revision string "SNAPSHOT".
 This class provides methods for performing comparisons of Version objects where major,
 minor and revision parts are compared as numbers when possible, or as strings otherwise.
Immutability and thread safety
This class is immutable and thus inherently thread-safe. Subclasses may or may not be immutable, at implementation choice. But implementers are encouraged to make sure that subclasses remain immutable for more predictable behavior.- Since:
- 0.3
- See Also:
Defined in the sis-utility module
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncharcharAt(int index) Returns thecharvalue at the specified index.intcompareTo(Version other) Compares this version with another version object.intcompareTo(Version other, int limit) Compares this version with another version object, up to the specified limit.booleanCompare this version string with the specified object for equality.Comparable<?>Returns the major version number.Comparable<?>Returns the minor version number.Comparable<?>Returns the revision number.intReturns a hash code value for this version.intlength()Returns the length of the version string.subSequence(int start, int end) Returns a new version string that is a subsequence of this sequence.Returns the version string.static VersionvalueOf(int... components) Returns an instance for the given integer values.Methods inherited from class Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface CharSequencechars, codePoints, isEmpty
- 
Field Details- 
SISThe version of this Apache SIS distribution.
 
- 
- 
Constructor Details- 
VersionCreates a new version object from the supplied string.- Parameters:
- version- the version as a string.
 
 
- 
- 
Method Details- 
valueOfReturns an instance for the given integer values. Thecomponentsarray must contain at least 1 element, where:- The first element is the major number.
- The second element (if any) is the minor number.
- The third element (if any) is the revision number.
- Other elements (if any) will be appended to the string value.
 - Parameters:
- components- the major number, optionally followed by minor, revision or other numbers.
- Returns:
- a new or existing instance of Versionfor the given numbers.
- Since:
- 0.4
 
- 
getMajorReturns the major version number. This method returns anIntegerif possible, or aStringotherwise.- Returns:
- the major version number.
 
- 
getMinorReturns the minor version number. This method returns anIntegerif possible, or aStringotherwise. If there is no minor version number, then this method returnsnull.- Returns:
- the minor version number, or nullif none.
 
- 
getRevisionReturns the revision number. This method returns anIntegerif possible, or aStringotherwise. If there is no revision number, then this method returnsnull.- Returns:
- the revision number, or nullif none.
 
- 
compareToCompares this version with another version object, up to the specified limit. A limit of 1 compares only the major version number. A limit of 2 compares the major and minor version numbers, etc. The comparisons are performed asIntegerobject if possible, or asStringotherwise.- Parameters:
- other- the other version object to compare with.
- limit- the maximum number of components to compare.
- Returns:
- a negative value if this version is lower than the supplied version, a positive value if it is higher, or 0 if they are equal.
 
- 
compareToCompares this version with another version object. This method performs the same comparison thancompareTo(Version, int)with no limit.- Specified by:
- compareToin interface- Comparable<Version>
- Parameters:
- other- the other version object to compare with.
- Returns:
- a negative value if this version is lower than the supplied version, a positive value if it is higher, or 0 if they are equal.
 
- 
equalsCompare this version string with the specified object for equality. Two version are considered equal ifcompareTo(other) == 0.
- 
lengthpublic int length()Returns the length of the version string.- Specified by:
- lengthin interface- CharSequence
 
- 
charAtpublic char charAt(int index) Returns thecharvalue at the specified index.- Specified by:
- charAtin interface- CharSequence
 
- 
subSequenceReturns a new version string that is a subsequence of this sequence.- Specified by:
- subSequencein interface- CharSequence
 
- 
toStringReturns the version string. This is the string specified at construction time.- Specified by:
- toStringin interface- CharSequence
- Overrides:
- toStringin class- Object
 
- 
hashCodepublic int hashCode()Returns a hash code value for this version.
 
-