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 isContentWritten();
60  
61      void increaseContentBufferSize(int size);
62      
63      boolean isBufferFull();
64  
65      boolean isCommitted();
66  
67      boolean isComplete();
68  
69      boolean isPersistent();
70  
71      void reset(boolean returnBuffers);
72  
73      void resetBuffer();
74  
75      void sendError(int code, String reason, String content, boolean close) throws IOException;
76      
77      void setHead(boolean head);
78  
79      void setRequest(String method, String uri);
80  
81      void setResponse(int status, String reason);
82  
83  
84      void setSendServerVersion(boolean sendServerVersion);
85   
86      void setVersion(int version);
87  
88      boolean isIdle();
89  
90      void setContentLength(long length);
91      
92      void setPersistent(boolean persistent);
93  
94      void setDate(Buffer timeStampBuffer);
95      
96  
97  }