1 16 package org.outerj.daisy.frontend.components.daisysource; 17 18 import org.apache.excalibur.source.Source; 19 import org.apache.excalibur.source.SourceNotFoundException; 20 import org.apache.excalibur.source.SourceValidity; 21 import org.apache.excalibur.source.impl.validity.TimeStampValidity; 22 import org.outerj.daisy.publisher.BlobInfo; 23 import org.outerj.daisy.repository.RepositoryException; 24 25 import java.io.InputStream ; 26 import java.io.IOException ; 27 28 31 public class DaisySource implements Source { 32 private BlobInfo blobInfo; 33 private String url; 34 35 public DaisySource(BlobInfo blobInfo, String url) { 36 this.blobInfo = blobInfo; 37 this.url = url; 38 } 39 40 public boolean exists() { 41 return true; 42 } 43 44 public InputStream getInputStream() throws IOException , SourceNotFoundException { 45 try { 46 return blobInfo.getInputStream(); 47 } catch (RepositoryException e) { 48 throw new IOException ("Error in daisy source: " + e.toString()); 49 } 50 } 51 52 public String getURI() { 53 return url; 54 } 55 56 public String getScheme() { 57 return "daisy"; 58 } 59 60 public SourceValidity getValidity() { 61 return new TimeStampValidity(getLastModified()); 62 } 63 64 public void refresh() { 65 } 66 67 public String getMimeType() { 68 return blobInfo.getMimeType(); 69 } 70 71 public long getContentLength() { 72 return blobInfo.getSize(); 73 } 74 75 public long getLastModified() { 76 return blobInfo.getLastModified().getTime(); 77 } 78 79 public void dispose() { 80 this.blobInfo.dispose(); 81 } 82 } 83 | Popular Tags |