Skip to main content
summaryrefslogtreecommitdiffstats
blob: e5de392b570326da7fbc168a97d09b79007a3a7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
 * Copyright (c) 2003, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.osgi.framework.internal.core;

import java.net.URL;
import java.util.Enumeration;

public class SingleSourcePackage extends PackageSource {
	BundleLoaderProxy supplier;
	// this is the index of the ExportPackageDescription 
	// into the list of exported packages of the supplier
	// a valid of -1 indicates it is unknown or does not matter
	protected int expid;
	public SingleSourcePackage(String id, int expid, BundleLoaderProxy supplier) {
		super(id);
		this.expid = expid;
		this.supplier = supplier;
	}

	public SingleSourcePackage[] getSuppliers() {
		return new SingleSourcePackage[] {this};
	}

	public String toString() {
		return id + " -> " + supplier; //$NON-NLS-1$
	}

	public Class loadClass(String name) throws ClassNotFoundException {
		return supplier.getBundleLoader().findLocalClass(name);
	}

	public URL getResource(String name) {
		return supplier.getBundleLoader().findLocalResource(name);
	}

	public Enumeration getResources(String name) {
		return supplier.getBundleLoader().findLocalResources(name);
	}

	public boolean equals(Object source) {
		if (this == source)
			return true;
		if (!(source instanceof SingleSourcePackage))
			return false;
		SingleSourcePackage singleSource = (SingleSourcePackage) source;
		return supplier == singleSource.supplier && expid == singleSource.expid;
	}
}

Back to the top