|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.message.BasicLineFormatter
@Contract(threading=IMMUTABLE) public class BasicLineFormatter
Interface for formatting elements of the HEAD section of an HTTP message.
This is the complement to 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.
Field Summary | |
---|---|
static BasicLineFormatter |
DEFAULT
Deprecated. (4.3) use INSTANCE |
static BasicLineFormatter |
INSTANCE
|
Constructor Summary | |
---|---|
BasicLineFormatter()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated public static final BasicLineFormatter DEFAULT
INSTANCE
BasicLineFormatter
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
Constructor Detail |
---|
public BasicLineFormatter()
Method Detail |
---|
protected CharArrayBuffer initBuffer(CharArrayBuffer charBuffer)
charBuffer
- a buffer already available, or null
public static String formatProtocolVersion(ProtocolVersion version, LineFormatter formatter)
version
- the protocol version to formatformatter
- the formatter to use, or
null
for the
default
public CharArrayBuffer appendProtocolVersion(CharArrayBuffer buffer, ProtocolVersion version)
LineFormatter
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
.
appendProtocolVersion
in interface LineFormatter
buffer
- a buffer to which to append, or null
version
- the protocol version to format
buffer
argument is not null
,
the returned buffer is the argument buffer.protected int estimateProtocolVersionLen(ProtocolVersion version)
version
- the protocol version to format, or null
public static String formatRequestLine(RequestLine reqline, LineFormatter formatter)
reqline
- the request line to formatformatter
- the formatter to use, or
null
for the
default
public CharArrayBuffer formatRequestLine(CharArrayBuffer buffer, RequestLine reqline)
LineFormatter
formatRequestLine
in interface LineFormatter
buffer
- a buffer available for formatting, or
null
.
The buffer will be cleared before use.reqline
- the request line to format
protected 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 null
reqline
- the request line to format, never null
public static String formatStatusLine(StatusLine statline, LineFormatter formatter)
statline
- the status line to formatformatter
- the formatter to use, or
null
for the
default
public CharArrayBuffer formatStatusLine(CharArrayBuffer buffer, StatusLine statline)
LineFormatter
formatStatusLine
in interface LineFormatter
buffer
- a buffer available for formatting, or
null
.
The buffer will be cleared before use.statline
- the status line to format
protected 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 null
statline
- the status line to format, never null
public static String formatHeader(Header header, LineFormatter formatter)
header
- the header to formatformatter
- the formatter to use, or
null
for the
default
public CharArrayBuffer formatHeader(CharArrayBuffer buffer, Header header)
LineFormatter
See the class comment for details about the buffer argument.
formatHeader
in interface LineFormatter
buffer
- a buffer available for formatting, or
null
.
The buffer will be cleared before use.header
- the header to format
null
.
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 null
header
- the header to format, never null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |