Frames | No Frames |
1: /** 2: * ================================================ 3: * LibLoader : a free Java resource loading library 4: * ================================================ 5: * 6: * Project Info: http://reporting.pentaho.org/libloader/ 7: * 8: * (C) Copyright 2006, by Pentaho Corporation and Contributors. 9: * 10: * This library is free software; you can redistribute it and/or modify it under the terms 11: * of the GNU Lesser General Public License as published by the Free Software Foundation; 12: * either version 2.1 of the License, or (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16: * See the GNU Lesser General Public License for more details. 17: * 18: * You should have received a copy of the GNU Lesser General Public License along with this 19: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20: * Boston, MA 02111-1307, USA. 21: * 22: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 23: * in the United States and other countries.] 24: * 25: * 26: * ------------ 27: * $Id: ResourceLoader.java,v 1.5 2007/04/01 13:43:17 taqua Exp $ 28: * ------------ 29: * (C) Copyright 2006, by Pentaho Corporation. 30: */ 31: package org.jfree.resourceloader; 32: 33: import java.util.Map; 34: import java.net.URL; 35: 36: /** 37: * A resource loader knows how to get binary rawdata from a location specified 38: * by an resource key. A resource key is a wrapper around any kind of data that 39: * is suitable to identify a resource location. The resource key can also hold 40: * configuration data for the factory. 41: * 42: * If the storage system is hierarchical, a new resource key can be derived from 43: * a given path-string. 44: * 45: * @author Thomas Morgner 46: */ 47: public interface ResourceLoader 48: { 49: /** 50: * Checks, whether this resource loader implementation was responsible for 51: * creating this key. 52: * 53: * @param key 54: * @return 55: */ 56: public boolean isSupportedKey (ResourceKey key); 57: 58: /** 59: * Creates a new resource key from the given object and the factory keys. 60: * 61: * @param value 62: * @param factoryKeys 63: * @return the created key or null, if the format was not recognized. 64: * @throws ResourceKeyCreationException if creating the key failed. 65: */ 66: public ResourceKey createKey (Object value, 67: Map factoryKeys) 68: throws ResourceKeyCreationException; 69: 70: /** 71: * Derives a new resource key from the given key. If neither a path nor new 72: * factory-keys are given, the parent key is returned. 73: * 74: * @param parent the parent 75: * @param path the derived path (can be null). 76: * @param factoryKeys the optional factory keys (can be null). 77: * @return the derived key. 78: * @throws ResourceKeyCreationException if the key cannot be derived for any 79: * reason. 80: */ 81: public ResourceKey deriveKey (ResourceKey parent, 82: String path, 83: Map factoryKeys) 84: throws ResourceKeyCreationException; 85: 86: /** 87: * Loads the binary data represented by this key. 88: * 89: * @param key 90: * @return 91: * @throws ResourceLoadingException 92: */ 93: public ResourceData load (ResourceKey key) 94: throws ResourceLoadingException; 95: 96: public void setResourceManager (ResourceManager manager); 97: 98: public URL toURL (ResourceKey key); 99: }