public class BrooklynVersionSyntax
extends java.lang.Object
major.minor.patch-qualifier
syntax,
with support for mapping to OSGi.
See tests for examples, VersionComparator
for more notes, and its tests for more examples.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DOT |
static java.lang.String |
GOOD_BROOKLYN_VERSION_REGEX |
static java.lang.String |
NUMBER |
static java.lang.String |
OSGI_TOKEN_CHARS |
static java.lang.String |
OSGI_TOKEN_REGEX |
static java.lang.String |
QUALIFIER |
static java.lang.String |
USABLE_REGEX |
static java.lang.String |
VALID_OSGI_VERSION_REGEX |
Constructor and Description |
---|
BrooklynVersionSyntax() |
Modifier and Type | Method and Description |
---|---|
static boolean |
equalAsOsgiVersions(java.lang.String v1,
java.lang.String v2)
Returns true if the given strings are equal when mapped according to
toValidOsgiVersion(String) |
static boolean |
isGoodBrooklynVersion(java.lang.String candidate)
True if the argument matches the Brooklyn version syntax,
MAJOR.MINOR.POINT-QUALIFIER or part thereof (not ending in a period though),
where the first three are whole numbers and the final piece is any valid OSGi token
(containing letters, numbers, _ and -; no full stops). |
static boolean |
isSnapshot(java.lang.String version) |
static boolean |
isUsableVersion(java.lang.String candidate)
For versions we currently work with any non-empty string that does not contain a ':' or whitespace.
|
static boolean |
isValidOsgiVersion(java.lang.String candidate)
True if the argument matches the OSGi version spec, of the form
MAJOR.MINOR.POINT.QUALIFIER or part thereof (not ending in a period though),
where the first three are whole numbers and the final piece is any valid OSGi token
(containing letters, numbers, _ and -; no full stops). |
static java.lang.String |
stripSnapshot(java.lang.String input)
Returns the version without "SNAPSHOT" (normally this will return the next expected release version).
|
static java.lang.String |
toGoodBrooklynVersion(java.lang.String input)
Creates a string satisfying
isGoodBrooklynVersion(String) based on the input. |
static java.lang.String |
toValidOsgiVersion(java.lang.String input)
Creates a string satisfying
isValidOsgiVersion(String) based on the input. |
static java.lang.String |
toValidOsgiVersionRange(java.lang.String input)
See
toValidOsgiVersion(String) , but takes a version range (in the standard OSGi format). |
public static final java.lang.String USABLE_REGEX
public static final java.lang.String DOT
public static final java.lang.String OSGI_TOKEN_CHARS
public static final java.lang.String OSGI_TOKEN_REGEX
public static final java.lang.String NUMBER
public static final java.lang.String QUALIFIER
public static final java.lang.String VALID_OSGI_VERSION_REGEX
public static final java.lang.String GOOD_BROOKLYN_VERSION_REGEX
public static boolean isUsableVersion(java.lang.String candidate)
isValidOsgiVersion(String)
.
In some places (eg bundles) the use of OSGi version syntax may be enforced.public static boolean isGoodBrooklynVersion(java.lang.String candidate)
MAJOR.MINOR.POINT-QUALIFIER
or part thereof (not ending in a period though),
where the first three are whole numbers and the final piece is any valid OSGi token
(containing letters, numbers, _ and -; no full stops).
See also isValidOsgiVersion(String)
and note this _requires_ a different separator to OSGi.public static boolean isValidOsgiVersion(java.lang.String candidate)
MAJOR.MINOR.POINT.QUALIFIER
or part thereof (not ending in a period though),
where the first three are whole numbers and the final piece is any valid OSGi token
(containing letters, numbers, _ and -; no full stops).
See also isGoodBrooklynVersion(String)
.public static java.lang.String toValidOsgiVersion(java.lang.String input)
isValidOsgiVersion(String)
based on the input.
For input satisfying isGoodBrooklynVersion(String)
the only change will be in the qualifer separator
(from "-" to ".") and making any "0" minor/patch token explicit (so "1-x" becomes "1.0.0.x"),
and the change can be reversed using toGoodBrooklynVersion(String)
(modulo insertion of "0"'s for minor/patch numbers if missing).
For input satisfying isValidOsgiVersion(String)
, the only change will be insertions of 0 for minor/patch.
Precise behaviour for other input is not guaranteed but callers can expect output which resembles the input,
with any major/minor/patch string at the front preserved and internal contiguous alphanumeric sequences preserved.public static java.lang.String toValidOsgiVersionRange(java.lang.String input)
toValidOsgiVersion(String)
, but takes a version range (in the standard OSGi format).public static java.lang.String toGoodBrooklynVersion(java.lang.String input)
isGoodBrooklynVersion(String)
based on the input.
For input satisfying isGoodBrooklynVersion(String)
the input will be returned unchanged.
For input satisfying isValidOsgiVersion(String)
the qualifier separator will be changed to "-",
and toValidOsgiVersion(String)
can be used to reverse the input (modulo insertion of "0"'s for minor/patch numbers if missing).
Precise behaviour for other input is not guaranteed but callers can expect output which resembles the input,
with any major/minor/patch string at the front preserved and internal contiguous alphanumeric sequences preserved.public static boolean equalAsOsgiVersions(java.lang.String v1, java.lang.String v2)
toValidOsgiVersion(String)
public static boolean isSnapshot(java.lang.String version)
public static java.lang.String stripSnapshot(java.lang.String input)