本文整理匯總了Java中org.apache.http.util.CharArrayBuffer.ensureCapacity方法的典型用法代碼示例。如果您正苦於以下問題:Java CharArrayBuffer.ensureCapacity方法的具體用法?Java CharArrayBuffer.ensureCapacity怎麽用?Java CharArrayBuffer.ensureCapacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.util.CharArrayBuffer
的用法示例。
在下文中一共展示了CharArrayBuffer.ensureCapacity方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doFormatRequestLine
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Actually formats a request line.
* Called from {@link #formatRequestLine}.
*
* @param buffer the empty buffer into which to format,
* never <code>null</code>
* @param reqline the request line to format, never <code>null</code>
*/
protected void doFormatRequestLine(final CharArrayBuffer buffer,
final RequestLine reqline) {
final String method = reqline.getMethod();
final String uri = reqline.getUri();
// room for "GET /index.html HTTP/1.1"
int len = method.length() + 1 + uri.length() + 1 +
estimateProtocolVersionLen(reqline.getProtocolVersion());
buffer.ensureCapacity(len);
buffer.append(method);
buffer.append(' ');
buffer.append(uri);
buffer.append(' ');
appendProtocolVersion(buffer, reqline.getProtocolVersion());
}
示例2: doFormatStatusLine
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Actually formats a status line.
* Called from {@link #formatStatusLine}.
*
* @param buffer the empty buffer into which to format,
* never <code>null</code>
* @param statline the status line to format, never <code>null</code>
*/
protected void doFormatStatusLine(final CharArrayBuffer buffer,
final StatusLine statline) {
int len = estimateProtocolVersionLen(statline.getProtocolVersion())
+ 1 + 3 + 1; // room for "HTTP/1.1 200 "
final String reason = statline.getReasonPhrase();
if (reason != null) {
len += reason.length();
}
buffer.ensureCapacity(len);
appendProtocolVersion(buffer, statline.getProtocolVersion());
buffer.append(' ');
buffer.append(Integer.toString(statline.getStatusCode()));
buffer.append(' '); // keep whitespace even if reason phrase is empty
if (reason != null) {
buffer.append(reason);
}
}
示例3: doFormatHeader
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Actually formats a header.
* Called from {@link #formatHeader}.
*
* @param buffer the empty buffer into which to format,
* never <code>null</code>
* @param header the header to format, never <code>null</code>
*/
protected void doFormatHeader(final CharArrayBuffer buffer,
final Header header) {
final String name = header.getName();
final String value = header.getValue();
int len = name.length() + 2;
if (value != null) {
len += value.length();
}
buffer.ensureCapacity(len);
buffer.append(name);
buffer.append(": ");
if (value != null) {
buffer.append(value);
}
}
示例4: doFormatRequestLine
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Actually formats a request line.
* Called from {@link #formatRequestLine}.
*
* @param buffer the empty buffer into which to format,
* never <code>null</code>
* @param reqline the request line to format, never <code>null</code>
*/
protected void doFormatRequestLine(final CharArrayBuffer buffer,
final RequestLine reqline) {
final String method = reqline.getMethod();
final String uri = reqline.getUri();
// room for "GET /index.html HTTP/1.1"
final int len = method.length() + 1 + uri.length() + 1 +
estimateProtocolVersionLen(reqline.getProtocolVersion());
buffer.ensureCapacity(len);
buffer.append(method);
buffer.append(' ');
buffer.append(uri);
buffer.append(' ');
appendProtocolVersion(buffer, reqline.getProtocolVersion());
}