1 17 18 package org.efs.openreports.util; 19 20 import java.io.*; 21 22 import javax.activation.DataSource ; 23 24 public class ByteArrayDataSource implements DataSource 25 { 26 private byte[] data; 27 private String type; 28 private String name; 29 30 public ByteArrayDataSource(byte[] data, String type) 31 { 32 this.type = type; 33 this.data = data; 34 } 35 36 public InputStream getInputStream() throws IOException 37 { 38 if (data == null) 39 throw new IOException("No data."); 40 41 return new ByteArrayInputStream(data); 42 } 43 44 public OutputStream getOutputStream() throws IOException 45 { 46 throw new IOException("Not supported."); 47 } 48 49 public String getContentType() 50 { 51 return type; 52 } 53 54 public void setContentType(String type) 55 { 56 this.type = type; 57 } 58 59 public String getName() 60 { 61 return name; 62 } 63 64 public void setName(String name) 65 { 66 this.name = name; 67 } 68 69 } 70 | Popular Tags |