Version (Apache SIS 1.6 API) JavaScript is disabled on your browser.     Skip navigation links Overview Class Use Tree New Deprecated Index Search Help org.apache.sis.util org.apache.sis.util Version Contents  Description Immutability and thread safety Field Summary Constructor Summary Method Summary Field Details SIS Constructor Details Version(String) Method Details ofLibrary(Class) valueOf(int...) getMajor() getMinor() getRevision() compareTo(Version, int) compareTo(Version) equals(Object) length() charAt(int) subSequence(int, int) toString() hashCode() Hide sidebar  Show sidebar Class Version Object Version All Implemented Interfaces: Serializable, Char­Sequence, Comparable<Version> public class Version extends Object implements CharSequence, Comparable<Version>, Serializable 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: Serialized Form Field Summary Fields Modifier and Type Field Description static final Version SIS The version of this Apache SIS distribution. Constructor Summary Constructors Constructor Description Version(String version) Creates a new version object from the supplied string. Method Summary All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method Description char char­At(int index) Returns the char value at the specified index. int compare­To(Version other) Compares this version with another version object. int compare­To(Version other, int limit) Compares this version with another version object, up to the specified limit. boolean equals(Object other) Compares this version string with the specified object for equality. Comparable<?> get­Major() Returns the major version number. Comparable<?> get­Minor() Returns the minor version number. Comparable<?> get­Revision() Returns the revision number. int hash­Code() Returns a hash code value for this version. int length() Returns the length of the version string. static Optional<Version> of­Library(Class<?> member) Returns the version of the library that provides the given class. Char­Sequence sub­Sequence(int start, int end) Returns a new version string that is a subsequence of this sequence. String to­String() Returns the version string. static Version value­Of(int... components) Returns an instance for the given integer values. Methods inherited from class Object clone, finalize, get­Class, notify, notify­All, wait, wait, wait Methods inherited from interface CharSequence chars, code­Points, get­Chars, is­Empty Field Details SIS public static final Version SIS The version of this Apache SIS distribution. Constructor Details Version public Version(String version) Creates a new version object from the supplied string. Parameters: version - the version as a string. Method Details ofLibrary public static Optional<Version> ofLibrary(Class<?> member) Returns the version of the library that provides the given class. This method reads the "Implementation-Version" attribute of the META-INF/MANIFEST​.MF file of the JAR file that contains the given class. Parameters: member - any public class of the library for which to get the version. Returns: version declared by the library that provides the given class. Since: 1.5 See Also: Attributes​.Name​.IMPLEMENTATION_VERSION valueOf public static Version valueOf(int... components) Returns an instance for the given integer values. The components array 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 Version for the given numbers. Since: 0.4 getMajor public Comparable<?> getMajor() Returns the major version number. This method returns an Integer if possible, or a String otherwise. Returns: the major version number. getMinor public Comparable<?> getMinor() Returns the minor version number. This method returns an Integer if possible, or a String otherwise. If there is no minor version number, then this method returns null. Returns: the minor version number, or null if none. getRevision public Comparable<?> getRevision() Returns the revision number. This method returns an Integer if possible, or a String otherwise. If there is no revision number, then this method returns null. Returns: the revision number, or null if none. compareTo public int compareTo(Version other, int limit) Compares 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 as Integer object if possible, or as String otherwise. 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. compareTo public int compareTo(Version other) Compares this version with another version object. This method performs the same comparison than compare­To(Version, int) with no limit. Specified by: compare­To in 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. equals public boolean equals(Object other) Compares this version string with the specified object for equality. Two version are considered equal if compare­To(other) == 0. Overrides: equals in class Object Parameters: other - the object to compare with this version for equality. length public int length() Returns the length of the version string. Specified by: length in interface Char­Sequence charAt public char charAt(int index) Returns the char value at the specified index. Specified by: char­At in interface Char­Sequence subSequence public CharSequence subSequence(int start, int end) Returns a new version string that is a subsequence of this sequence. Specified by: sub­Sequence in interface Char­Sequence toString public String toString() Returns the version string. This is the string specified at construction time. Specified by: to­String in interface Char­Sequence Overrides: to­String in class Object hashCode public int hashCode() Returns a hash code value for this version. Overrides: hash­Code in class Object