org.apache.archiva.common.utils
Class VersionUtil

java.lang.Object
  extended by org.apache.archiva.common.utils.VersionUtil

public class VersionUtil
extends Object

Version utility methods.


Field Summary
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 Summary
VersionUtil()
           
 
Method Summary
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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionPatterns

private static final String[] versionPatterns
These are the version patterns found in the filenames of the various artifact's versions IDs. These patterns are all tackling lowercase version IDs.


SNAPSHOT

public static final String SNAPSHOT
See Also:
Constant Field Values

UNIQUE_SNAPSHOT_PATTERN

public static final Pattern UNIQUE_SNAPSHOT_PATTERN

TIMESTAMP_PATTERN

public static final Pattern TIMESTAMP_PATTERN

GENERIC_SNAPSHOT_PATTERN

public static final Pattern GENERIC_SNAPSHOT_PATTERN

VERSION_MEGA_PATTERN

private static final Pattern VERSION_MEGA_PATTERN
Constructor Detail

VersionUtil

public VersionUtil()
Method Detail

isVersion

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.

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

isSimpleVersionKeyword

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...)

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

isSnapshot

public static boolean isSnapshot(String version)

getBaseVersion

public static String getBaseVersion(String version)

getReleaseVersion

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

Parameters:
snapshotVersion -
Returns:

isUniqueSnapshot

public static boolean isUniqueSnapshot(String version)

isGenericSnapshot

public static boolean isGenericSnapshot(String version)

getVersionFromGenericSnapshot

public static String getVersionFromGenericSnapshot(String version)


Copyright © 2006-2013 The Apache Software Foundation. All Rights Reserved.