1 11 package org.eclipse.osgi.framework.internal.core; 12 13 import java.io.IOException ; 14 import java.net.URL ; 15 import java.util.Enumeration ; 16 import org.eclipse.osgi.framework.util.KeyedElement; 17 18 public abstract class PackageSource implements KeyedElement { 19 protected String id; 20 21 public PackageSource(String id) { 22 this.id = id.intern(); 23 } 24 25 public String getId() { 26 return id; 27 } 28 29 public abstract SingleSourcePackage[] getSuppliers(); 30 31 public boolean compare(KeyedElement other) { 32 return id.equals(((PackageSource) other).getId()); 33 } 34 35 public int getKeyHashCode() { 36 return id.hashCode(); 37 } 38 39 public Object getKey() { 40 return id; 41 } 42 43 public boolean isNullSource() { 44 return false; 45 } 46 47 public boolean isFriend(String symbolicName) { 48 return true; 49 } 50 51 public abstract Class loadClass(String name) throws ClassNotFoundException ; 52 public abstract URL getResource(String name); 53 public abstract Enumeration getResources(String name) throws IOException ; 54 55 public boolean hasCommonSource(PackageSource other) { 59 if (other == null) 60 return false; 61 if (this == other) 62 return true; 63 SingleSourcePackage[] suppliers1 = getSuppliers(); 64 SingleSourcePackage[] suppliers2 = other.getSuppliers(); 65 if (suppliers1 == null || suppliers2 == null) 66 return false; 67 for (int i = 0; i < suppliers1.length; i++) 70 for (int j = 0; j < suppliers2.length; j++) 71 if (suppliers2[j].equals(suppliers1[i])) 72 return true; 73 return false; 74 } 75 } 76 | Popular Tags |