当前位置: 首页>>代码示例>>Java>>正文


Java ParserCursor.updatePos方法代码示例

本文整理汇总了Java中org.apache.http.message.ParserCursor.updatePos方法的典型用法代码示例。如果您正苦于以下问题:Java ParserCursor.updatePos方法的具体用法?Java ParserCursor.updatePos怎么用?Java ParserCursor.updatePos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.message.ParserCursor的用法示例。


在下文中一共展示了ParserCursor.updatePos方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyContent

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例2: copyUnquotedContent

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例3: parseParameter

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例4: parseNameValuePair

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例5: skipWhiteSpace

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例6: copyQuotedContent

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例7: copyUnquotedContent

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例8: parseProtocolVersion

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public ProtocolVersion parseProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) {
  int index = cursor.getPos();
  int bound = cursor.getUpperBound();

  if (bound >= index + 4 && "ICY ".equals(buffer.substring(index, index + 4))) {
    cursor.updatePos(index + 4);
    return ICY_PROTOCOL;
  }

  return super.parseProtocolVersion(buffer, cursor);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:13,代码来源:HttpClientTools.java

示例9: parse

import org.apache.http.message.ParserCursor; //导入方法依赖的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

示例10: skipDelims

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
private void skipDelims(final CharSequence 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 (DELIMS.get(current)) {
            pos++;
        } else {
            break;
        }
    }
    cursor.updatePos(pos);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:LaxExpiresHandler.java

示例11: copyContent

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
private void copyContent(final CharSequence buf, final ParserCursor cursor, 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 (DELIMS.get(current)) {
            break;
        } else {
            pos++;
            dst.append(current);
        }
    }
    cursor.updatePos(pos);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:LaxExpiresHandler.java

示例12: parseProtocolVersion

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public ProtocolVersion parseProtocolVersion(CharArrayBuffer buffer, 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");
	}

	final int protolength = ICY_PROTOCOL_NAME.length();

	int indexFrom = cursor.getPos();
	int indexTo = cursor.getUpperBound();

	skipWhitespace(buffer, cursor);

	int i = cursor.getPos();

	// long enough for "HTTP/1.1"?
	if (i + protolength + 4 > indexTo) {
		throw new ParseException("Not a valid protocol version: " + buffer.substring(indexFrom, indexTo));
	}

	// check the protocol name and slash
	if (!buffer.substring(i, i + protolength).equals(ICY_PROTOCOL_NAME)) {
		return super.parseProtocolVersion(buffer, cursor);
	}

	cursor.updatePos(i + protolength);

	return createProtocolVersion(1, 0);
}
 
开发者ID:andrewhanks,项目名称:MediaPlayerProxy,代码行数:34,代码来源:HttpUtils.java


注:本文中的org.apache.http.message.ParserCursor.updatePos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。