*** empty log message ***
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/Version.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/Version.java deleted file mode 100644 index 67b486a..0000000 --- a/update/org.eclipse.update.core/src/org/eclipse/update/core/Version.java +++ /dev/null
@@ -1,282 +0,0 @@ -package org.eclipse.update.core; -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ - -import java.util.StringTokenizer; -import java.util.Vector; - -/** - * Version identifier. In its string representation, - * it consists of up to 4 tokens separated by decimal point. - * The first 3 tokens are positive integer numbers, the last token - * is an uninterpreted string. - * For example, the following are valid version identifiers - * (as strings): - * <ul> - * <li><code>0.0.0</code></li> - * <li><code>1.0.127564</code></li> - * <li><code>3.7.2.build-127J</code></li> - * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li> - * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li> - * </ul> - * </p> - * <p> - * The version identifier can be decomposed into a major, minor, - * service and qualifier components. A difference in the major - * component is interpreted as an incompatible version change. - * A difference in the minor (and not the major) component is - * interpreted as a compatible version change. The service - * level component is interpreted as a cumulative - * and compatible service update of the minor version component. - * The qualifier is not interpreted, other than in version - * comparisons. The qualifiers are compared using lexicographical - * string comparison. - * @see java.lang.String#compareTo - * </p> - * <p> - * Clients may instantiate; not intended to be subclassed by clients. - */ -public final class Version { - - private int major = 0; - private int minor = 0; - private int service = 0; - private String qualifier = null; - - private static final String SEPARATOR = "."; //$NON-NLS-1$ - - private Version() { - } - - /** - * Creates a version identifier from its components. - * - * @param major major component of the version identifier - * @param minor minor component of the version identifier - * @param service service update component of the version identifier - * @since 2.0 - */ - public Version(int major, int minor, int service) { - this(major, minor, service, null); - } - - /** - * Creates a version identifier from its components. - * - * @param major major component of the version identifier - * @param minor minor component of the version identifier - * @param service service update component of the version identifier - * @param qualifier component of the version identifier. Qualifier - * characters that are not a letter or a digit are replaced. - * @since 2.0 - */ - public Version(int major, int minor, int service, String qualifier) { - - if (major < 0) - major = 0; - if (minor < 0) - minor = 0; - if (service < 0) - service = 0; - if (qualifier == null) - qualifier = ""; //$NON-NLS-1$ - - this.major = major; - this.minor = minor; - this.service = service; - this.qualifier = verifyQualifier(qualifier); - } - - /** - * Creates a version identifier from the given string. - * The string represenation consists of up to 4 tokens - * separated by decimal point. - * For example, the following are valid version identifiers - * (as strings): - * <ul> - * <li><code>0.0.0</code></li> - * <li><code>1.0.127564</code></li> - * <li><code>3.7.2.build-127J</code></li> - * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li> - * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li> - * </ul> - * </p> - * - * @param versionId string representation of the version identifier. - * Qualifier characters that are not a letter or a digit are replaced. - * @since 2.0 - */ - public Version(String versionId) { - - // set up default values - this.major = 0; - this.minor = 0; - this.service = 0; - this.qualifier = ""; //$NON-NLS-1$ - - // parse string value - try { - if (versionId == null) - versionId = "0.0.0"; //$NON-NLS-1$ - - String s = versionId.trim(); - - StringTokenizer st = new StringTokenizer(s, SEPARATOR); - Vector elements = new Vector(4); - - while (st.hasMoreTokens()) { - elements.addElement(st.nextToken()); - } - - if (elements.size() >= 1) - this.major = (new Integer((String) elements.elementAt(0))).intValue(); - if (elements.size() >= 2) - this.minor = (new Integer((String) elements.elementAt(1))).intValue(); - if (elements.size() >= 3) - this.service = (new Integer((String) elements.elementAt(2))).intValue(); - if (elements.size() >= 4) - this.qualifier = verifyQualifier((String) elements.elementAt(3)); - - } catch (Exception e) { // use default version 0.0.0 - } - - } - - /** - * Compare two version identifiers for equality. Identifiers are - * equal if all of their components are equal. - * - * @param object an object to compare - * @return <code>true</code> if the objects are equal, - * <code>false</code> otherwise - * @since 2.0 - */ - public boolean equals(Object object) { - if (!(object instanceof Version)) - return false; - Version v = (Version) object; - return v.getMajorComponent() == major - && v.getMinorComponent() == minor - && v.getServiceComponent() == service - && v.getQualifierComponent().equals(qualifier); - } - - /** - * Returns the major (incompatible) component of this - * version identifier. - * - * @return the major version - * @since 2.0 - */ - public int getMajorComponent() { - return major; - } - - /** - * Returns the minor (compatible) component of this - * version identifier. - * - * @return the minor version - * @since 2.0 - */ - public int getMinorComponent() { - return minor; - } - - /** - * Returns the service level component of this - * version identifier. - * - * @return the service level - * @since 2.0 - */ - public int getServiceComponent() { - return service; - } - - /** - * Returns the qualifier component of this - * version identifier. - * - * @return the qualifier - * @since 2.0 - */ - public String getQualifierComponent() { - return qualifier; - } - - /** - * Compares two version identifiers for order using multi-decimal - * comparison for the first 3 components (major, minor, service) - * and lexicographic string comparison for the qualifier component - * - * @see java.lang.String#compareTo - * @param versionId the other version identifier - * @return -1 if this version is smaller than the argument - * version, 0 if it is equal and 1 if this version is greater than the argument - * version. - * @since 2.0 - */ - public int compare(Version id) { - - if (id == null) - return 1; - - if (major > id.getMajorComponent()) - return 1; - if (major < id.getMajorComponent()) - return -1; - if (minor > id.getMinorComponent()) - return 1; - if (minor < id.getMinorComponent()) - return -1; - if (service > id.getServiceComponent()) - return 1; - if (service < id.getServiceComponent()) - return -1; - return compareQualifiers(qualifier, id.getQualifierComponent()); - } - - /** - * Returns the string representation of this version identifier. - * The result satisfies - * <code>vi.equals(new PluginVersionIdentifier(vi.toString()))</code>. - * - * @return the string representation of this version identifier. The - * individual components of the version are separated by a period - * (M.m.s.Q). Qualifier characters other than letters and digits - * are replaced with a substitution character. - * @since 2.0 - */ - public String toString() { - String s = major + SEPARATOR + minor + SEPARATOR + service; - if (!qualifier.equals("")) //$NON-NLS-1$ - s += SEPARATOR + qualifier; - return s; - } - - private String verifyQualifier(String s) { - char[] chars = s.trim().toCharArray(); - boolean whitespace = false; - for (int i = 0; i < chars.length; i++) { - if (!Character.isLetterOrDigit(chars[i])) { - chars[i] = '-'; - whitespace = true; - } - } - return whitespace ? new String(chars) : s; - } - - private int compareQualifiers(String q1, String q2) { - int result = q1.compareTo(q2); - if (result < 0) - return -1; - else if (result > 0) - return 1; - else - return 0; - } - -} \ No newline at end of file
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/VersionedIdentifier.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/VersionedIdentifier.java index a33630f..4c4f9d1 100644 --- a/update/org.eclipse.update.core/src/org/eclipse/update/core/VersionedIdentifier.java +++ b/update/org.eclipse.update.core/src/org/eclipse/update/core/VersionedIdentifier.java
@@ -4,6 +4,7 @@ * All Rights Reserved. */ +import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.update.internal.core.Policy; /** @@ -17,7 +18,7 @@ */ public class VersionedIdentifier { private String id; - private Version version; + private PluginVersionIdentifier version; private static final String SEPARATOR = "_"; //$NON-NLS-1$ /** @@ -32,17 +33,17 @@ if (idWithVersion == null || (idWithVersion = idWithVersion.trim()).equals("")) { //$NON-NLS-1$ this.id = ""; //$NON-NLS-1$ - this.version = new Version(0, 0, 0); + this.version = new PluginVersionIdentifier(0, 0, 0); } int loc = idWithVersion.lastIndexOf(SEPARATOR); if (loc != -1) { id = idWithVersion.substring(0, loc); String versionName = idWithVersion.substring(loc + 1); - version = new Version(versionName); + version = new PluginVersionIdentifier(versionName); } else { this.id = ""; //$NON-NLS-1$ - version = new Version(0, 0, 0); + version = new PluginVersionIdentifier(0, 0, 0); } } @@ -63,7 +64,7 @@ Policy.bind("VersionedIdentifier.IdOrVersionNull", id, versionName)); //$NON-NLS-1$ this.id = id; - this.version = new Version(versionName); + this.version = new PluginVersionIdentifier(versionName); } /** @@ -82,7 +83,7 @@ * @return version * @since 2.0 */ - public Version getVersion() { + public PluginVersionIdentifier getVersion() { return version; }
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFileFactory.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFileFactory.java index b3a3884..767f237 100644 --- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFileFactory.java +++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFileFactory.java
@@ -36,7 +36,7 @@ return null; } - public Version getVersion() { + public PluginVersionIdentifier getVersion() { if (id != null) return id.getVersion(); return null;
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteLocal.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteLocal.java index 49adc2d..1537065 100644 --- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteLocal.java +++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteLocal.java
@@ -876,9 +876,9 @@ } /** - * compare 2 feature references + * compare two feature references * returns 0 if the feature are different - * returns 1 if the version of feature 1 is > version of feature 2 + * returns 1 if the version of feature 1 is greater than version of feature 2 * returns 2 if opposite */ private int compare( @@ -904,14 +904,14 @@ if (id1.getIdentifier() != null && id1.getIdentifier().equals(id2.getIdentifier())) { - Version version1 = id1.getVersion(); - Version version2 = id2.getVersion(); + PluginVersionIdentifier version1 = id1.getVersion(); + PluginVersionIdentifier version2 = id2.getVersion(); if (version1 != null) { - int result = (version1.compare(version2)); - if (result == -1) { - return 2; - } else { + boolean greaterOrEqual = (version1.isGreaterOrEqualTo(version2)); + if (greaterOrEqual) { return 1; + } else { + return 2; } } else { return 2;
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/security/JarVerificationResult.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/security/JarVerificationResult.java index f8528be..6a64c9a 100644 --- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/security/JarVerificationResult.java +++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/security/JarVerificationResult.java
@@ -6,6 +6,7 @@ import java.security.Principal; import java.security.cert.*; +import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; @@ -246,8 +247,7 @@ * */ private String dateString(Date date) { - SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, yyyyy"); - return formatter.format(date); + return DateFormat.getDateInstance().format(date); } /*