FileDocCategorySizeDatePackage
LineFormatter.javaAPI DocAndroid 1.5 API5809Wed May 06 22:41:10 BST 2009org.apache.http.message

LineFormatter

public interface LineFormatter
Interface for formatting elements of the HEAD section of an HTTP message. This is the complement to {@link LineParser}. There are individual methods for formatting a request line, a status line, or a header line. The formatting does not include the trailing line break sequence CR-LF. Instances of this interface are expected to be stateless and thread-safe.

The formatted lines are returned in memory, the formatter does not depend on any specific IO mechanism. In order to avoid unnecessary creation of temporary objects, a buffer can be passed as argument to all formatting methods. The implementation may or may not actually use that buffer for formatting. If it is used, the buffer will first be cleared by the formatXXX methods. The argument buffer can always be re-used after the call. The buffer returned as the result, if it is different from the argument buffer, MUST NOT be modified.

author
Roland Weber
version
$Revision: 573864 $ $Date: 2007-09-08 08:53:25 -0700 (Sat, 08 Sep 2007) $
since
4.0

Fields Summary
Constructors Summary
Methods Summary
public org.apache.http.util.CharArrayBufferappendProtocolVersion(org.apache.http.util.CharArrayBuffer buffer, org.apache.http.ProtocolVersion version)
Formats a protocol version. This method does not follow the general contract for buffer arguments. It does not clear the argument buffer, but appends instead. The returned buffer can always be modified by the caller. Because of these differing conventions, it is not named formatProtocolVersion.

param
buffer a buffer to which to append, or null
param
version the protocol version to format
return
a buffer with the formatted protocol version appended. The caller is allowed to modify the result buffer. If the buffer argument is not null, the returned buffer is the argument buffer.

public org.apache.http.util.CharArrayBufferformatHeader(org.apache.http.util.CharArrayBuffer buffer, org.apache.http.Header header)
Formats a header. Due to header continuation, the result may be multiple lines. In order to generate well-formed HTTP, the lines in the result must be separated by the HTTP line break sequence CR-LF. There is no trailing CR-LF in the result.
See the class comment for details about the buffer argument.

param
buffer a buffer available for formatting, or null. The buffer will be cleared before use.
param
header the header to format
return
a buffer holding the formatted header, never null. The returned buffer may be different from the argument buffer.
throws
ParseException in case of a parse error

public org.apache.http.util.CharArrayBufferformatRequestLine(org.apache.http.util.CharArrayBuffer buffer, org.apache.http.RequestLine reqline)
Formats a request line.

param
buffer a buffer available for formatting, or null. The buffer will be cleared before use.
param
reqline the request line to format
return
the formatted request line

public org.apache.http.util.CharArrayBufferformatStatusLine(org.apache.http.util.CharArrayBuffer buffer, org.apache.http.StatusLine statline)
Formats a status line.

param
buffer a buffer available for formatting, or null. The buffer will be cleared before use.
param
statline the status line to format
return
the formatted status line
throws
ParseException in case of a parse error