• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/HeaderValueFormatter.java $
3  * $Revision: 571954 $
4  * $Date: 2007-09-02 04:05:21 -0700 (Sun, 02 Sep 2007) $
5  *
6  * ====================================================================
7  * Licensed to the Apache Software Foundation (ASF) under one
8  * or more contributor license agreements.  See the NOTICE file
9  * distributed with this work for additional information
10  * regarding copyright ownership.  The ASF licenses this file
11  * to you under the Apache License, Version 2.0 (the
12  * "License"); you may not use this file except in compliance
13  * with the License.  You may obtain a copy of the License at
14  *
15  *   http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing,
18  * software distributed under the License is distributed on an
19  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20  * KIND, either express or implied.  See the License for the
21  * specific language governing permissions and limitations
22  * under the License.
23  * ====================================================================
24  *
25  * This software consists of voluntary contributions made by many
26  * individuals on behalf of the Apache Software Foundation.  For more
27  * information on the Apache Software Foundation, please see
28  * <http://www.apache.org/>.
29  *
30  */
31 
32 package org.apache.http.message;
33 
34 
35 import org.apache.http.HeaderElement;
36 import org.apache.http.NameValuePair;
37 import org.apache.http.util.CharArrayBuffer;
38 
39 
40 
41 /**
42  * Interface for formatting elements of a header value.
43  * This is the complement to {@link HeaderValueParser}.
44  * Instances of this interface are expected to be stateless and thread-safe.
45  *
46  * <p>
47  * All formatting methods accept an optional buffer argument.
48  * If a buffer is passed in, the formatted element will be appended
49  * and the modified buffer is returned. If no buffer is passed in,
50  * a new buffer will be created and filled with the formatted element.
51  * In both cases, the caller is allowed to modify the returned buffer.
52  * </p>
53  *
54  *
55  * <!-- empty lines above to avoid 'svn diff' context problems -->
56  * @version $Revision: 571954 $
57  *
58  * @since 4.0
59  *
60  * @deprecated Please use {@link java.net.URL#openConnection} instead.
61  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
62  *     for further details.
63  */
64 @Deprecated
65 public interface HeaderValueFormatter {
66 
67     /**
68      * Formats an array of header elements.
69      *
70      * @param buffer    the buffer to append to, or
71      *                  <code>null</code> to create a new buffer
72      * @param elems     the header elements to format
73      * @param quote     <code>true</code> to always format with quoted values,
74      *                  <code>false</code> to use quotes only when necessary
75      *
76      * @return  a buffer with the formatted header elements.
77      *          If the <code>buffer</code> argument was not <code>null</code>,
78      *          that buffer will be used and returned.
79      */
formatElements(CharArrayBuffer buffer, HeaderElement[] elems, boolean quote)80     CharArrayBuffer formatElements(CharArrayBuffer buffer,
81                                    HeaderElement[] elems,
82                                    boolean quote)
83         ;
84 
85 
86     /**
87      * Formats one header element.
88      *
89      * @param buffer    the buffer to append to, or
90      *                  <code>null</code> to create a new buffer
91      * @param elem      the header element to format
92      * @param quote     <code>true</code> to always format with quoted values,
93      *                  <code>false</code> to use quotes only when necessary
94      *
95      * @return  a buffer with the formatted header element.
96      *          If the <code>buffer</code> argument was not <code>null</code>,
97      *          that buffer will be used and returned.
98      */
formatHeaderElement(CharArrayBuffer buffer, HeaderElement elem, boolean quote)99     CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer,
100                                         HeaderElement elem,
101                                         boolean quote)
102         ;
103 
104 
105 
106     /**
107      * Formats the parameters of a header element.
108      * That's a list of name-value pairs, to be separated by semicolons.
109      * This method will <i>not</i> generate a leading semicolon.
110      *
111      * @param buffer    the buffer to append to, or
112      *                  <code>null</code> to create a new buffer
113      * @param nvps      the parameters (name-value pairs) to format
114      * @param quote     <code>true</code> to always format with quoted values,
115      *                  <code>false</code> to use quotes only when necessary
116      *
117      * @return  a buffer with the formatted parameters.
118      *          If the <code>buffer</code> argument was not <code>null</code>,
119      *          that buffer will be used and returned.
120      */
formatParameters(CharArrayBuffer buffer, NameValuePair[] nvps, boolean quote)121     CharArrayBuffer formatParameters(CharArrayBuffer buffer,
122                                      NameValuePair[] nvps,
123                                      boolean quote)
124         ;
125 
126 
127     /**
128      * Formats one name-value pair, where the value is optional.
129      *
130      * @param buffer    the buffer to append to, or
131      *                  <code>null</code> to create a new buffer
132      * @param nvp       the name-value pair to format
133      * @param quote     <code>true</code> to always format with a quoted value,
134      *                  <code>false</code> to use quotes only when necessary
135      *
136      * @return  a buffer with the formatted name-value pair.
137      *          If the <code>buffer</code> argument was not <code>null</code>,
138      *          that buffer will be used and returned.
139      */
formatNameValuePair(CharArrayBuffer buffer, NameValuePair nvp, boolean quote)140     CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer,
141                                         NameValuePair nvp,
142                                         boolean quote)
143         ;
144 
145 }
146 
147