KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > cvsclient > request > GzipStreamRequest


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

22 package org.netbeans.lib.cvsclient.request;
23
24 import java.io.*;
25
26 import org.netbeans.lib.cvsclient.connection.*;
27
28 /**
29  * This class implements the Gzip-Stream request that is used to indicate that
30  * all further communication with the server is to be gzipped.
31  * @author Robert Greig
32  */

33 public class GzipStreamRequest extends Request {
34
35     /**
36      * The level of gzipping to specify
37      */

38     private int level = 6;
39
40     /**
41      * Creates new GzipStreamRequest with gzip level 6
42      */

43     public GzipStreamRequest() {
44     }
45
46     /**
47      * Creates new GzipStreamRequest
48      * @param level the level of zipping to use (between 1 and 9)
49      */

50     public GzipStreamRequest(int level) {
51         this.level = level;
52     }
53
54     /**
55      * Get the request String that will be passed to the server
56      * @return the request String
57      * @throws UnconfiguredRequestException if the request has not been
58      * properly configured
59      */

60     public String JavaDoc getRequestString() throws UnconfiguredRequestException {
61         return "Gzip-stream " + level + "\n"; //NOI18N
62
}
63
64     /**
65      * Is a response expected from the server?
66      * @return true if a response is expected, false if no response if
67      * expected
68      */

69     public boolean isResponseExpected() {
70         return false;
71     }
72
73     /**
74      * Modify streams on the connection if necessary
75      */

76     public void modifyOutputStream(Connection connection) throws IOException {
77         connection.modifyOutputStream(new GzipModifier());
78     }
79
80     /**
81      * Modify streams on the connection if necessary
82      */

83     public void modifyInputStream(Connection connection) throws IOException {
84         connection.modifyInputStream(new GzipModifier());
85     }
86
87     /**
88      * Does this request modify the input stream?
89      * @return true if it does, false otherwise
90      */

91     public boolean modifiesInputStream() {
92         return true;
93     }
94 }
95
Popular Tags