@Contract(threading=IMMUTABLE) public class BasicLineFormatter extends Object implements LineFormatter
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.
The formatted lines are returned in memory, the formatter does not depend
on any specific IO mechanism.
Instances of this interface are expected to be stateless and thread-safe.| Modifier and Type | Field and Description |
|---|---|
static BasicLineFormatter |
DEFAULT
Deprecated.
(4.3) use
INSTANCE |
static BasicLineFormatter |
INSTANCE |
| Constructor and Description |
|---|
BasicLineFormatter() |
| Modifier and Type | Method and Description |
|---|---|
CharArrayBuffer |
appendProtocolVersion(CharArrayBuffer buffer,
ProtocolVersion version)
Formats a protocol version.
|
protected void |
doFormatHeader(CharArrayBuffer buffer,
Header header)
Actually formats a header.
|
protected void |
doFormatRequestLine(CharArrayBuffer buffer,
RequestLine reqline)
Actually formats a request line.
|
protected void |
doFormatStatusLine(CharArrayBuffer buffer,
StatusLine statline)
Actually formats a status line.
|
protected int |
estimateProtocolVersionLen(ProtocolVersion version)
Guesses the length of a formatted protocol version.
|
CharArrayBuffer |
formatHeader(CharArrayBuffer buffer,
Header header)
Formats a header.
|
static String |
formatHeader(Header header,
LineFormatter formatter)
Formats a header.
|
static String |
formatProtocolVersion(ProtocolVersion version,
LineFormatter formatter)
Formats a protocol version.
|
CharArrayBuffer |
formatRequestLine(CharArrayBuffer buffer,
RequestLine reqline)
Formats a request line.
|
static String |
formatRequestLine(RequestLine reqline,
LineFormatter formatter)
Formats a request line.
|
CharArrayBuffer |
formatStatusLine(CharArrayBuffer buffer,
StatusLine statline)
Formats a status line.
|
static String |
formatStatusLine(StatusLine statline,
LineFormatter formatter)
Formats a status line.
|
protected CharArrayBuffer |
initBuffer(CharArrayBuffer charBuffer)
Obtains a buffer for formatting.
|
@Deprecated public static final BasicLineFormatter DEFAULT
INSTANCEBasicLineFormatter is not a singleton, there can
be many instances of the class itself and of derived classes.
The instance here provides non-customized, default behavior.public static final BasicLineFormatter INSTANCE
protected CharArrayBuffer initBuffer(CharArrayBuffer charBuffer)
charBuffer - a buffer already available, or nullpublic static String formatProtocolVersion(ProtocolVersion version, LineFormatter formatter)
version - the protocol version to formatformatter - the formatter to use, or
null for the
defaultpublic CharArrayBuffer appendProtocolVersion(CharArrayBuffer buffer, ProtocolVersion version)
LineFormatterbuffer 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.appendProtocolVersion in interface LineFormatterbuffer - a buffer to which to append, or nullversion - the protocol version to formatbuffer argument is not null,
the returned buffer is the argument buffer.protected int estimateProtocolVersionLen(ProtocolVersion version)
version - the protocol version to format, or nullpublic static String formatRequestLine(RequestLine reqline, LineFormatter formatter)
reqline - the request line to formatformatter - the formatter to use, or
null for the
defaultpublic CharArrayBuffer formatRequestLine(CharArrayBuffer buffer, RequestLine reqline)
LineFormatterformatRequestLine in interface LineFormatterbuffer - a buffer available for formatting, or
null.
The buffer will be cleared before use.reqline - the request line to formatprotected void doFormatRequestLine(CharArrayBuffer buffer, RequestLine reqline)
formatRequestLine(org.apache.http.RequestLine, org.apache.http.message.LineFormatter).buffer - the empty buffer into which to format,
never nullreqline - the request line to format, never nullpublic static String formatStatusLine(StatusLine statline, LineFormatter formatter)
statline - the status line to formatformatter - the formatter to use, or
null for the
defaultpublic CharArrayBuffer formatStatusLine(CharArrayBuffer buffer, StatusLine statline)
LineFormatterformatStatusLine in interface LineFormatterbuffer - a buffer available for formatting, or
null.
The buffer will be cleared before use.statline - the status line to formatprotected void doFormatStatusLine(CharArrayBuffer buffer, StatusLine statline)
formatStatusLine(org.apache.http.StatusLine, org.apache.http.message.LineFormatter).buffer - the empty buffer into which to format,
never nullstatline - the status line to format, never nullpublic static String formatHeader(Header header, LineFormatter formatter)
header - the header to formatformatter - the formatter to use, or
null for the
defaultpublic CharArrayBuffer formatHeader(CharArrayBuffer buffer, Header header)
LineFormatterSee the class comment for details about the buffer argument.
formatHeader in interface LineFormatterbuffer - a buffer available for formatting, or
null.
The buffer will be cleared before use.header - the header to formatnull.
The returned buffer may be different from the argument buffer.protected void doFormatHeader(CharArrayBuffer buffer, Header header)
formatHeader(org.apache.http.Header, org.apache.http.message.LineFormatter).buffer - the empty buffer into which to format,
never nullheader - the header to format, never nullCopyright © 2005–2022 The Apache Software Foundation. All rights reserved.