KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > coyote > http11 > filters > VoidInputFilter


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.coyote.http11.filters;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.tomcat.util.buf.ByteChunk;
23
24 import org.apache.coyote.InputBuffer;
25 import org.apache.coyote.Request;
26 import org.apache.coyote.http11.InputFilter;
27
28 /**
29  * Void input filter, which returns -1 when attempting a read. Used with a GET,
30  * HEAD, or a similar request.
31  *
32  * @author Remy Maucherat
33  */

34 public class VoidInputFilter implements InputFilter {
35
36
37     // -------------------------------------------------------------- Constants
38

39
40     protected static final String JavaDoc ENCODING_NAME = "void";
41     protected static final ByteChunk ENCODING = new ByteChunk();
42
43
44     // ----------------------------------------------------- Static Initializer
45

46
47     static {
48         ENCODING.setBytes(ENCODING_NAME.getBytes(), 0, ENCODING_NAME.length());
49     }
50
51
52     // ----------------------------------------------------- Instance Variables
53

54
55     // --------------------------------------------------- OutputBuffer Methods
56

57
58     /**
59      * Write some bytes.
60      *
61      * @return number of bytes written by the filter
62      */

63     public int doRead(ByteChunk chunk, Request req)
64         throws IOException JavaDoc {
65
66         return -1;
67
68     }
69
70
71     // --------------------------------------------------- OutputFilter Methods
72

73
74     /**
75      * Set the associated reauest.
76      */

77     public void setRequest(Request request) {
78     }
79
80
81     /**
82      * Set the next buffer in the filter pipeline.
83      */

84     public void setBuffer(InputBuffer buffer) {
85     }
86
87
88     /**
89      * Make the filter ready to process the next request.
90      */

91     public void recycle() {
92     }
93
94
95     /**
96      * Return the name of the associated encoding; Here, the value is
97      * "void".
98      */

99     public ByteChunk getEncodingName() {
100         return ENCODING;
101     }
102
103
104     /**
105      * End the current request. It is acceptable to write extra bytes using
106      * buffer.doWrite during the execution of this method.
107      *
108      * @return Should return 0 unless the filter does some content length
109      * delimitation, in which case the number is the amount of extra bytes or
110      * missing bytes, which would indicate an error.
111      * Note: It is recommended that extra bytes be swallowed by the filter.
112      */

113     public long end()
114         throws IOException JavaDoc {
115         return 0;
116     }
117
118
119 }
120
Popular Tags