001/** 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 * 006 */ 007package org.fcrepo.migration.foxml; 008 009import java.io.IOException; 010import java.io.InputStream; 011import java.net.URL; 012 013/** 014 * A CachedContent implementation that exposes content stored 015 * at a resolvable URL. 016 * @author mdurbin 017 */ 018public class URLCachedContent implements CachedContent { 019 020 private URL url; 021 022 private URLFetcher fetcher; 023 024 /** 025 * url cached content. 026 * @param url the url 027 * @param fetcher the fetcher 028 */ 029 public URLCachedContent(final URL url, final URLFetcher fetcher) { 030 this.fetcher = fetcher; 031 this.url = url; 032 } 033 /** 034 * get URL. 035 * @return the url 036 */ 037 public URL getURL() { 038 return url; 039 } 040 041 @Override 042 public InputStream getInputStream() throws IOException { 043 return fetcher.getContentAtUrl(url); 044 } 045}