org.jitsi.utils.version.AbstractVersionService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jitsi-utils Show documentation
Show all versions of jitsi-utils Show documentation
A set of basic utilities used in Jitsi projects
/*
* Copyright @ 2015 - present, 8x8 Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.utils.version;
import java.util.regex.*;
/**
* Base implementation of VersionService that uses major, minor
* and nightly build id fields for versioning purposes.
*
* @author Emil Ivov
* @author Pawel Domas
*/
public abstract class AbstractVersionService
implements VersionService
{
/**
* The pattern that will parse strings to version object.
*/
private static final Pattern PARSE_VERSION_STRING_PATTERN =
Pattern.compile("(\\d+)\\.(\\d+)\\.([\\d\\.]+)");
/**
* Returns a Version instance corresponding to the version
* string.
*
* @param version a version String that we have obtained by calling a
* Version.toString() method.
* @return the Version object corresponding to the
* version string. Or null if we cannot parse the string.
*/
public Version parseVersionString(String version)
{
Matcher matcher = PARSE_VERSION_STRING_PATTERN.matcher(version);
if (matcher.matches() && matcher.groupCount() == 3)
{
return createVersionImpl(
Integer.parseInt(matcher.group(1)),
Integer.parseInt(matcher.group(2)),
matcher.group(3));
}
return null;
}
/**
* Creates new Version instance specific to current implementation.
* @param majorVersion major version number.
* @param minorVersion minor version number.
* @param nightlyBuildId nightly build id string.
* @return new Version instance specific to current implementation
* for given major, minor and nightly build id parameters.
*/
protected abstract Version createVersionImpl(int majorVersion,
int minorVersion,
String nightlyBuildId);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy