1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/ch/boye/httpclientandroidlib/message/HeaderValueFormatter.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,122 @@ 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.HeaderElement; 1.34 +import ch.boye.httpclientandroidlib.NameValuePair; 1.35 +import ch.boye.httpclientandroidlib.util.CharArrayBuffer; 1.36 + 1.37 +/** 1.38 + * Interface for formatting elements of a header value. 1.39 + * This is the complement to {@link HeaderValueParser}. 1.40 + * Instances of this interface are expected to be stateless and thread-safe. 1.41 + * 1.42 + * <p> 1.43 + * All formatting methods accept an optional buffer argument. 1.44 + * If a buffer is passed in, the formatted element will be appended 1.45 + * and the modified buffer is returned. If no buffer is passed in, 1.46 + * a new buffer will be created and filled with the formatted element. 1.47 + * In both cases, the caller is allowed to modify the returned buffer. 1.48 + * </p> 1.49 + * 1.50 + * @since 4.0 1.51 + */ 1.52 +public interface HeaderValueFormatter { 1.53 + 1.54 + /** 1.55 + * Formats an array of header elements. 1.56 + * 1.57 + * @param buffer the buffer to append to, or 1.58 + * <code>null</code> to create a new buffer 1.59 + * @param elems the header elements to format 1.60 + * @param quote <code>true</code> to always format with quoted values, 1.61 + * <code>false</code> to use quotes only when necessary 1.62 + * 1.63 + * @return a buffer with the formatted header elements. 1.64 + * If the <code>buffer</code> argument was not <code>null</code>, 1.65 + * that buffer will be used and returned. 1.66 + */ 1.67 + CharArrayBuffer formatElements(CharArrayBuffer buffer, 1.68 + HeaderElement[] elems, 1.69 + boolean quote); 1.70 + 1.71 + /** 1.72 + * Formats one header element. 1.73 + * 1.74 + * @param buffer the buffer to append to, or 1.75 + * <code>null</code> to create a new buffer 1.76 + * @param elem the header element to format 1.77 + * @param quote <code>true</code> to always format with quoted values, 1.78 + * <code>false</code> to use quotes only when necessary 1.79 + * 1.80 + * @return a buffer with the formatted header element. 1.81 + * If the <code>buffer</code> argument was not <code>null</code>, 1.82 + * that buffer will be used and returned. 1.83 + */ 1.84 + CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer, 1.85 + HeaderElement elem, 1.86 + boolean quote); 1.87 + 1.88 + /** 1.89 + * Formats the parameters of a header element. 1.90 + * That's a list of name-value pairs, to be separated by semicolons. 1.91 + * This method will <i>not</i> generate a leading semicolon. 1.92 + * 1.93 + * @param buffer the buffer to append to, or 1.94 + * <code>null</code> to create a new buffer 1.95 + * @param nvps the parameters (name-value pairs) to format 1.96 + * @param quote <code>true</code> to always format with quoted values, 1.97 + * <code>false</code> to use quotes only when necessary 1.98 + * 1.99 + * @return a buffer with the formatted parameters. 1.100 + * If the <code>buffer</code> argument was not <code>null</code>, 1.101 + * that buffer will be used and returned. 1.102 + */ 1.103 + CharArrayBuffer formatParameters(CharArrayBuffer buffer, 1.104 + NameValuePair[] nvps, 1.105 + boolean quote); 1.106 + 1.107 + /** 1.108 + * Formats one name-value pair, where the value is optional. 1.109 + * 1.110 + * @param buffer the buffer to append to, or 1.111 + * <code>null</code> to create a new buffer 1.112 + * @param nvp the name-value pair to format 1.113 + * @param quote <code>true</code> to always format with a quoted value, 1.114 + * <code>false</code> to use quotes only when necessary 1.115 + * 1.116 + * @return a buffer with the formatted name-value pair. 1.117 + * If the <code>buffer</code> argument was not <code>null</code>, 1.118 + * that buffer will be used and returned. 1.119 + */ 1.120 + CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer, 1.121 + NameValuePair nvp, 1.122 + boolean quote); 1.123 + 1.124 +} 1.125 +