當前位置: 首頁>>代碼示例>>Java>>正文


Java CharArrayBuffer.ensureCapacity方法代碼示例

本文整理匯總了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());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:BasicLineFormatter.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:BasicLineFormatter.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:BasicLineFormatter.java

示例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());
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:25,代碼來源:BasicLineFormatterHC4.java


注:本文中的org.apache.http.util.CharArrayBuffer.ensureCapacity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。