View Javadoc

1   // ========================================================================
2   // Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  
15  package org.eclipse.jetty.http;
16  
17  import java.io.IOException;
18  
19  import org.eclipse.jetty.io.Buffer;
20  
21  public interface Generator
22  {
23      public static final boolean LAST=true;
24      public static final boolean MORE=false;
25  
26      /* ------------------------------------------------------------ */
27      /**
28       * Add content.
29       * 
30       * @param content
31       * @param last
32       * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}.
33       * @throws IllegalStateException If the request is not expecting any more content,
34       *   or if the buffers are full and cannot be flushed.
35       * @throws IOException if there is a problem flushing the buffers.
36       */
37      void addContent(Buffer content, boolean last) throws IOException;
38  
39      /* ------------------------------------------------------------ */
40      /**
41       * Add content.
42       * 
43       * @param b byte
44       * @return true if the buffers are full
45       * @throws IOException
46       */
47      boolean addContent(byte b) throws IOException;
48  
49      void complete() throws IOException;
50  
51      void completeHeader(HttpFields responseFields, boolean last) throws IOException;
52  
53      long flushBuffer() throws IOException;
54  
55      int getContentBufferSize();
56  
57      long getContentWritten();
58  
59      boolean isWritten();
60      
61      boolean isAllContentWritten();
62  
63      void increaseContentBufferSize(int size);
64      
65      boolean isBufferFull();
66  
67      boolean isCommitted();
68  
69      boolean isComplete();
70  
71      boolean isPersistent();
72  
73      void reset(boolean returnBuffers);
74  
75      void resetBuffer();
76  
77      void sendError(int code, String reason, String content, boolean close) throws IOException;
78      
79      void setHead(boolean head);
80  
81      void setRequest(String method, String uri);
82  
83      void setResponse(int status, String reason);
84  
85  
86      void setSendServerVersion(boolean sendServerVersion);
87   
88      void setVersion(int version);
89  
90      boolean isIdle();
91  
92      void setContentLength(long length);
93      
94      void setPersistent(boolean persistent);
95  
96      void setDate(Buffer timeStampBuffer);
97      
98  
99  }