01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: BLOBOutputStream.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.blob;
10:
11: import org.ozoneDB.*;
12: import java.io.*;
13:
14: /**
15: * The output stream of ozone BLOBs. Every write operations will call
16: * the underlaying BLOBContainer. Therefore BLOBStreams should never be used
17: * without buffering/caching. This can be done by using the BLOBStream together
18: * with a BufferedStream.
19: *
20: *
21: * @author <a href="http://www.softwarebuero.de/">SMB</a>
22: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
23: */
24: public class BLOBOutputStream extends OutputStream implements
25: Serializable {
26:
27: BLOBContainer container;
28: int index = 0;
29:
30: public BLOBOutputStream(BLOBContainer _container) {
31: container = _container;
32: }
33:
34: public void write(byte[] b) throws IOException {
35: write(b, 0, b.length);
36: }
37:
38: public void write(byte[] b, int off, int len) throws IOException {
39: try {
40: container.write(index, b, off, len);
41: index += len;
42: } catch (Exception e) {
43: e.printStackTrace();
44: throw new IOException(e.getMessage());
45: }
46: }
47:
48: public void write(int b) throws IOException {
49: byte[] bb = new byte[1];
50: bb[0] = (byte) b;
51: write(bb, 0, 1);
52: }
53:
54: public void flush() throws IOException {
55: }
56:
57: public void close() throws IOException {
58: }
59: }
|