1 11 package org.eclipse.update.core; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.update.internal.core.*; 16 17 32 public class VersionedIdentifier { 33 private String id; 34 private PluginVersionIdentifier version; 35 private static final String SEPARATOR = "_"; 37 46 public VersionedIdentifier(String id, String versionName) { 47 if (id == null || (id = id.trim()).equals("")) throw new IllegalArgumentException ( 49 NLS.bind(Messages.VersionedIdentifier_IdOrVersionNull, (new String [] { id, versionName }))); 50 this.id = id; 51 if (versionName != null){ 53 try { 55 this.version = new PluginVersionIdentifier(versionName); 56 } catch (RuntimeException e){ 57 UpdateCore.warn("Invalid Version:"+versionName,e); } 59 } 60 if (this.version==null) 61 version = new PluginVersionIdentifier(0, 0, 0); 62 } 63 64 70 public String getIdentifier() { 71 return id; 72 } 73 74 80 public PluginVersionIdentifier getVersion() { 81 return version; 82 } 83 84 92 public String toString() { 93 return id.equals("") ? "" : id + SEPARATOR + version.toString(); } 95 96 104 public boolean equals(Object obj) { 105 if (!(obj instanceof VersionedIdentifier)) 106 return false; 107 VersionedIdentifier vid = (VersionedIdentifier) obj; 108 if (!this.id.equals(vid.id)) 109 return false; 110 return this.version.equals(vid.version); 111 } 112 113 119 public int hashCode() { 120 return toString().hashCode(); 121 } 122 123 } 124 | Popular Tags |