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: CompoundResource.java,v 1.4 2007/04/01 13:43:17 taqua Exp $ 28: * ------------ 29: * (C) Copyright 2006, by Pentaho Corporation. 30: */ 31: 32: package org.jfree.resourceloader; 33: 34: /** 35: * Creation-Date: 08.04.2006, 14:08:13 36: * 37: * @author Thomas Morgner 38: */ 39: public class CompoundResource implements Resource 40: { 41: private ResourceKey source; 42: private DependencyCollector dependencies; 43: private Object product; 44: 45: public CompoundResource(final ResourceKey source, 46: final DependencyCollector dependencies, 47: final Object product) 48: { 49: if (source == null) 50: { 51: throw new NullPointerException("Source must not be null"); 52: } 53: if (dependencies == null) 54: { 55: throw new NullPointerException("Dependecies must be given."); 56: } 57: if (product == null) 58: { 59: throw new NullPointerException("Product must not be null"); 60: } 61: this.source = source; 62: try 63: { 64: this.dependencies = (DependencyCollector) dependencies.clone(); 65: } 66: catch (CloneNotSupportedException e) 67: { 68: throw new IllegalStateException 69: ("Clone not supported? This should not happen."); 70: } 71: this.product = product; 72: } 73: 74: public Object getResource() throws ResourceException 75: { 76: return product; 77: } 78: 79: public long getVersion(ResourceKey key) 80: { 81: return dependencies.getVersion(key); 82: } 83: 84: /** 85: * The primary source is also included in this set. The dependencies are given 86: * as ResourceKey objects. The keys itself do not hold any state information. 87: * <p/> 88: * The dependencies do not track deep dependencies. So if Resource A depends 89: * on Resource B which depends on Resource C, then A only knows about B, not 90: * C. 91: * 92: * @return 93: */ 94: public ResourceKey[] getDependencies() 95: { 96: return dependencies.getDependencies(); 97: } 98: 99: public ResourceKey getSource() 100: { 101: return source; 102: } 103: }