01: /*
02: * Copyright (C) 2003 Erik Swenson - erik@oreports.com
03: *
04: * This program is free software; you can redistribute it and/or modify it under the terms of the
05: * GNU General Public License as published by the Free Software Foundation; either version 2 of the
06: * License, or (at your option) any later version.
07: *
08: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
09: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
10: * the GNU General Public License for more details.
11: *
12: * You should have received a copy of the GNU General Public License along with this program; if
13: * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
14: * 02111-1307, USA.
15: *
16: */
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: private byte[] data;
26: private String type;
27: private String name;
28:
29: public ByteArrayDataSource(byte[] data, String type) {
30: this .type = type;
31: this .data = data;
32: }
33:
34: public InputStream getInputStream() throws IOException {
35: if (data == null)
36: throw new IOException("No data.");
37:
38: return new ByteArrayInputStream(data);
39: }
40:
41: public OutputStream getOutputStream() throws IOException {
42: throw new IOException("Not supported.");
43: }
44:
45: public String getContentType() {
46: return type;
47: }
48:
49: public void setContentType(String type) {
50: this .type = type;
51: }
52:
53: public String getName() {
54: return name;
55: }
56:
57: public void setName(String name) {
58: this.name = name;
59: }
60:
61: }
|