Modifies VersionImpl and VersionServiceImpl to use shared abstract classes from libjitsi(updates libjitsi bundle).

cusax-fix 4973
paweldomas 12 years ago
parent 5501e53360
commit 26cc488505

@ -26,6 +26,7 @@ Export-Package: javax.media,
org.jitsi.service.protocol.event,
org.jitsi.service.resources,
org.jitsi.service.version,
org.jitsi.service.version.util,
org.jitsi.util,
org.jitsi.util.event,
org.jitsi.util.swing,

@ -9,13 +9,13 @@
import net.java.sip.communicator.util.*;
import org.jitsi.service.resources.*;
import org.jitsi.service.version.*;
import org.jitsi.service.version.util.*;
/**
* A static implementation of the Version interface.
*/
public class VersionImpl
implements Version
extends AbstractVersion
{
/**
* The version major of the current Jitsi version. In an
@ -25,11 +25,6 @@ public class VersionImpl
*/
public static final int VERSION_MAJOR = 2;
/**
* The version major field. Default value is VERSION_MAJOR.
*/
private int versionMajor = VERSION_MAJOR;
/**
* The version major of the current Jitsi version. In an
* example 2.3.1 version string 2 is the version major. The version major
@ -38,11 +33,6 @@ public class VersionImpl
*/
public static final int VERSION_MINOR = 3;
/**
* The version minor field. Default value is VERSION_MINOR.
*/
private int versionMinor = VERSION_MINOR;
/**
* Indicates whether this version represents a prerelease (i.e. a
* non-complete release like an alpha, beta or release candidate version).
@ -61,11 +51,6 @@ public class VersionImpl
*/
public static final boolean IS_NIGHTLY_BUILD = true;
/**
* The nightly build id field. Default value is NightlyBuildID.BUILD_ID.
*/
private String nightlyBuildID = NightlyBuildID.BUILD_ID;
/**
* The default name of this application.
*/
@ -86,7 +71,9 @@ public class VersionImpl
* Creates version object with default (current) values.
*/
private VersionImpl()
{}
{
super(VERSION_MAJOR, VERSION_MINOR, NightlyBuildID.BUILD_ID);
}
/**
* Creates version object with custom major, minor and nightly build id.
@ -96,38 +83,10 @@ private VersionImpl()
* @param nightlyBuildID the nightly build id value for new version object.
*/
private VersionImpl(int majorVersion,
int minorVersion,
String nightlyBuildID)
int minorVersion,
String nightlyBuildID)
{
this.versionMajor = majorVersion;
this.versionMinor = minorVersion;
this.nightlyBuildID = nightlyBuildID;
}
/**
* Returns the version major of the current Jitsi version. In an
* example 2.3.1 version string 2 is the version major. The version major
* number changes when a relatively extensive set of new features and
* possibly rearchitecturing have been applied to the Jitsi.
*
* @return the version major String.
*/
public int getVersionMajor()
{
return versionMajor;
}
/**
* Returns the version minor of the current Jitsi version. In an
* example 2.3.1 version string 3 is the version minor. The version minor
* number changes after adding enhancements and possibly new features to a
* given Jitsi version.
*
* @return the version minor integer.
*/
public int getVersionMinor()
{
return versionMinor;
super(majorVersion, minorVersion, nightlyBuildID);
}
/**
@ -142,22 +101,6 @@ public boolean isNightly()
return IS_NIGHTLY_BUILD;
}
/**
* If this is a nightly build, returns the build identifies (e.g.
* nightly-2007.12.07-06.45.17). If this is not a nightly build Jitsi
* version, the method returns null.
*
* @return a String containing a nightly build identifier or null if this is
* a release version and therefore not a nightly build
*/
public String getNightlyBuildID()
{
if(!isNightly())
return null;
return nightlyBuildID;
}
/**
* Indicates whether this version represents a prerelease (i.e. a
* non-complete release like an alpha, beta or release candidate version).
@ -182,133 +125,6 @@ public String getPreReleaseID()
return PRE_RELEASE_ID;
}
/**
* Compares another <tt>Version</tt> object to this one and returns a
* negative, zero or a positive integer if this version instance represents
* respectively an earlier, same, or later version as the one indicated
* by the <tt>version</tt> parameter.
*
* @param version the <tt>Version</tt> instance that we'd like to compare
* to this one.
*
* @return a negative integer, zero, or a positive integer as this object
* represents a version that is earlier, same, or more recent than the one
* referenced by the <tt>version</tt> parameter.
*/
public int compareTo(Version version)
{
if(version == null)
return -1;
if(getVersionMajor() != version.getVersionMajor())
return getVersionMajor() - version.getVersionMajor();
if(getVersionMinor() != version.getVersionMinor())
return getVersionMinor() - version.getVersionMinor();
try
{
return compareNightlyBuildIDByComponents(
getNightlyBuildID(), version.getNightlyBuildID());
}
catch(Throwable th)
{
// if parsing fails will continue with lexicographically compare
}
return getNightlyBuildID().compareTo(version.getNightlyBuildID());
}
/**
* As normally nightly.build.id is in the form of <build-num> or
* <build-num>.<revision> we will first try to compare them by splitting
* the id in components and compare them one by one asnumbers
* @param v1 the first version to compare
* @param v2 the second version to compare
* @return a negative integer, zero, or a positive integer as the first
* parameter <tt>v1</tt> represents a version that is earlier, same,
* or more recent than the one referenced by the <tt>v2</tt> parameter.
*/
private static int compareNightlyBuildIDByComponents(String v1, String v2)
{
String[] s1 = v1.split("\\.");
String[] s2 = v2.split("\\.");
int len = Math.max(s1.length, s2.length);
for(int i = 0; i < len; i++)
{
int n1 = 0;
int n2 = 0;
if(i < s1.length)
n1 = Integer.valueOf(s1[i]);
if(i < s2.length)
n2 = Integer.valueOf(s2[i]);
if(n1 == n2)
continue;
else
return n1 - n2;
}
// will happen if boths version has identical numbers in
// their components (even if one of them is longer, has more components)
return 0;
}
/**
* Compares the <tt>version</tt> parameter to this version and returns true
* if and only if both reference the same Jitsi version and
* false otherwise.
*
* @param version the version instance that we'd like to compare with this
* one.
* @return true if and only the version param references the same
* Jitsi version as this Version instance and false otherwise.
*/
@Override
public boolean equals(Object version)
{
//simply compare the version strings
return toString().equals( (version == null)
? "null"
: version.toString());
}
/**
* Returns a String representation of this Version instance in the generic
* form of major.minor[.nightly.build.id]. If you'd just like to obtain the
* version of Jitsi so that you could display it (e.g. in a Help->About
* dialog) then all you need is calling this method.
*
* @return a major.minor[.build] String containing the complete
* Jitsi version.
*/
@Override
public String toString()
{
StringBuffer versionStringBuff = new StringBuffer();
versionStringBuff.append(Integer.toString(getVersionMajor()));
versionStringBuff.append(".");
versionStringBuff.append(Integer.toString(getVersionMinor()));
if(isPreRelease())
{
versionStringBuff.append("-");
versionStringBuff.append(getPreReleaseID());
}
if(isNightly())
{
versionStringBuff.append(".");
versionStringBuff.append(getNightlyBuildID());
}
return versionStringBuff.toString();
}
/**
* Returns the VersionImpl instance describing the current version of
* Jitsi.

@ -7,8 +7,7 @@
package net.java.sip.communicator.impl.version;
import org.jitsi.service.version.*;
import java.util.regex.*;
import org.jitsi.service.version.util.*;
/**
* The version service keeps track of the Jitsi version that we are
@ -21,14 +20,8 @@
* @author Emil Ivov
*/
public class VersionServiceImpl
implements VersionService
extends AbstractVersionService
{
/**
* The pattern that will parse strings to version object.
*/
private static final Pattern PARSE_VERSION_STRING_PATTERN =
Pattern.compile("(\\d+)\\.(\\d+)\\.([\\d\\.]+)");
/**
* Returns a <tt>Version</tt> object containing version details of the
* Jitsi version that we're currently running.
@ -42,26 +35,14 @@ public Version getCurrentVersion()
}
/**
* Returns a Version instance corresponding to the <tt>version</tt>
* string.
*
* @param version a version String that we have obtained by calling a
* <tt>Version.toString()</tt> method.
* @return the <tt>Version</tt> object corresponding to the
* <tt>version</tt> string. Or null if we cannot parse the string.
* {@inheritDoc}
*/
public Version parseVersionString(String version)
@Override
protected Version createVersionImpl(int majorVersion,
int minorVersion,
String nightlyBuildId)
{
Matcher matcher = PARSE_VERSION_STRING_PATTERN.matcher(version);
if(matcher.matches() && matcher.groupCount() == 3)
{
return VersionImpl.customVersion(
Integer.parseInt(matcher.group(1)),
Integer.parseInt(matcher.group(2)),
matcher.group(3));
}
return null;
return VersionImpl.customVersion(
majorVersion, minorVersion, nightlyBuildId);
}
}

@ -6,6 +6,6 @@ Bundle-Version: 0.0.1
Bundle-SymbolicName: net.java.sip.communicator.version
Import-Package: org.osgi.framework,
org.jitsi.service.configuration,
org.jitsi.service.version,
org.jitsi.service.version, org.jitsi.service.version.util,
org.jitsi.service.resources, net.java.sip.communicator.service.resources,
net.java.sip.communicator.util

Loading…
Cancel
Save