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


Java CharArrayBuffer.length方法代碼示例

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


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

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

示例2: writeLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Writes characters from the specified char array followed by a line
 * delimiter to this session buffer.
 * <p>
 * This method uses CR-LF as a line delimiter.
 *
 * @param      charbuffer the buffer containing chars of the line.
 * @exception  IOException  if an I/O error occurs.
 */
public void writeLine(final CharArrayBuffer charbuffer) throws IOException {
    if (charbuffer == null) {
        return;
    }
    if (this.ascii) {
        int off = 0;
        int remaining = charbuffer.length();
        while (remaining > 0) {
            int chunk = this.buffer.capacity() - this.buffer.length();
            chunk = Math.min(chunk, remaining);
            if (chunk > 0) {
                this.buffer.append(charbuffer, off, chunk);
            }
            if (this.buffer.isFull()) {
                flushBuffer();
            }
            off += chunk;
            remaining -= chunk;
        }
    } else {
        CharBuffer cbuf = CharBuffer.wrap(charbuffer.buffer(), 0, charbuffer.length());
        writeEncoded(cbuf);
    }
    write(CRLF);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:AbstractSessionOutputBuffer.java

示例3: 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 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: writeLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
 * Writes characters from the specified char array followed by a line
 * delimiter to this session buffer.
 * <p>
 * This method uses CR-LF as a line delimiter.
 *
 * @param      charbuffer the buffer containing chars of the line.
 * @exception  IOException  if an I/O error occurs.
 */
public void writeLine(final CharArrayBuffer charbuffer) throws IOException {
    if (charbuffer == null) {
        return;
    }
    if (this.encoder == null) {
        int off = 0;
        int remaining = charbuffer.length();
        while (remaining > 0) {
            int chunk = this.buffer.capacity() - this.buffer.length();
            chunk = Math.min(chunk, remaining);
            if (chunk > 0) {
                this.buffer.append(charbuffer, off, chunk);
            }
            if (this.buffer.isFull()) {
                flushBuffer();
            }
            off += chunk;
            remaining -= chunk;
        }
    } else {
        final CharBuffer cbuf = CharBuffer.wrap(charbuffer.buffer(), 0, charbuffer.length());
        writeEncoded(cbuf);
    }
    write(CRLF);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:35,代碼來源:SessionOutputBufferImpl.java

示例5: parse

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

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

示例7: parse

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

示例8: parseChallenge

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
    HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
    ParserCursor cursor = new ParserCursor(pos, buffer.length());
    HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (HeaderElement element : elements) {
        this.params.put(element.getName(), element.getValue());
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:RFC2617Scheme.java

示例9: readLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public int readLine(final CharArrayBuffer buffer) throws IOException {
    int l = this.in.readLine(buffer);
    if (this.wire.enabled() && l >= 0) {
        int pos = buffer.length() - l;
        String s = new String(buffer.buffer(), pos, l);
        String tmp = s + "\r\n";
        this.wire.input(tmp.getBytes(this.charset));
    }
    return l;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:LoggingSessionInputBuffer.java

示例10: writeLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
public void writeLine(final CharArrayBuffer buffer) throws IOException {
    this.out.writeLine(buffer);
    if (this.wire.enabled()) {
        String s = new String(buffer.buffer(), 0, buffer.length());
        String tmp = s + "\r\n";
        this.wire.output(tmp.getBytes(this.charset));
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:LoggingSessionOutputBuffer.java

示例11: writeLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@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);
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:9,代碼來源:ByteArraySessionOutputBuffer.java

示例12: readCRLFSeparatedBlock

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
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()]);
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:12,代碼來源:InputStreamTestMocks.java

示例13: parseChallenge

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@Override
protected void parseChallenge(
        final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
    final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
    final ParserCursor cursor = new ParserCursor(pos, buffer.length());
    final HeaderElement[] elements = parser.parseElements(buffer, cursor);
    if (elements.length == 0) {
        throw new MalformedChallengeException("Authentication challenge is empty");
    }
    this.params.clear();
    for (final HeaderElement element : elements) {
        this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:15,代碼來源:RFC2617SchemeHC4.java

示例14: reject

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@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;
}
 
開發者ID:sedmelluq,項目名稱:lavaplayer,代碼行數:11,代碼來源:HttpClientTools.java

示例15: readLine

import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
@Override
public int readLine(final CharArrayBuffer buffer) throws IOException {
    final int l = this.in.readLine(buffer);
    if (this.wire.enabled() && l >= 0) {
        final int pos = buffer.length() - l;
        final String s = new String(buffer.buffer(), pos, l);
        final String tmp = s + "\r\n";
        this.wire.input(tmp.getBytes(this.charset));
    }
    return l;
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:12,代碼來源:LoggingSessionInputBuffer.java


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