1 16 package org.outerj.daisy.publisher.serverimpl; 17 18 import org.outerj.daisy.publisher.BlobInfo; 19 import org.outerj.daisy.repository.Part; 20 import org.outerj.daisy.repository.RepositoryException; 21 22 import java.util.Date ; 23 import java.io.InputStream ; 24 25 public class BlobInfoImpl implements BlobInfo { 26 private Part part; 27 private Date lastModified; 28 private boolean disposed = false; 29 private static final String DISPOSED_MESSAGE = "This BlobInfo object has been disposed."; 30 31 public BlobInfoImpl(Part part, Date lastModified) { 32 this.part = part; 33 this.lastModified = lastModified; 34 } 35 36 public Date getLastModified() { 37 if (disposed) 38 throw new RuntimeException (DISPOSED_MESSAGE); 39 return lastModified; 40 } 41 42 public String getMimeType() { 43 if (disposed) 44 throw new RuntimeException (DISPOSED_MESSAGE); 45 return part.getMimeType(); 46 } 47 48 public long getSize() { 49 if (disposed) 50 throw new RuntimeException (DISPOSED_MESSAGE); 51 return part.getSize(); 52 } 53 54 public InputStream getInputStream() throws RepositoryException { 55 if (disposed) 56 throw new RuntimeException (DISPOSED_MESSAGE); 57 return part.getDataStream(); 58 } 59 60 public void dispose() { 61 this.disposed = true; 62 this.part = null; 63 this.lastModified = null; 64 } 65 } 66 | Popular Tags |