KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > service > rmi > socket > zip > CompressionSocket


1 /*
2  * $Id: CompressionSocket.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 1998, 1999 Sun Microsystems, Inc. All Rights Reserved.
5  *
6  * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
7  * modify and redistribute this software in source and binary code form,
8  * provided that i) this copyright notice and license appear on all copies of
9  * the software; and ii) Licensee does not utilize the software in a manner
10  * which is disparaging to Sun.
11  *
12  * This software is provided "AS IS," without a warranty of any kind. ALL
13  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
14  * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
15  * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
16  * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
17  * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
18  * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
19  * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
20  * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
21  * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
22  * POSSIBILITY OF SUCH DAMAGES.
23  *
24  * This software is not designed or intended for use in on-line control of
25  * aircraft, air traffic, aircraft navigation or aircraft communications; or in
26  * the design, construction, operation or maintenance of any nuclear
27  * facility. Licensee represents and warrants that it will not use or
28  * redistribute the Software for such purposes.
29  */

30
31 package org.ofbiz.service.rmi.socket.zip;
32
33 import java.io.IOException JavaDoc;
34 import java.io.InputStream JavaDoc;
35 import java.io.OutputStream JavaDoc;
36 import java.net.Socket JavaDoc;
37
38 class CompressionSocket extends Socket JavaDoc {
39
40     /* InputStream used by socket */
41     private InputStream JavaDoc in;
42     /* OutputStream used by socket */
43     private OutputStream JavaDoc out;
44
45     /*
46      * No-arg constructor for class CompressionSocket
47      */

48     public CompressionSocket() {
49         super();
50     }
51
52     /*
53      * Constructor for class CompressionSocket
54      */

55     public CompressionSocket(String JavaDoc host, int port) throws IOException JavaDoc {
56         super(host, port);
57     }
58
59     /*
60      * Returns a stream of type CompressionInputStream
61      */

62     public InputStream JavaDoc getInputStream() throws IOException JavaDoc {
63         if (in == null) {
64             in = new CompressionInputStream(super.getInputStream());
65         }
66         return in;
67     }
68
69     /*
70      * Returns a stream of type CompressionOutputStream
71      */

72     public OutputStream JavaDoc getOutputStream() throws IOException JavaDoc {
73         if (out == null) {
74             out = new CompressionOutputStream(super.getOutputStream());
75         }
76         return out;
77     }
78
79     /*
80      * Flush the CompressionOutputStream before
81      * closing the socket.
82      */

83     public synchronized void close() throws IOException JavaDoc {
84         OutputStream JavaDoc o = getOutputStream();
85         o.flush();
86         super.close();
87     }
88 }
89
Popular Tags