01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.io;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20:
21: /**
22: * The CloneInputStream from a master.
23: *
24: * @see CloneStreamMaster
25: *
26: * @author Timo Stich <tstich@users.sourceforge.net>
27: */
28: public class CloneInputStream extends InputStream {
29: private CloneStreamMaster model;
30:
31: private int id;
32:
33: /**
34: * Constructs a new CloneInputStream.
35: *
36: * @see CloneStreamMaster#getClone()
37: *
38: * @param master
39: */
40: protected CloneInputStream(CloneStreamMaster model, int id) {
41: super ();
42: this .model = model;
43: this .id = id;
44: }
45:
46: /**
47: * {@inheritDoc}
48: */
49: @Override
50: public int read() throws IOException {
51: return model.read(id);
52: }
53:
54: /**
55: * {@inheritDoc}
56: */
57: @Override
58: public int read(byte[] arg0, int arg1, int arg2) throws IOException {
59: return model.read(id, arg0, arg1, arg2);
60: }
61:
62: /**
63: * {@inheritDoc}
64: */
65: @Override
66: public int available() throws IOException {
67: return model.available();
68: }
69:
70: /**
71: * {@inheritDoc}
72: */
73: @Override
74: public void close() throws IOException {
75: if (model != null) {
76: model.close(id);
77: model = null;
78: }
79: }
80: }
|