01: //========================================================================
02: //Copyright 2006 Mort Bay Consulting Pty. Ltd.
03: //------------------------------------------------------------------------
04: //Licensed under the Apache License, Version 2.0 (the "License");
05: //you may not use this file except in compliance with the License.
06: //You may obtain a copy of the License at
07: //http://www.apache.org/licenses/LICENSE-2.0
08: //Unless required by applicable law or agreed to in writing, software
09: //distributed under the License is distributed on an "AS IS" BASIS,
10: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11: //See the License for the specific language governing permissions and
12: //limitations under the License.
13: //========================================================================
14:
15: package org.mortbay.jetty;
16:
17: import java.io.IOException;
18:
19: import org.mortbay.io.Buffer;
20:
21: public interface Generator {
22: public static final boolean LAST = true;
23: public static final boolean MORE = false;
24:
25: /* ------------------------------------------------------------ */
26: /**
27: * Add content.
28: *
29: * @param content
30: * @param last
31: * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}.
32: * @throws IllegalStateException If the request is not expecting any more content,
33: * or if the buffers are full and cannot be flushed.
34: * @throws IOException if there is a problem flushing the buffers.
35: */
36: void addContent(Buffer content, boolean last) throws IOException;
37:
38: /* ------------------------------------------------------------ */
39: /**
40: * Add content.
41: *
42: * @param b byte
43: * @return true if the buffers are full
44: * @throws IOException
45: */
46: boolean addContent(byte b) throws IOException;
47:
48: void complete() throws IOException;
49:
50: void completeHeader(HttpFields responseFields, boolean last)
51: throws IOException;
52:
53: long flush() throws IOException;
54:
55: int getContentBufferSize();
56:
57: long getContentWritten();
58:
59: void increaseContentBufferSize(int size);
60:
61: boolean isBufferFull();
62:
63: boolean isCommitted();
64:
65: boolean isComplete();
66:
67: boolean isPersistent();
68:
69: void reset(boolean returnBuffers);
70:
71: void resetBuffer();
72:
73: void sendError(int code, String reason, String content,
74: boolean close) throws IOException;
75:
76: void setHead(boolean head);
77:
78: void setRequest(String method, String uri);
79:
80: void setResponse(int status, String reason);
81:
82: void setSendServerVersion(boolean sendServerVersion);
83:
84: void setVersion(int version);
85:
86: boolean isIdle();
87:
88: void setContentLength(long length);
89:
90: }
|