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


Java CharArrayBuffer.substring方法代碼示例

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


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

示例1: parseRequestLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Parses a request line.
 *
 * @param buffer    a buffer holding the line to parse
 *
 * @return  the parsed request line
 *
 * @throws ParseException        in case of a parse error
 */
public RequestLine parseRequestLine(final CharArrayBuffer buffer,
                                    final ParserCursor cursor)
    throws ParseException {

    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 indexFrom = cursor.getPos();
    int indexTo = cursor.getUpperBound();

    try {
        skipWhitespace(buffer, cursor);
        int i = cursor.getPos();

        int blank = buffer.indexOf(' ', i, indexTo);
        if (blank < 0) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }
        String method = buffer.substringTrimmed(i, blank);
        cursor.updatePos(blank);

        skipWhitespace(buffer, cursor);
        i = cursor.getPos();

        blank = buffer.indexOf(' ', i, indexTo);
        if (blank < 0) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }
        String uri = buffer.substringTrimmed(i, blank);
        cursor.updatePos(blank);

        ProtocolVersion ver = parseProtocolVersion(buffer, cursor);

        skipWhitespace(buffer, cursor);
        if (!cursor.atEnd()) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }

        return createRequestLine(method, uri, ver);
    } catch (IndexOutOfBoundsException e) {
        throw new ParseException("Invalid request line: " +
                                 buffer.substring(indexFrom, indexTo));
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:61,代碼來源:BasicLineParser.java

示例2: parseRequestLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Parses a request line.
 *
 * @param buffer    a buffer holding the line to parse
 *
 * @return  the parsed request line
 *
 * @throws ParseException        in case of a parse error
 */
public RequestLine parseRequestLine(final CharArrayBuffer buffer,
                                    final ParserCursor cursor) throws ParseException {

    Args.notNull(buffer, "Char array buffer");
    Args.notNull(cursor, "Parser cursor");
    final int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();

    try {
        skipWhitespace(buffer, cursor);
        int i = cursor.getPos();

        int blank = buffer.indexOf(' ', i, indexTo);
        if (blank < 0) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }
        final String method = buffer.substringTrimmed(i, blank);
        cursor.updatePos(blank);

        skipWhitespace(buffer, cursor);
        i = cursor.getPos();

        blank = buffer.indexOf(' ', i, indexTo);
        if (blank < 0) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }
        final String uri = buffer.substringTrimmed(i, blank);
        cursor.updatePos(blank);

        final ProtocolVersion ver = parseProtocolVersion(buffer, cursor);

        skipWhitespace(buffer, cursor);
        if (!cursor.atEnd()) {
            throw new ParseException("Invalid request line: " +
                    buffer.substring(indexFrom, indexTo));
        }

        return createRequestLine(method, uri, ver);
    } catch (final IndexOutOfBoundsException e) {
        throw new ParseException("Invalid request line: " +
                                 buffer.substring(indexFrom, indexTo));
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:55,代碼來源:BasicLineParserHC4.java


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