org.apache.http.util.CharArrayBuffer#length ( )源码实例Demo

下面列出了org.apache.http.util.CharArrayBuffer#length ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BigApp_Discuz_Android   文件: URLEncodedUtils.java
/**
 * 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;
}
 
/**
 * 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;
}
 
源代码3 项目: RoboZombie   文件: URLEncodedUtils.java
/**
 * 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;
}
 
源代码4 项目: BUbiNG   文件: ByteArraySessionOutputBuffer.java
@Override
public void writeLine(final CharArrayBuffer buffer) throws IOException {
	if (buffer == null) return;
	for (int i = 0; i < buffer.length(); i++) {
		write(buffer.charAt(i));
	}
	write(CRLF);
}
 
源代码5 项目: BUbiNG   文件: InputStreamTestMocks.java
public static String[] readCRLFSeparatedBlock(SessionInputBuffer input) throws IOException {
	CharArrayBuffer line = new CharArrayBuffer(128);
	List<String> ret = new ArrayList<>();
	for (;;) {
		if (input.readLine(line) == -1) break;
		if (line.length() == 0) break;
		ret.add(line.toString());
		line.clear();
	}
	return ret.toArray(new String[ret.size()]);
}
 
源代码6 项目: lavaplayer   文件: ExtendedHttpClientBuilder.java
@Override
protected boolean reject(CharArrayBuffer line, int count) {
  if (line.length() > 4 && "ICY ".equals(line.substring(0, 4))) {
    throw new FriendlyException("ICY protocol is not supported.", COMMON, null);
  } else if (count > 10) {
    throw new FriendlyException("The server is giving us garbage.", SUSPICIOUS, null);
  }

  return false;
}
 
源代码7 项目: MediaPlayerProxy   文件: HttpUtils.java
@Override
public boolean hasProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) {
	boolean superFound = super.hasProtocolVersion(buffer, cursor);
	if (superFound) {
		return true;
	}
	int index = cursor.getPos();

	final int protolength = ICY_PROTOCOL_NAME.length();

	if (buffer.length() < protolength)
		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() - 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

	return index + protolength <= buffer.length()
			&& buffer.substring(index, index + protolength).equals(ICY_PROTOCOL_NAME);

}