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


Java CharArrayBuffer.charAt方法代碼示例

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


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

示例1: parseHeaderElement

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public HeaderElement parseHeaderElement(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");
    }

    NameValuePair nvp = parseNameValuePair(buffer, cursor);
    NameValuePair[] params = null;
    if (!cursor.atEnd()) {
        char ch = buffer.charAt(cursor.getPos() - 1);
        if (ch != ELEM_DELIMITER) {
            params = parseParameters(buffer, cursor);
        }
    }
    return createHeaderElement(nvp.getName(), nvp.getValue(), params);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:BasicHeaderValueParser.java

示例2: parseToken

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Extracts from the sequence of chars a token terminated with any of the given delimiters
 * discarding semantically insignificant whitespace characters.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param delimiters set of delimiting characters. Can be <code>null</code> if the token
 *  is not delimited by any character.
 */
public String parseToken(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
    final StringBuilder dst = new StringBuilder();
    boolean whitespace = false;
    while (!cursor.atEnd()) {
        final char current = buf.charAt(cursor.getPos());
        if (delimiters != null && delimiters.get(current)) {
            break;
        } else if (isWhitespace(current)) {
            skipWhiteSpace(buf, cursor);
            whitespace = true;
        } else {
            if (whitespace && dst.length() > 0) {
                dst.append(' ');
            }
            copyContent(buf, cursor, delimiters, dst);
            whitespace = false;
        }
    }
    return dst.toString();
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:30,代碼來源:TokenParser.java

示例3: copyContent

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Transfers content into the destination buffer until a whitespace character or any of
 * the given delimiters is encountered.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param delimiters set of delimiting characters. Can be <code>null</code> if the value
 *  is delimited by a whitespace only.
 * @param dst destination buffer
 */
public void copyContent(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters,
        final StringBuilder dst) {
    int pos = cursor.getPos();
    final int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();
    for (int i = indexFrom; i < indexTo; i++) {
        final char current = buf.charAt(i);
        if ((delimiters != null && delimiters.get(current)) || isWhitespace(current)) {
            break;
        } else {
            pos++;
            dst.append(current);
        }
    }
    cursor.updatePos(pos);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:27,代碼來源:TokenParser.java

示例4: copyUnquotedContent

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Transfers content into the destination buffer until a whitespace character,  a quote,
 * or any of the given delimiters is encountered.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param delimiters set of delimiting characters. Can be <code>null</code> if the value
 *  is delimited by a whitespace or a quote only.
 * @param dst destination buffer
 */
public void copyUnquotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
        final BitSet delimiters, final StringBuilder dst) {
    int pos = cursor.getPos();
    final int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();
    for (int i = indexFrom; i < indexTo; i++) {
        final char current = buf.charAt(i);
        if ((delimiters != null && delimiters.get(current))
                || isWhitespace(current) || current == DQUOTE) {
            break;
        } else {
            pos++;
            dst.append(current);
        }
    }
    cursor.updatePos(pos);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:28,代碼來源:TokenParser.java

示例5: parseParameter

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
NameValuePair parseParameter(final CharArrayBuffer buf, final ParserCursor cursor) {
    final String name = parseToken(buf, cursor, EQUAL_OR_COMMA_OR_PLUS);
    if (cursor.atEnd()) {
        return new BasicNameValuePair(name, null);
    }
    final int delim = buf.charAt(cursor.getPos());
    cursor.updatePos(cursor.getPos() + 1);
    if (delim == ',') {
        return new BasicNameValuePair(name, null);
    }
    final String value = parseValue(buf, cursor, COMMA_OR_PLUS);
    if (!cursor.atEnd()) {
        cursor.updatePos(cursor.getPos() + 1);
    }
    return new BasicNameValuePair(name, value);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:17,代碼來源:DistinguishedNameParser.java

示例6: parseNameValuePair

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
private NameValuePair parseNameValuePair(
        final CharArrayBuffer buffer, final ParserCursor cursor) {
    final String name = tokenParser.parseToken(buffer, cursor, TOKEN_DELIMS);
    if (cursor.atEnd()) {
        return new BasicNameValuePair(name, null);
    }
    final int delim = buffer.charAt(cursor.getPos());
    cursor.updatePos(cursor.getPos() + 1);
    if (delim != '=') {
        return new BasicNameValuePair(name, null);
    }
    final String value = tokenParser.parseToken(buffer, cursor, VALUE_DELIMS);
    if (!cursor.atEnd()) {
        cursor.updatePos(cursor.getPos() + 1);
    }
    return new BasicNameValuePair(name, value);
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:18,代碼來源:NetscapeDraftHeaderParser.java

示例7: parseHeaderElement

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public HeaderElement parseHeaderElement(final CharArrayBuffer buffer,
                                        final ParserCursor cursor) {
    Args.notNull(buffer, "Char array buffer");
    Args.notNull(cursor, "Parser cursor");
    final NameValuePair nvp = parseNameValuePair(buffer, cursor);
    NameValuePair[] params = null;
    if (!cursor.atEnd()) {
        final char ch = buffer.charAt(cursor.getPos() - 1);
        if (ch != ELEM_DELIMITER) {
            params = parseParameters(buffer, cursor);
        }
    }
    return createHeaderElement(nvp.getName(), nvp.getValue(), params);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:15,代碼來源:BasicHeaderValueParserHC4.java

示例8: parseValue

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Extracts from the sequence of chars a value which can be enclosed in quote marks and
 * terminated with any of the given delimiters discarding semantically insignificant
 * whitespace characters.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param delimiters set of delimiting characters. Can be <code>null</code> if the value
 *  is not delimited by any character.
 */
public String parseValue(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
    final StringBuilder dst = new StringBuilder();
    boolean whitespace = false;
    while (!cursor.atEnd()) {
        final char current = buf.charAt(cursor.getPos());
        if (delimiters != null && delimiters.get(current)) {
            break;
        } else if (isWhitespace(current)) {
            skipWhiteSpace(buf, cursor);
            whitespace = true;
        } else if (current == DQUOTE) {
            if (whitespace && dst.length() > 0) {
                dst.append(' ');
            }
            copyQuotedContent(buf, cursor, dst);
            whitespace = false;
        } else {
            if (whitespace && dst.length() > 0) {
                dst.append(' ');
            }
            copyUnquotedContent(buf, cursor, delimiters, dst);
            whitespace = false;
        }
    }
    return dst.toString();
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:37,代碼來源:TokenParser.java

示例9: skipWhiteSpace

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Skips semantically insignificant whitespace characters and moves the cursor to the closest
 * non-whitespace character.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 */
public void skipWhiteSpace(final CharArrayBuffer buf, final ParserCursor cursor) {
    int pos = cursor.getPos();
    final int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();
    for (int i = indexFrom; i < indexTo; i++) {
        final char current = buf.charAt(i);
        if (!isWhitespace(current)) {
            break;
        } else {
            pos++;
        }
    }
    cursor.updatePos(pos);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:22,代碼來源:TokenParser.java

示例10: copyQuotedContent

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Transfers content enclosed with quote marks into the destination buffer.
 *
 * @param buf buffer with the sequence of chars to be parsed
 * @param cursor defines the bounds and current position of the buffer
 * @param dst destination buffer
 */
public void copyQuotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
        final StringBuilder dst) {
    if (cursor.atEnd()) {
        return;
    }
    int pos = cursor.getPos();
    int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();
    char current = buf.charAt(pos);
    if (current != DQUOTE) {
        return;
    }
    pos++;
    indexFrom++;
    boolean escaped = false;
    for (int i = indexFrom; i < indexTo; i++, pos++) {
        current = buf.charAt(i);
        if (escaped) {
            if (current != DQUOTE && current != ESCAPE) {
                dst.append(ESCAPE);
            }
            dst.append(current);
            escaped = false;
        } else {
            if (current == DQUOTE) {
                pos++;
                break;
            }
            if (current == ESCAPE) {
                escaped = true;
            } else if (current != CR && current != LF) {
                dst.append(current);
            }
        }
    }
    cursor.updatePos(pos);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:45,代碼來源:TokenParser.java

示例11: copyUnquotedContent

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@Override
public void copyUnquotedContent(
        final CharArrayBuffer buf,
        final ParserCursor cursor,
        final BitSet delimiters,
        final StringBuilder dst) {
    int pos = cursor.getPos();
    final int indexFrom = cursor.getPos();
    final int indexTo = cursor.getUpperBound();
    boolean escaped = false;
    for (int i = indexFrom; i < indexTo; i++, pos++) {
        final char current = buf.charAt(i);
        if (escaped) {
            dst.append(current);
            escaped = false;
        } else {
            if ((delimiters != null && delimiters.get(current))
                    || TokenParser.isWhitespace(current) || current == '\"') {
                break;
            } else if (current == '\\') {
                escaped = true;
            } else {
                dst.append(current);
            }
        }
    }
    cursor.updatePos(pos);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:29,代碼來源:DistinguishedNameParser.java

示例12: parse

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Returns a list of {@link NameValuePair NameValuePairs} as parsed from the given string using
 * the given character encoding.
 *
 * @param buf
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 * @param separators
 *            element separators.
 * @return a list of {@link NameValuePair} as built from the URI's query portion.
 *
 * @since 4.4
 */
public static List<NameValuePair> parse(
        final CharArrayBuffer buf, final Charset charset, final char... separators) {
    Args.notNull(buf, "Char array buffer");
    final TokenParser tokenParser = TokenParser.INSTANCE;
    final BitSet delimSet = new BitSet();
    for (final char separator: separators) {
        delimSet.set(separator);
    }
    final ParserCursor cursor = new ParserCursor(0, buf.length());
    final List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        delimSet.set('=');
        final String name = tokenParser.parseToken(buf, cursor, delimSet);
        String value = null;
        if (!cursor.atEnd()) {
            final int delim = buf.charAt(cursor.getPos());
            cursor.updatePos(cursor.getPos() + 1);
            if (delim == '=') {
                delimSet.clear('=');
                value = tokenParser.parseValue(buf, cursor, delimSet);
                if (!cursor.atEnd()) {
                    cursor.updatePos(cursor.getPos() + 1);
                }
            }
        }
        if (!name.isEmpty()) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(name, charset),
                    decodeFormFields(value, charset)));
        }
    }
    return list;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:48,代碼來源:URLEncodedUtils.java

示例13: hasProtocolVersion

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的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

示例14: hasProtocolVersion

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public boolean hasProtocolVersion(final CharArrayBuffer buffer,
                                  final ParserCursor cursor) {
    Args.notNull(buffer, "Char array buffer");
    Args.notNull(cursor, "Parser cursor");
    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:xxonehjh,項目名稱:remote-files-sync,代碼行數:44,代碼來源:BasicLineParserHC4.java


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