KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > io > CloneInputStream


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
19 import java.io.InputStream JavaDoc;
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 JavaDoc {
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     /**
48      * {@inheritDoc}
49      */

50     @Override JavaDoc
51     public int read() throws IOException JavaDoc {
52         return model.read(id);
53     }
54
55     
56     /**
57      * {@inheritDoc}
58      */

59     @Override JavaDoc
60     public int read(byte[] arg0, int arg1, int arg2) throws IOException JavaDoc {
61         return model.read(id, arg0, arg1, arg2);
62     }
63
64     
65     /**
66      * {@inheritDoc}
67      */

68     @Override JavaDoc
69     public int available() throws IOException JavaDoc {
70         return model.available();
71     }
72
73     /**
74      * {@inheritDoc}
75      */

76     @Override JavaDoc
77     public void close() throws IOException JavaDoc {
78         if (model != null) {
79             model.close(id);
80             model = null;
81         }
82     }
83 }
84
Popular Tags