package com.hammurapi.common;

import java.io.InputStream;
import java.net.URL;

public class ClassLoaderResourceSet implements ResourceSet {
	
	private ClassLoader classLoader;
	private String prefix;

	public ClassLoaderResourceSet(ClassLoader classLoader, String prefix) {
		this.classLoader = classLoader;
		this.prefix = prefix;
	}

	@Override
	public InputStream getResourceStream(String resourceName) {
		return classLoader.getResourceAsStream(prefix==null ? resourceName : prefix+resourceName);
	}

	@Override
	public URL getResource(String resourceName) {
		return classLoader.getResource(prefix==null ? resourceName : prefix+resourceName);
	}

}
