1 17 package org.apache.servicemix.jbi.util; 18 19 import java.io.IOException ; 20 import java.io.InputStream ; 21 import java.io.OutputStream ; 22 23 import javax.activation.DataSource ; 24 25 30 public class StreamDataSource implements DataSource { 31 32 private InputStream in; 33 private String contentType; 34 private String name; 35 36 public StreamDataSource(InputStream in) { 37 this(in, null, null); 38 } 39 40 public StreamDataSource(InputStream in, String contentType) { 41 this(in, contentType, null); 42 } 43 44 public StreamDataSource(InputStream in, String contentType, String name) { 45 this.in = in; 46 this.contentType = contentType; 47 this.name = name; 48 } 49 50 public InputStream getInputStream() throws IOException { 51 if (in == null) throw new IOException ("no data"); 52 return in; 53 } 54 55 public OutputStream getOutputStream() throws IOException { 56 throw new IOException ("getOutputStream() not supported"); 57 } 58 59 public String getContentType() { 60 return contentType; 61 } 62 63 public String getName() { 64 return name; 65 } 66 67 public void setName(String name) { 68 this.name = name; 69 } 70 71 public void setContentType(String contentType) { 72 this.contentType = contentType; 73 } 74 75 } 76 | Popular Tags |