This project has retired. For details please refer to its Attic page.
VersionUtil

org.apache.maven.archiva.common.utils
Class VersionUtil

Package class diagram package VersionUtil
java.lang.Object
  extended by org.apache.maven.archiva.common.utils.VersionUtil

public class VersionUtil
extends java.lang.Object

Version utility methods.


Field Summary
static java.util.regex.Pattern GENERIC_SNAPSHOT_PATTERN
           
static java.lang.String SNAPSHOT
           
static java.util.regex.Pattern TIMESTAMP_PATTERN
           
static java.util.regex.Pattern UNIQUE_SNAPSHOT_PATTERN
           
 
Constructor Summary
VersionUtil()
           
 
Method Summary
static java.lang.String getBaseVersion(java.lang.String version)
           
static java.lang.String getReleaseVersion(java.lang.String snapshotVersion)
           Get the release version of the snapshot version.
static boolean isGenericSnapshot(java.lang.String version)
           
static boolean isSimpleVersionKeyword(java.lang.String identifier)
           Tests if the identifier is a known simple version keyword.
static boolean isSnapshot(java.lang.String version)
           
static boolean isUniqueSnapshot(java.lang.String version)
           
static boolean isVersion(java.lang.String unknown)
           Tests if the unknown string contains elements that identify it as a version string (or not).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNAPSHOT

public static final java.lang.String SNAPSHOT
See Also:
Constant Field Values

UNIQUE_SNAPSHOT_PATTERN

public static final java.util.regex.Pattern UNIQUE_SNAPSHOT_PATTERN

TIMESTAMP_PATTERN

public static final java.util.regex.Pattern TIMESTAMP_PATTERN

GENERIC_SNAPSHOT_PATTERN

public static final java.util.regex.Pattern GENERIC_SNAPSHOT_PATTERN
Constructor Detail

VersionUtil

public VersionUtil()
Method Detail

isVersion

public static boolean isVersion(java.lang.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.

Parameters:
unknown - the unknown string to test.
Returns:
true if the unknown string is likely a version string.

isSimpleVersionKeyword

public static boolean isSimpleVersionKeyword(java.lang.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...)

Parameters:
identifier - the identifier to test.
Returns:
true if the unknown string is likely a version string.

isSnapshot

public static boolean isSnapshot(java.lang.String version)

getBaseVersion

public static java.lang.String getBaseVersion(java.lang.String version)

getReleaseVersion

public static java.lang.String getReleaseVersion(java.lang.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

Parameters:
snapshotVersion -
Returns:

isUniqueSnapshot

public static boolean isUniqueSnapshot(java.lang.String version)

isGenericSnapshot

public static boolean isGenericSnapshot(java.lang.String version)