KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > internal > core > SingleSourcePackage


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.osgi.framework.internal.core;
12
13 import java.net.URL JavaDoc;
14 import java.util.Enumeration JavaDoc;
15
16 public class SingleSourcePackage extends PackageSource {
17     BundleLoaderProxy supplier;
18     // this is the index of the ExportPackageDescription
19
// into the list of exported packages of the supplier
20
// a valid of -1 indicates it is unknown or does not matter
21
protected int expid;
22     public SingleSourcePackage(String JavaDoc id, int expid, BundleLoaderProxy supplier) {
23         super(id);
24         this.expid = expid;
25         this.supplier = supplier;
26     }
27
28     public SingleSourcePackage[] getSuppliers() {
29         return new SingleSourcePackage[] {this};
30     }
31
32     public String JavaDoc toString() {
33         return id + " -> " + supplier; //$NON-NLS-1$
34
}
35
36     public Class JavaDoc loadClass(String JavaDoc name) throws ClassNotFoundException JavaDoc {
37         return supplier.getBundleLoader().findLocalClass(name);
38     }
39
40     public URL JavaDoc getResource(String JavaDoc name) {
41         return supplier.getBundleLoader().findLocalResource(name);
42     }
43
44     public Enumeration JavaDoc getResources(String JavaDoc name) {
45         return supplier.getBundleLoader().findLocalResources(name);
46     }
47
48     public boolean equals(Object JavaDoc source) {
49         if (this == source)
50             return true;
51         if (!(source instanceof SingleSourcePackage))
52             return false;
53         SingleSourcePackage singleSource = (SingleSourcePackage) source;
54         return supplier == singleSource.supplier && expid == singleSource.expid;
55     }
56 }
57
Popular Tags