public abstract class Version extends Object implements Comparable<Version>, Serializable
Version
but attempts
to use it as such might render a UnsupportedOperationException
in case the
raw vector holds incompatible values. The method isOSGiCompatible()
can be used
to test.Modifier and Type | Field and Description |
---|---|
static Version |
emptyVersion
The version that is semantically less then all other versions.
|
static Version |
MAX_VERSION
The version that is semantically greater then all other versions.
|
static String |
RAW_PREFIX |
Constructor and Description |
---|
Version() |
Modifier and Type | Method and Description |
---|---|
static IVersionFormat |
compile(String format)
Compile a version format string into a compiled format..
|
static Version |
create(String version)
Parses a version identifier from the specified string.
|
static Version |
createOSGi(int major,
int minor,
int micro)
Creates an OSGi version identifier from the specified numerical components.
|
static Version |
createOSGi(int major,
int minor,
int micro,
String qualifier)
Creates an OSGi version identifier from the specified components.
|
abstract IVersionFormat |
getFormat()
Returns the optional format.
|
abstract String |
getOriginal()
Returns the
original part of the string for this version
or null if no such part was provided when the version was
created. |
abstract Comparable<?> |
getPad()
Returns the pad value used when comparing this versions to
versions that has a larger number of segments
|
abstract Comparable<?> |
getSegment(int index)
An element from the raw vector representation of this version.
|
abstract int |
getSegmentCount()
Returns the number of elements in the raw vector representation of this version.
|
abstract boolean |
isOSGiCompatible()
Checks if this version is in compliance with the OSGi version spec.
|
static Version |
parseVersion(String version)
Parses a version identifier from the specified string.
|
String |
toString() |
abstract void |
toString(StringBuffer sb)
Appends the string representation of this version onto the
sb StringBuffer. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
compareTo
public static final String RAW_PREFIX
public static final Version MAX_VERSION
public static final Version emptyVersion
public static IVersionFormat compile(String format) throws VersionFormatException
format
- The format to compile.VersionFormatException
- If the format could not be compiledpublic static Version create(String version)
version
- String representation of the version identifier. Leading
and trailing whitespace will be ignored.Version
object representing the version identifier
or null
if version
is null
or
an empty string.IllegalArgumentException
- If version
is improperly
formatted.public static Version createOSGi(int major, int minor, int micro)
The qualifier is set to the empty string.
major
- Major component of the version identifier.minor
- Minor component of the version identifier.micro
- Micro component of the version identifier.IllegalArgumentException
- If the numerical components are
negative.public static Version createOSGi(int major, int minor, int micro, String qualifier)
major
- Major component of the version identifier.minor
- Minor component of the version identifier.micro
- Micro component of the version identifier.qualifier
- Qualifier component of the version identifier. If
null
is specified, then the qualifier will be set to
the empty string.IllegalArgumentException
- If the numerical components are negative
or the qualifier string is invalid.public static Version parseVersion(String version)
null
.version
- String representation of the version identifier. Leading
and trailing whitespace will be ignored.Version
object representing the version
identifier. If version
is null
or
the empty string then the OSGi emptyVersion
will be
returned.IllegalArgumentException
- If version
is improperly
formatted.create(String)
public abstract IVersionFormat getFormat()
public abstract String getOriginal()
original
part of the string for this version
or null
if no such part was provided when the version was
created. An OSGi type version will always return the OSGi string representation.original
part of the version string or
null
if that part was missing.public abstract Comparable<?> getPad()
null
if not set.public abstract Comparable<?> getSegment(int index)
index
- The zero based index of the desired elementpublic abstract int getSegmentCount()
public abstract boolean isOSGiCompatible()
public abstract void toString(StringBuffer sb)
sb
StringBuffer.sb
- The buffer that will receive the version string
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.