Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004, 2008 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.internal.loader;
public class FilteredSourcePackage extends SingleSourcePackage {
	private static final char ALL = '*';
	public FilteredSourcePackage(String nameBundleLoaderProxy supplierString includesString excludesString[] friends) {
		super(namesupplier);
		if (includes != null)
			this. = ManifestElement.getArrayFromList(includes);
		if (excludes != null)
			this. = ManifestElement.getArrayFromList(excludes);
		this. = friends;
	}
	public boolean isFriend(String symbolicName) {
		if ( == null)
			return true;
		for (int i = 0; i < .i++)
			if ([i].equals(symbolicName))
				return true;
		return false;
	}
	public URL getResource(String name) {
		if (isFiltered(namegetId()))
			return null;
		return super.getResource(name);
	}
	public Enumeration getResources(String name) {
		if (isFiltered(namegetId()))
			return null;
		return super.getResources(name);
	}
	public Class loadClass(String namethrows ClassNotFoundException {
		if (isFiltered(namegetId()))
			return null;
		return super.loadClass(name);
	}
	private boolean isFiltered(String nameString pkgName) {
		String lastName = getName(namepkgName);
		return !isIncluded(lastName) || isExcluded(lastName);
	}
	private String getName(String nameString pkgName) {
		if (!..equals(pkgName) && pkgName.length() + 1 <= name.length())
			return name.substring(pkgName.length() + 1);
		return name;
	}
	private boolean isIncluded(String name) {
		if ( == null)
			return true;
		return isInList(name);
	}
	private boolean isExcluded(String name) {
		if ( == null)
			return false;
		return isInList(name);
	}
	private boolean isInList(String nameString[] list) {
		for (int i = 0; i < list.lengthi++) {
			int len = list[i].length();
			if (len == 0)
				continue;
			if (list[i].charAt(0) ==  && len == 1)
				return true// handles "*" wild card
			if (list[i].charAt(len - 1) == )
				if (name.startsWith(list[i].substring(0, len - 1)))
					return true;
			if (name.equals(list[i]))
				return true;
		}
		return false;
	}
New to GrepCode? Check out our FAQ X