mobile/android/thirdparty/ch/boye/httpclientandroidlib/message/LineFormatter.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/message/LineFormatter.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +/*
     1.5 + * ====================================================================
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + * ====================================================================
    1.23 + *
    1.24 + * This software consists of voluntary contributions made by many
    1.25 + * individuals on behalf of the Apache Software Foundation.  For more
    1.26 + * information on the Apache Software Foundation, please see
    1.27 + * <http://www.apache.org/>.
    1.28 + *
    1.29 + */
    1.30 +
    1.31 +package ch.boye.httpclientandroidlib.message;
    1.32 +
    1.33 +import ch.boye.httpclientandroidlib.ProtocolVersion;
    1.34 +import ch.boye.httpclientandroidlib.RequestLine;
    1.35 +import ch.boye.httpclientandroidlib.StatusLine;
    1.36 +import ch.boye.httpclientandroidlib.Header;
    1.37 +import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
    1.38 +
    1.39 +/**
    1.40 + * Interface for formatting elements of the HEAD section of an HTTP message.
    1.41 + * This is the complement to {@link LineParser}.
    1.42 + * There are individual methods for formatting a request line, a
    1.43 + * status line, or a header line. The formatting does <i>not</i> include the
    1.44 + * trailing line break sequence CR-LF.
    1.45 + * Instances of this interface are expected to be stateless and thread-safe.
    1.46 + *
    1.47 + * <p>
    1.48 + * The formatted lines are returned in memory, the formatter does not depend
    1.49 + * on any specific IO mechanism.
    1.50 + * In order to avoid unnecessary creation of temporary objects,
    1.51 + * a buffer can be passed as argument to all formatting methods.
    1.52 + * The implementation may or may not actually use that buffer for formatting.
    1.53 + * If it is used, the buffer will first be cleared by the
    1.54 + * <code>formatXXX</code> methods.
    1.55 + * The argument buffer can always be re-used after the call. The buffer
    1.56 + * returned as the result, if it is different from the argument buffer,
    1.57 + * MUST NOT be modified.
    1.58 + * </p>
    1.59 + *
    1.60 + * @since 4.0
    1.61 + */
    1.62 +public interface LineFormatter {
    1.63 +
    1.64 +    /**
    1.65 +     * Formats a protocol version.
    1.66 +     * This method does <i>not</i> follow the general contract for
    1.67 +     * <code>buffer</code> arguments.
    1.68 +     * It does <i>not</i> clear the argument buffer, but appends instead.
    1.69 +     * The returned buffer can always be modified by the caller.
    1.70 +     * Because of these differing conventions, it is not named
    1.71 +     * <code>formatProtocolVersion</code>.
    1.72 +     *
    1.73 +     * @param buffer    a buffer to which to append, or <code>null</code>
    1.74 +     * @param version   the protocol version to format
    1.75 +     *
    1.76 +     * @return  a buffer with the formatted protocol version appended.
    1.77 +     *          The caller is allowed to modify the result buffer.
    1.78 +     *          If the <code>buffer</code> argument is not <code>null</code>,
    1.79 +     *          the returned buffer is the argument buffer.
    1.80 +     */
    1.81 +    CharArrayBuffer appendProtocolVersion(CharArrayBuffer buffer,
    1.82 +                                          ProtocolVersion version);
    1.83 +
    1.84 +    /**
    1.85 +     * Formats a request line.
    1.86 +     *
    1.87 +     * @param buffer    a buffer available for formatting, or
    1.88 +     *                  <code>null</code>.
    1.89 +     *                  The buffer will be cleared before use.
    1.90 +     * @param reqline   the request line to format
    1.91 +     *
    1.92 +     * @return  the formatted request line
    1.93 +     */
    1.94 +    CharArrayBuffer formatRequestLine(CharArrayBuffer buffer,
    1.95 +                                      RequestLine reqline);
    1.96 +
    1.97 +    /**
    1.98 +     * Formats a status line.
    1.99 +     *
   1.100 +     * @param buffer    a buffer available for formatting, or
   1.101 +     *                  <code>null</code>.
   1.102 +     *                  The buffer will be cleared before use.
   1.103 +     * @param statline  the status line to format
   1.104 +     *
   1.105 +     * @return  the formatted status line
   1.106 +     *
   1.107 +     * @throws ch.boye.httpclientandroidlib.ParseException        in case of a parse error
   1.108 +     */
   1.109 +    CharArrayBuffer formatStatusLine(CharArrayBuffer buffer,
   1.110 +                                     StatusLine statline);
   1.111 +
   1.112 +    /**
   1.113 +     * Formats a header.
   1.114 +     * Due to header continuation, the result may be multiple lines.
   1.115 +     * In order to generate well-formed HTTP, the lines in the result
   1.116 +     * must be separated by the HTTP line break sequence CR-LF.
   1.117 +     * There is <i>no</i> trailing CR-LF in the result.
   1.118 +     * <br/>
   1.119 +     * See the class comment for details about the buffer argument.
   1.120 +     *
   1.121 +     * @param buffer    a buffer available for formatting, or
   1.122 +     *                  <code>null</code>.
   1.123 +     *                  The buffer will be cleared before use.
   1.124 +     * @param header    the header to format
   1.125 +     *
   1.126 +     * @return  a buffer holding the formatted header, never <code>null</code>.
   1.127 +     *          The returned buffer may be different from the argument buffer.
   1.128 +     *
   1.129 +     * @throws ch.boye.httpclientandroidlib.ParseException        in case of a parse error
   1.130 +     */
   1.131 +    CharArrayBuffer formatHeader(CharArrayBuffer buffer,
   1.132 +                                 Header header);
   1.133 +
   1.134 +}

mercurial