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: ResourceData.java 2777 2007-05-04 14:21:56Z taqua $ 28: * ------------ 29: * (C) Copyright 2006, by Pentaho Corporation. 30: */ 31: package org.jfree.resourceloader; 32: 33: import java.io.InputStream; 34: 35: /** 36: * A resource data object encapsulates the raw data of an resource at a given 37: * point in the past. 38: * 39: * Any change to the resource increases the version number. Version numbers 40: * are not needed to be checked regulary, but must be checked on each call to 41: * 'getVersion()'. 42: * 43: * This definitly does *not* solve the problem of concurrent modifications; if 44: * you need to be sure that the resource has not been altered between the last 45: * call to 'getVersion' and 'getResource..' external locking mechanism have to 46: * be implemented. 47: * 48: * @author Thomas Morgner 49: */ 50: public interface ResourceData 51: { 52: public static final String CONTENT_LENGTH = "content-length"; 53: public static final String CONTENT_TYPE = "content-type"; 54: public static final String FILENAME = "filename"; 55: 56: public InputStream getResourceAsStream(ResourceManager caller) throws ResourceLoadingException; 57: 58: /** 59: * This is dangerous, especially if the resource is large. 60: * 61: * @param caller 62: * @return 63: * @throws ResourceLoadingException 64: */ 65: public byte[] getResource(ResourceManager caller) throws ResourceLoadingException; 66: 67: /** 68: * Tries to read data into the given byte-array. 69: * 70: * @param caller 71: * @param target 72: * @param offset 73: * @param length 74: * @return the number of bytes read or -1 if no more data can be read. 75: * @throws ResourceLoadingException 76: */ 77: public int getResource(ResourceManager caller, byte[] target, int offset, int length) 78: throws ResourceLoadingException; 79: 80: public Object getAttribute (String key); 81: public ResourceKey getKey(); 82: public long getVersion(ResourceManager caller) 83: throws ResourceLoadingException; 84: 85: }