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


Java ParserCursor.atEnd方法代码示例

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


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

示例1: parseHeader

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
public HeaderElement parseHeader(
        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");
    }
    NameValuePair nvp = parseNameValuePair(buffer, cursor);
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair param = parseNameValuePair(buffer, cursor);
        params.add(param);
    }
    return new BasicHeaderElement(
            nvp.getName(),
            nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:NetscapeDraftHeaderParser.java

示例2: 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 s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:URLEncodedUtils.java

示例3: 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 s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 * @param parameterSeparator
 *            The characters used to separate parameters, by convention, {@code '&'} and {@code ';'}.
 * @return a list of {@link NameValuePair} as built from the URI's query portion.
 *
 * @since 4.3
 */
public static List<NameValuePair> parse(final String s, final Charset charset, final char... parameterSeparator) {
    if (s == null) {
        return Collections.emptyList();
    }
    final BasicHeaderValueParserHC4 parser = BasicHeaderValueParserHC4.INSTANCE;
    final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    final ParserCursor cursor = new ParserCursor(0, buffer.length());
    final List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        final NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, parameterSeparator);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:34,代码来源:URLEncodedUtilsHC4.java

示例4: parseToken

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

示例5: 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

示例6: parse

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
 * Returns a list of {@link org.apache.http.NameValuePair NameValuePairs} as parsed.
 *
 * @param s text to parse.
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(nvp.getName(), nvp.getValue()));
        }
    }
    return list;
}
 
开发者ID:BigAppOS,项目名称:BigApp_Discuz_Android,代码行数:24,代码来源:URLEncodedUtils.java

示例7: 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 s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
	if (s == null)
		return Collections.emptyList();
	BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
	CharArrayBuffer buffer = new CharArrayBuffer(s.length());
	buffer.append(s);
	ParserCursor cursor = new ParserCursor(0, buffer.length());
	List<NameValuePair> list = new ArrayList<NameValuePair>();
	while (!cursor.atEnd()) {
		NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
		if (nvp.getName().length() > 0)
			list.add(new BasicNameValuePair(
					decodeFormFields(nvp.getName(), charset),
					decodeFormFields(nvp.getValue(), charset)));
	}
	return list;
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:URLEncodedUtils.java

示例8: 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

示例9: parseHeader

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
public HeaderElement parseHeader(
        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");
    }
    NameValuePair nvp = this.nvpParser.parseNameValuePair(buffer, cursor, DELIMITERS);
    List<NameValuePair> params = new ArrayList<NameValuePair>(); 
    while (!cursor.atEnd()) {
        NameValuePair param = this.nvpParser.parseNameValuePair(buffer, cursor, DELIMITERS);
        params.add(param);
    }
    return new BasicHeaderElement(
            nvp.getName(), 
            nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:20,代码来源:NetscapeDraftHeaderParser.java

示例10: parse

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
 * Returns a list of {@link NameValuePair NameValuePairs} as deserialized from the given string
 * using the given character encoding.
 *
 * @param s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 *
 * @since 4.2
 */
public static List<NameValuePair> parse (final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser deserializer = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = deserializer.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:sahan,项目名称:RoboZombie,代码行数:31,代码来源:URLEncodedUtils.java

示例11: 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 s
 *            text to parse.
 * @param charset
 *            Encoding to use when decoding the parameters.
 * 
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(decodeFormFields(nvp.getName(), charset), decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:mobilesystems,项目名称:box-java-sdk-v2,代码行数:28,代码来源:HttpClientURLEncodedUtils.java

示例12: parse

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
 * Returns a list of {@link org.apache.http.NameValuePair NameValuePairs} as parsed from the given string
 * using the given character encoding.
 *
 * @param s       text to parse.
 * @param charset Encoding to use when decoding the parameters.
 * @since 4.2
 */
public static List<NameValuePair> parse(final String s, final Charset charset) {
    if (s == null) {
        return Collections.emptyList();
    }
    BasicHeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    CharArrayBuffer buffer = new CharArrayBuffer(s.length());
    buffer.append(s);
    ParserCursor cursor = new ParserCursor(0, buffer.length());
    List<NameValuePair> list = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        NameValuePair nvp = parser.parseNameValuePair(buffer, cursor, DELIM);
        if (nvp.getName().length() > 0) {
            list.add(new BasicNameValuePair(
                    decodeFormFields(nvp.getName(), charset),
                    decodeFormFields(nvp.getValue(), charset)));
        }
    }
    return list;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:28,代码来源:URLEncodedUtils.java

示例13: parseHeader

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
public HeaderElement parseHeader(
        final CharArrayBuffer buffer,
        final ParserCursor cursor) throws ParseException {
    Args.notNull(buffer, "Char array buffer");
    Args.notNull(cursor, "Parser cursor");
    final NameValuePair nvp = parseNameValuePair(buffer, cursor);
    final List<NameValuePair> params = new ArrayList<NameValuePair>();
    while (!cursor.atEnd()) {
        final NameValuePair param = parseNameValuePair(buffer, cursor);
        params.add(param);
    }
    return new BasicHeaderElement(
            nvp.getName(),
            nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:16,代码来源:NetscapeDraftHeaderParserHC4.java

示例14: parseValue

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

示例15: 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


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