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


Java HTTP.isWhitespace方法代碼示例

本文整理匯總了Java中org.apache.http.protocol.HTTP.isWhitespace方法的典型用法代碼示例。如果您正苦於以下問題:Java HTTP.isWhitespace方法的具體用法?Java HTTP.isWhitespace怎麽用?Java HTTP.isWhitespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.protocol.HTTP的用法示例。


在下文中一共展示了HTTP.isWhitespace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: substringTrimmed

import org.apache.http.protocol.HTTP; //導入方法依賴的package包/類
/**
 * Returns a substring of this buffer with leading and trailing whitespace
 * omitted. The substring begins with the first non-whitespace character
 * from <code>beginIndex</code> and extends to the last
 * non-whitespace character with the index lesser than
 * <code>endIndex</code>.
 *
 * @param      beginIndex   the beginning index, inclusive.
 * @param      endIndex     the ending index, exclusive.
 * @return     the specified substring.
 * @exception  IndexOutOfBoundsException  if the
 *             <code>beginIndex</code> is negative, or
 *             <code>endIndex</code> is larger than the length of this
 *             buffer, or <code>beginIndex</code> is larger than
 *             <code>endIndex</code>.
 */
public String substringTrimmed(int beginIndex, int endIndex) {
    if (beginIndex < 0) {
        throw new IndexOutOfBoundsException("Negative beginIndex: "+beginIndex);
    }
    if (endIndex > this.len) {
        throw new IndexOutOfBoundsException("endIndex: "+endIndex+" > length: "+this.len);
    }
    if (beginIndex > endIndex) {
        throw new IndexOutOfBoundsException("beginIndex: "+beginIndex+" > endIndex: "+endIndex);
    }
    while (beginIndex < endIndex && HTTP.isWhitespace(this.buffer[beginIndex])) {
        beginIndex++;
    }
    while (endIndex > beginIndex && HTTP.isWhitespace(this.buffer[endIndex - 1])) {
        endIndex--;
    }
    return new String(this.buffer, beginIndex, endIndex - beginIndex);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:CharArrayBuffer.java

示例2: skipWhitespace

import org.apache.http.protocol.HTTP; //導入方法依賴的package包/類
/**
 * Helper to skip whitespace.
 */
protected void skipWhitespace(final CharArrayBuffer buffer, final ParserCursor cursor) {
    int pos = cursor.getPos();
    int indexTo = cursor.getUpperBound();
    while ((pos < indexTo) &&
           HTTP.isWhitespace(buffer.charAt(pos))) {
        pos++;
    }
    cursor.updatePos(pos);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:BasicLineParser.java

示例3: hasProtocolVersion

import org.apache.http.protocol.HTTP; //導入方法依賴的package包/類
public boolean hasProtocolVersion(final CharArrayBuffer buffer,
                                  final ParserCursor cursor) {

    if (buffer == null) {
        throw new IllegalArgumentException("Char array buffer may not be null");
    }
    if (cursor == null) {
        throw new IllegalArgumentException("Parser cursor may not be null");
    }
    int index = cursor.getPos();

    final String protoname = this.protocol.getProtocol();
    final int  protolength = protoname.length();

    if (buffer.length() < protolength+4)
        return false; // not long enough for "HTTP/1.1"

    if (index < 0) {
        // end of line, no tolerance for trailing whitespace
        // this works only for single-digit major and minor version
        index = buffer.length() -4 -protolength;
    } else if (index == 0) {
        // beginning of line, tolerate leading whitespace
        while ((index < buffer.length()) &&
                HTTP.isWhitespace(buffer.charAt(index))) {
             index++;
         }
    } // else within line, don't tolerate whitespace


    if (index + protolength + 4 > buffer.length())
        return false;


    // just check protocol name and slash, no need to analyse the version
    boolean ok = true;
    for (int j=0; ok && (j<protolength); j++) {
        ok = (buffer.charAt(index+j) == protoname.charAt(j));
    }
    if (ok) {
        ok = (buffer.charAt(index+protolength) == '/');
    }

    return ok;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:46,代碼來源:BasicLineParser.java


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