Java Utililty Methods Regex Version Validate

List of utility methods to do Regex Version Validate

Description

The list of methods to do Regex Version Validate are organized into topic(s).

Method

IntegerparseVersion(final String versionString)
parse Version
final String PERIOD_REGEX = "\\.";
final int SIG_DIGITS = 100;
String[] versionSections = versionString.split(PERIOD_REGEX);
if (versionSections.length == 3) {
    final String BUILDINFO_REGEX = "([0-9]*)(.*)"; 
    final Pattern pattern = Pattern.compile(BUILDINFO_REGEX);
    final Matcher matcher = pattern.matcher(versionSections[2]);
    if (matcher.find() && matcher.groupCount() >= 2) {
...
VersionparseVersion(String s, String groupId, String artifactId)
parse Version
if (s != null && (s = s.trim()).length() > 0) {
    String[] parts = V_SEP.split(s);
    return new Version(parseVersionPart(parts[0]), (parts.length > 1) ? parseVersionPart(parts[1]) : 0,
            (parts.length > 2) ? parseVersionPart(parts[2]) : 0, (parts.length > 3) ? parts[3] : null,
            groupId, artifactId);
return null;
int[]parseVersion(String version, int defaultRevision)
parse Version
Matcher m = VERSION_REGEX.matcher(version);
if (!m.matches()) {
    throw new IllegalArgumentException("invalid version string: \"" + version + "\"");
String revision = m.group(4);
return new int[] { Integer.parseInt(m.group(1)), 
        Integer.parseInt(m.group(2)), 
        revision == null ? defaultRevision : Integer.parseInt(revision), };
...
booleanparseVersion(String version, String currentVersion)
parse Version
if (version == null || version.length() == 0)
    return false;
Matcher versionMatcher = VERSION_PATTERN.matcher(version);
boolean isValid = false;
while (versionMatcher.find()) {
    boolean isIntervalValid = true;
    String interval = versionMatcher.group(1);
    Matcher intervalMatcher = INTERVAL_PATTERN.matcher(interval);
...
String[]parseVersionNamespace(String versionNamespace)
parse Version Namespace
Matcher matcher = MODEL_URI_PATTERN.matcher(versionNamespace);
Matcher oldMatcher = OLD_MODEL_URI_PATTERN.matcher(versionNamespace);
if (matcher.matches()) {
    return new String[] { DATAMODEL_PREFIX, matcher.group(1), matcher.group(2), matcher.group(3),
            matcher.group(4) };
} else if (oldMatcher.matches()) {
    return new String[] { PREFIX, oldMatcher.group(1), oldMatcher.group(2), oldMatcher.group(3),
            oldMatcher.group(4) };
...