本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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));
}
}
示例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);
}
示例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()]);
}
示例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());
}
}
示例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;
}
示例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;
}