KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javadoc > httpfs > HTTPFileInputStream


1 /**************************************************************************
2  *
3  * The contents of this file are subject to the terms of the Common Development
4  * and Distribution License (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8  * or http://www.netbeans.org/cddl.txt.
9  *
10  * When distributing Covered Code, include this CDDL Header Notice in each file
11  * and include the License file at http://www.netbeans.org/cddl.txt.
12  * If applicable, add the following below the CDDL Header, with the fields
13  * enclosed by brackets [] replaced by your own identifying information:
14  * "Portions Copyrighted [year] [name of copyright owner]"
15  *
16  * The Original Software is the HTTP Javadoc Filesystem.
17  * The Initial Developer of the Original Software is Jeffrey A. Keyser.
18  * Portions created by Jeffrey A. Keyser are Copyright (C) 2000-2001.
19  * All Rights Reserved.
20  *
21  * Contributor(s): Jeffrey A. Keyser.
22  *
23  **************************************************************************/

24
25
26 package org.netbeans.modules.javadoc.httpfs;
27
28
29 import java.io.InputStream JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.net.HttpURLConnection JavaDoc;
32
33
34 /**
35  * <p>InputStream for files read from the "HTTP Javadoc Viewer" file system. This
36  * class merely wraps the InputStream object that comes from the HttpURLConnection
37  * object, and calls the HttpURLConnection.dicsonnect() method when the InputStream
38  * object is closed.</p>
39  *
40  * @since 1.0
41  */

42 class HTTPFileInputStream extends InputStream JavaDoc {
43     
44     // Connection object to the web server
45
private HttpURLConnection JavaDoc fileConnection;
46     // Input stream that is wrapped by this class
47
private InputStream JavaDoc fileInputStream;
48         
49     /**
50      * Constructs an <code>HTTPFileInputStream</code> object created from the
51      * connection object passed to the constructor.
52      *
53      * @param FileConnection URLConnection object from which to obtain the wrapped
54      * InputStream.
55      *
56      * @since 1.0
57      */

58     HTTPFileInputStream( HttpURLConnection JavaDoc fileConnection ) throws IOException JavaDoc {
59         
60         this.fileConnection = fileConnection;
61         this.fileInputStream = this.fileConnection.getInputStream( );
62     }
63     
64     
65     /**
66      * Pass-through method for {@link java.io.InputStream#available()}.
67      */

68     public int available() throws IOException JavaDoc {
69         
70         return fileInputStream.available( );
71     }
72     
73     
74     /**
75      * Pass-through method for {@link InputStream#close()}. It also disconnects from
76      * the web server.
77      */

78     public void close( ) throws IOException JavaDoc {
79         
80         // Disconnect from the web server when the InputStream is closed
81
fileInputStream.close( );
82         fileConnection.disconnect( );
83     }
84     
85     
86     /**
87      * Pass-through method for {@link java.io.InputStream#mark(int)}.
88      */

89     public void mark( int param ) {
90         
91         fileInputStream.mark( param );
92     }
93     
94     
95     /**
96      * Pass-through method for {@link java.io.InputStream#markSupported()}.
97      */

98     public boolean markSupported( ) {
99         
100         return fileInputStream.markSupported( );
101     }
102     
103     
104     /**
105      * Pass-through method for {@link java.io.InputStream#read()}.
106      */

107     public int read( ) throws IOException JavaDoc {
108         
109         return fileInputStream.read( );
110     }
111     
112     
113     /**
114      * Pass-through method for {@link java.io.InputStream#read(byte[])}.
115      */

116     public int read( byte[] values ) throws IOException JavaDoc {
117         
118         return fileInputStream.read( values );
119     }
120     
121     
122     /**
123      * Pass-through method for {@link java.io.InputStream#read(byte[],int,int)}.
124      */

125     public int read( byte[] values, int off, int len ) throws IOException JavaDoc {
126         
127         return fileInputStream.read( values, off, len );
128     }
129     
130     
131     /**
132      * Pass-through method for {@link java.io.InputStream#reset()}.
133      */

134     public void reset( ) throws IOException JavaDoc {
135         
136         fileInputStream.reset( );
137     }
138     
139     
140     /**
141      * Pass-through method for {@link java.io.InputStream#skip(long)}.
142      */

143     public long skip(long param ) throws IOException JavaDoc {
144         
145         return fileInputStream.skip( param );
146     }
147 }
148
Popular Tags