1 11 package org.eclipse.osgi.internal.resolver; 12 13 import org.eclipse.osgi.service.resolver.BundleDelta; 14 import org.eclipse.osgi.service.resolver.BundleDescription; 15 16 public class BundleDeltaImpl implements BundleDelta { 17 18 private BundleDescription bundleDescription; 19 private int type; 20 21 public BundleDeltaImpl(BundleDescription bundleDescription) { 22 this(bundleDescription, 0); 23 } 24 25 public BundleDeltaImpl(BundleDescription bundleDescription, int type) { 26 this.bundleDescription = bundleDescription; 27 this.type = type; 28 } 29 30 public BundleDescription getBundle() { 31 return bundleDescription; 32 } 33 34 public int getType() { 35 return type; 36 } 37 38 protected void setBundle(BundleDescription bundleDescription) { 39 this.bundleDescription = bundleDescription; 40 } 41 42 protected void setType(int type) { 43 this.type = type; 44 } 45 46 public String toString() { 47 return bundleDescription.getSymbolicName() + '_' + bundleDescription.getVersion() + " (" + toTypeString(type) + ")"; } 49 50 private static String toTypeString(int type) { 51 StringBuffer typeStr = new StringBuffer (); 52 if ((type & BundleDelta.ADDED) != 0) 53 typeStr.append("ADDED,"); if ((type & BundleDelta.REMOVED) != 0) 55 typeStr.append("REMOVED,"); if ((type & BundleDelta.RESOLVED) != 0) 57 typeStr.append("RESOLVED,"); if ((type & BundleDelta.UNRESOLVED) != 0) 59 typeStr.append("UNRESOLVED,"); if ((type & BundleDelta.LINKAGE_CHANGED) != 0) 61 typeStr.append("LINKAGE_CHANGED,"); if ((type & BundleDelta.UPDATED) != 0) 63 typeStr.append("UPDATED,"); if ((type & BundleDelta.REMOVAL_PENDING) != 0) 65 typeStr.append("REMOVAL_PENDING,"); if ((type & BundleDelta.REMOVAL_COMPLETE) != 0) 67 typeStr.append("REMOVAL_COMPLETE,"); if (typeStr.length() > 0) 69 typeStr.deleteCharAt(typeStr.length() - 1); 70 return typeStr.toString(); 71 } 72 73 public int compareTo(Object obj) { 74 long idcomp = getBundle().getBundleId() - ((BundleDelta) obj).getBundle().getBundleId(); 75 return (idcomp < 0L) ? -1 : ((idcomp > 0L) ? 1 : 0); 76 } 77 } 78 | Popular Tags |