public class VersionUtil extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
GENERIC_SNAPSHOT_PATTERN |
static String |
SNAPSHOT |
static Pattern |
TIMESTAMP_PATTERN |
static Pattern |
UNIQUE_SNAPSHOT_PATTERN |
private static Pattern |
VERSION_MEGA_PATTERN |
private static String[] |
versionPatterns
These are the version patterns found in the filenames of the various artifact's versions IDs.
|
Constructor and Description |
---|
VersionUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
getBaseVersion(String version) |
static String |
getReleaseVersion(String snapshotVersion)
Get the release version of the snapshot version.
|
static String |
getVersionFromGenericSnapshot(String version) |
static boolean |
isGenericSnapshot(String version) |
static boolean |
isSimpleVersionKeyword(String identifier)
Tests if the identifier is a known simple version keyword.
|
static boolean |
isSnapshot(String version) |
static boolean |
isUniqueSnapshot(String version) |
static boolean |
isVersion(String unknown)
Tests if the unknown string contains elements that identify it as a version string (or not).
|
private static final String[] versionPatterns
public static final String SNAPSHOT
public static final Pattern UNIQUE_SNAPSHOT_PATTERN
public static final Pattern TIMESTAMP_PATTERN
public static final Pattern GENERIC_SNAPSHOT_PATTERN
private static final Pattern VERSION_MEGA_PATTERN
public VersionUtil()
public static boolean isVersion(String unknown)
Tests if the unknown string contains elements that identify it as a version string (or not).
The algorithm tests each part of the string that is delimited by a '-' (dash) character. If 75% or more of the sections are identified as 'version' strings, the result is determined to be of a high probability to be version identifier string.
unknown
- the unknown string to test.public static boolean isSimpleVersionKeyword(String identifier)
Tests if the identifier is a known simple version keyword.
This method is different from isVersion(String)
in that it tests the whole input string in
one go as a simple identifier. (eg "alpha", "1.0", "beta", "debug", "latest", "rc#", etc...)
identifier
- the identifier to test.public static boolean isSnapshot(String version)
public static String getBaseVersion(String version)
public static String getReleaseVersion(String snapshotVersion)
Get the release version of the snapshot version.
If snapshot version is 1.0-SNAPSHOT, then release version would be 1.0 And if snapshot version is 1.0-20070113.163208-1.jar, then release version would still be 1.0
snapshotVersion
- snapshot versionpublic static boolean isUniqueSnapshot(String version)
public static boolean isGenericSnapshot(String version)
public static String getVersionFromGenericSnapshot(String version)
Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.