michael@0: /*
michael@0: * ====================================================================
michael@0: * Licensed to the Apache Software Foundation (ASF) under one
michael@0: * or more contributor license agreements. See the NOTICE file
michael@0: * distributed with this work for additional information
michael@0: * regarding copyright ownership. The ASF licenses this file
michael@0: * to you under the Apache License, Version 2.0 (the
michael@0: * "License"); you may not use this file except in compliance
michael@0: * with the License. You may obtain a copy of the License at
michael@0: *
michael@0: * http://www.apache.org/licenses/LICENSE-2.0
michael@0: *
michael@0: * Unless required by applicable law or agreed to in writing,
michael@0: * software distributed under the License is distributed on an
michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
michael@0: * KIND, either express or implied. See the License for the
michael@0: * specific language governing permissions and limitations
michael@0: * under the License.
michael@0: * ====================================================================
michael@0: *
michael@0: * This software consists of voluntary contributions made by many
michael@0: * individuals on behalf of the Apache Software Foundation. For more
michael@0: * information on the Apache Software Foundation, please see
michael@0: *
michael@0: * All formatting methods accept an optional buffer argument. michael@0: * If a buffer is passed in, the formatted element will be appended michael@0: * and the modified buffer is returned. If no buffer is passed in, michael@0: * a new buffer will be created and filled with the formatted element. michael@0: * In both cases, the caller is allowed to modify the returned buffer. michael@0: *
michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface HeaderValueFormatter { michael@0: michael@0: /** michael@0: * Formats an array of header elements. michael@0: * michael@0: * @param buffer the buffer to append to, or michael@0: *null
to create a new buffer
michael@0: * @param elems the header elements to format
michael@0: * @param quote true
to always format with quoted values,
michael@0: * false
to use quotes only when necessary
michael@0: *
michael@0: * @return a buffer with the formatted header elements.
michael@0: * If the buffer
argument was not null
,
michael@0: * that buffer will be used and returned.
michael@0: */
michael@0: CharArrayBuffer formatElements(CharArrayBuffer buffer,
michael@0: HeaderElement[] elems,
michael@0: boolean quote);
michael@0:
michael@0: /**
michael@0: * Formats one header element.
michael@0: *
michael@0: * @param buffer the buffer to append to, or
michael@0: * null
to create a new buffer
michael@0: * @param elem the header element to format
michael@0: * @param quote true
to always format with quoted values,
michael@0: * false
to use quotes only when necessary
michael@0: *
michael@0: * @return a buffer with the formatted header element.
michael@0: * If the buffer
argument was not null
,
michael@0: * that buffer will be used and returned.
michael@0: */
michael@0: CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer,
michael@0: HeaderElement elem,
michael@0: boolean quote);
michael@0:
michael@0: /**
michael@0: * Formats the parameters of a header element.
michael@0: * That's a list of name-value pairs, to be separated by semicolons.
michael@0: * This method will not generate a leading semicolon.
michael@0: *
michael@0: * @param buffer the buffer to append to, or
michael@0: * null
to create a new buffer
michael@0: * @param nvps the parameters (name-value pairs) to format
michael@0: * @param quote true
to always format with quoted values,
michael@0: * false
to use quotes only when necessary
michael@0: *
michael@0: * @return a buffer with the formatted parameters.
michael@0: * If the buffer
argument was not null
,
michael@0: * that buffer will be used and returned.
michael@0: */
michael@0: CharArrayBuffer formatParameters(CharArrayBuffer buffer,
michael@0: NameValuePair[] nvps,
michael@0: boolean quote);
michael@0:
michael@0: /**
michael@0: * Formats one name-value pair, where the value is optional.
michael@0: *
michael@0: * @param buffer the buffer to append to, or
michael@0: * null
to create a new buffer
michael@0: * @param nvp the name-value pair to format
michael@0: * @param quote true
to always format with a quoted value,
michael@0: * false
to use quotes only when necessary
michael@0: *
michael@0: * @return a buffer with the formatted name-value pair.
michael@0: * If the buffer
argument was not null
,
michael@0: * that buffer will be used and returned.
michael@0: */
michael@0: CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer,
michael@0: NameValuePair nvp,
michael@0: boolean quote);
michael@0:
michael@0: }
michael@0: