public class Version extends Object implements CharSequence, Comparable<Version>, Serializable
major.minor.revision
, but are not
required to. For example an EPSG database version is "6.11.2"
. The separator character is
the dot.
This class provides convenience methods for fetching the major, minor and reversion numbers, and for performing comparaisons.
GeoTools.getVersion()
,
Serialized FormConstructor and Description |
---|
Version(String version)
Creates a new version object from the supplied string.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index)
Returns the
char value at the specified index. |
int |
compareTo(Version other)
Compares this version with an other version object.
|
int |
compareTo(Version other,
int limit)
Compares this version with an other version object, up to the specified limit.
|
boolean |
equals(Object other)
Compare this version string with the specified object for equality.
|
Comparable<?> |
getComponent(int index)
Returns the specified components of this version string.
|
Comparable<?> |
getMajor()
Returns the major version number.
|
Comparable<?> |
getMinor()
Returns the minor version number.
|
Comparable<?> |
getRevision()
Returns the revision number.
|
int |
hashCode()
Returns a hash code value for this version.
|
int |
length()
Returns the length of the version string.
|
CharSequence |
subSequence(int start,
int end)
Returns a new version string that is a subsequence of this sequence.
|
String |
toString()
Returns the version string.
|
chars, codePoints
public Version(String version)
version
- The version as a string.public Comparable<?> getMajor()
Integer
if possible, or a
String
otherwise.public Comparable<?> getMinor()
Integer
if possible, or a
String
otherwise. If there is no minor version number, then this method returns
null
.null
if none.public Comparable<?> getRevision()
Integer
if possible, or a String
otherwise. If there is no revision number, then this method returns null
.null
if none.public Comparable<?> getComponent(int index)
major.minor.revision
form, index 0 stands for the major version number, 1 stands for the
minor version number and 2 stands for the revision number.
The return value is an Integer
if the component is parsable as an integer, or a
String
otherwise. If there is no component at the specified index, then this method
returns null
.
index
- The index of the component to fetch.null
if none.IndexOutOfBoundsException
- if index
is negative.public int compareTo(Version other, int limit)
Integer
object if possible, or as String
otherwise.other
- The other version object to compare with.limit
- The maximum number of components to compare.public int compareTo(Version other)
compareTo(Version, int)
with no limit.compareTo
in interface Comparable<Version>
other
- The other version object to compare with.public boolean equals(Object other)
compareTo(other) == 0
.public int length()
length
in interface CharSequence
public char charAt(int index)
char
value at the specified index.charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public String toString()
toString
in interface CharSequence
toString
in class Object
Copyright © 1996–2019 Geotools. All rights reserved.