当前位置: 首页>>代码示例>>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;未经允许,请勿转载。