View Javadoc

    1   //========================================================================
    2   //Copyright 2006 Mort Bay Consulting Pty. Ltd.
    3   //------------------------------------------------------------------------
    4   //Licensed under the Apache License, Version 2.0 (the "License");
    5   //you may not use this file except in compliance with the License.
    6   //You may obtain a copy of the License at
    7   //http://www.apache.org/licenses/LICENSE-2.0
    8   //Unless required by applicable law or agreed to in writing, software
    9   //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
    16  package org.mortbay.jetty;
    17
    18  import java.io.IOException;
    19
    20  import org.mortbay.io.Buffer;
    21
    22  public interface Generator
    23  {
    24      public static final boolean LAST=true;
    25      public static final boolean MORE=false;
    26
    27      /* ------------------------------------------------------------ */
    28      /**
    29       * Add content.
    30       *
    31       * @param content
    32       * @param last
    33       * @throws IllegalArgumentException if <code>content</code> is {@link Buffer#isImmutable immutable}.
    34       * @throws IllegalStateException If the request is not expecting any more content,
    35       *   or if the buffers are full and cannot be flushed.
    36       * @throws IOException if there is a problem flushing the buffers.
    37       */
    38      void addContent(Buffer content, boolean last) throws IOException;
    39
    40      /* ------------------------------------------------------------ */
    41      /**
    42       * Add content.
    43       *
    44       * @param b byte
    45       * @return true if the buffers are full
    46       * @throws IOException
    47       */
    48      boolean addContent(byte b) throws IOException;
    49
    50      void complete() throws IOException;
    51
    52      void completeHeader(HttpFields responseFields, boolean last) throws IOException;
    53
    54      long flush() throws IOException;
    55
    56      int getContentBufferSize();
    57
    58      long getContentWritten();
    59
    60      boolean isContentWritten();
    61
    62      void increaseContentBufferSize(int size);
    63
    64      boolean isBufferFull();
    65
    66      boolean isCommitted();
    67
    68      boolean isComplete();
    69
    70      boolean isPersistent();
    71
    72      void reset(boolean returnBuffers);
    73
    74      void resetBuffer();
    75
    76      void sendError(int code, String reason, String content, boolean close) throws IOException;
    77
    78      void setHead(boolean head);
    79
    80      void setRequest(String method, String uri);
    81
    82      void setResponse(int status, String reason);
    83
    84
    85      void setSendServerVersion(boolean sendServerVersion);
    86
    87      void setVersion(int version);
    88
    89      boolean isIdle();
    90
    91      void setContentLength(long length);
    92
    93      void setPersistent(boolean persistent);
    94
    95
    96  }