KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > tools > OPP > srcgen > streamfactory > ArrayOutputStreamFactory


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: ArrayOutputStreamFactory.java,v 1.2 2003/11/07 21:34:22 per_nyfelt Exp $
8
package org.ozoneDB.tools.OPP.srcgen.streamfactory;
9
10 import java.io.OutputStream JavaDoc;
11 import java.io.IOException JavaDoc;
12 import java.io.ByteArrayOutputStream JavaDoc;
13 import java.util.*;
14
15
16 /**
17  *
18  * @author Joakim Ohlrogge
19  */

20 public class ArrayOutputStreamFactory implements OutputStreamFactory {
21     private List arrayStreams = new LinkedList();
22
23     public List getArrays() {
24         List arrays = new ArrayList(arrayStreams.size());
25         for (Iterator iterator = arrayStreams.iterator(); iterator.hasNext();) {
26             ByteArrayOutputStream JavaDoc stream = (ByteArrayOutputStream JavaDoc) iterator.next();
27             arrays.add(stream.toByteArray());
28         }
29         return arrays;
30     }
31
32     public void clear() {
33         arrayStreams.clear();
34     }
35
36     public OutputStream JavaDoc newInstance(String JavaDoc className) throws IOException JavaDoc {
37
38         ByteArrayOutputStream JavaDoc os = new ByteArrayOutputStream JavaDoc();
39         arrayStreams.add(os);
40         return os;
41     }
42 }
43
Popular Tags