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

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2  * ====================================================================
     3  * Licensed to the Apache Software Foundation (ASF) under one
     4  * or more contributor license agreements.  See the NOTICE file
     5  * distributed with this work for additional information
     6  * regarding copyright ownership.  The ASF licenses this file
     7  * to you under the Apache License, Version 2.0 (the
     8  * "License"); you may not use this file except in compliance
     9  * with the License.  You may obtain a copy of the License at
    10  *
    11  *   http://www.apache.org/licenses/LICENSE-2.0
    12  *
    13  * Unless required by applicable law or agreed to in writing,
    14  * software distributed under the License is distributed on an
    15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    16  * KIND, either express or implied.  See the License for the
    17  * specific language governing permissions and limitations
    18  * under the License.
    19  * ====================================================================
    20  *
    21  * This software consists of voluntary contributions made by many
    22  * individuals on behalf of the Apache Software Foundation.  For more
    23  * information on the Apache Software Foundation, please see
    24  * <http://www.apache.org/>.
    25  *
    26  */
    28 package ch.boye.httpclientandroidlib.message;
    30 import ch.boye.httpclientandroidlib.HeaderElement;
    31 import ch.boye.httpclientandroidlib.NameValuePair;
    32 import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
    34 /**
    35  * Interface for formatting elements of a header value.
    36  * This is the complement to {@link HeaderValueParser}.
    37  * Instances of this interface are expected to be stateless and thread-safe.
    38  *
    39  * <p>
    40  * All formatting methods accept an optional buffer argument.
    41  * If a buffer is passed in, the formatted element will be appended
    42  * and the modified buffer is returned. If no buffer is passed in,
    43  * a new buffer will be created and filled with the formatted element.
    44  * In both cases, the caller is allowed to modify the returned buffer.
    45  * </p>
    46  *
    47  * @since 4.0
    48  */
    49 public interface HeaderValueFormatter {
    51     /**
    52      * Formats an array of header elements.
    53      *
    54      * @param buffer    the buffer to append to, or
    55      *                  <code>null</code> to create a new buffer
    56      * @param elems     the header elements to format
    57      * @param quote     <code>true</code> to always format with quoted values,
    58      *                  <code>false</code> to use quotes only when necessary
    59      *
    60      * @return  a buffer with the formatted header elements.
    61      *          If the <code>buffer</code> argument was not <code>null</code>,
    62      *          that buffer will be used and returned.
    63      */
    64     CharArrayBuffer formatElements(CharArrayBuffer buffer,
    65                                    HeaderElement[] elems,
    66                                    boolean quote);
    68     /**
    69      * Formats one header element.
    70      *
    71      * @param buffer    the buffer to append to, or
    72      *                  <code>null</code> to create a new buffer
    73      * @param elem      the header element to format
    74      * @param quote     <code>true</code> to always format with quoted values,
    75      *                  <code>false</code> to use quotes only when necessary
    76      *
    77      * @return  a buffer with the formatted header element.
    78      *          If the <code>buffer</code> argument was not <code>null</code>,
    79      *          that buffer will be used and returned.
    80      */
    81     CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer,
    82                                         HeaderElement elem,
    83                                         boolean quote);
    85     /**
    86      * Formats the parameters of a header element.
    87      * That's a list of name-value pairs, to be separated by semicolons.
    88      * This method will <i>not</i> generate a leading semicolon.
    89      *
    90      * @param buffer    the buffer to append to, or
    91      *                  <code>null</code> to create a new buffer
    92      * @param nvps      the parameters (name-value pairs) to format
    93      * @param quote     <code>true</code> to always format with quoted values,
    94      *                  <code>false</code> to use quotes only when necessary
    95      *
    96      * @return  a buffer with the formatted parameters.
    97      *          If the <code>buffer</code> argument was not <code>null</code>,
    98      *          that buffer will be used and returned.
    99      */
   100     CharArrayBuffer formatParameters(CharArrayBuffer buffer,
   101                                      NameValuePair[] nvps,
   102                                      boolean quote);
   104     /**
   105      * Formats one name-value pair, where the value is optional.
   106      *
   107      * @param buffer    the buffer to append to, or
   108      *                  <code>null</code> to create a new buffer
   109      * @param nvp       the name-value pair to format
   110      * @param quote     <code>true</code> to always format with a quoted value,
   111      *                  <code>false</code> to use quotes only when necessary
   112      *
   113      * @return  a buffer with the formatted name-value pair.
   114      *          If the <code>buffer</code> argument was not <code>null</code>,
   115      *          that buffer will be used and returned.
   116      */
   117     CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer,
   118                                         NameValuePair nvp,
   119                                         boolean quote);
   121 }

mercurial