    001package com.hammurapi.common;
    002
    003import java.io.InputStream;
    004import java.net.URL;
    005
    006public class ClassLoaderResourceSet implements ResourceSet {
    007
    008        private ClassLoader classLoader;
    009        private String prefix;
    010
    011        public ClassLoaderResourceSet(ClassLoader classLoader, String prefix) {
    012                this.classLoader = classLoader;
    013                this.prefix = prefix;
    014        }
    015
    016        @Override
    017        public InputStream getResourceStream(String resourceName) {
    018                return classLoader.getResourceAsStream(prefix==null ? resourceName : prefix+resourceName);
    019        }
    020
    021        @Override
    022        public URL getResource(String resourceName) {
    023                return classLoader.getResource(prefix==null ? resourceName : prefix+resourceName);
    024        }
    025
    026}