本文整理匯總了Java中org.apache.http.util.CharArrayBuffer.indexOf方法的典型用法代碼示例。如果您正苦於以下問題:Java CharArrayBuffer.indexOf方法的具體用法?Java CharArrayBuffer.indexOf怎麽用?Java CharArrayBuffer.indexOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.util.CharArrayBuffer
的用法示例。
在下文中一共展示了CharArrayBuffer.indexOf方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BufferedHeader
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Creates a new header from a buffer.
* The name of the header will be parsed immediately,
* the value only if it is accessed.
*
* @param buffer the buffer containing the header to represent
*
* @throws ParseException in case of a parse error
*/
public BufferedHeader(final CharArrayBuffer buffer)
throws ParseException {
super();
if (buffer == null) {
throw new IllegalArgumentException
("Char array buffer may not be null");
}
int colon = buffer.indexOf(':');
if (colon == -1) {
throw new ParseException
("Invalid header: " + buffer.toString());
}
String s = buffer.substringTrimmed(0, colon);
if (s.length() == 0) {
throw new ParseException
("Invalid header: " + buffer.toString());
}
this.buffer = buffer;
this.name = s;
this.valuePos = colon + 1;
}
示例2: parseRequestLine
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Parses a request line.
*
* @param buffer a buffer holding the line to parse
*
* @return the parsed request line
*
* @throws ParseException in case of a parse error
*/
public RequestLine parseRequestLine(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");
}
int indexFrom = cursor.getPos();
int indexTo = cursor.getUpperBound();
try {
skipWhitespace(buffer, cursor);
int i = cursor.getPos();
int blank = buffer.indexOf(' ', i, indexTo);
if (blank < 0) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
String method = buffer.substringTrimmed(i, blank);
cursor.updatePos(blank);
skipWhitespace(buffer, cursor);
i = cursor.getPos();
blank = buffer.indexOf(' ', i, indexTo);
if (blank < 0) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
String uri = buffer.substringTrimmed(i, blank);
cursor.updatePos(blank);
ProtocolVersion ver = parseProtocolVersion(buffer, cursor);
skipWhitespace(buffer, cursor);
if (!cursor.atEnd()) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
return createRequestLine(method, uri, ver);
} catch (IndexOutOfBoundsException e) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
}
示例3: parseRequestLine
import org.apache.http.util.CharArrayBuffer; //導入方法依賴的package包/類
/**
* Parses a request line.
*
* @param buffer a buffer holding the line to parse
*
* @return the parsed request line
*
* @throws ParseException in case of a parse error
*/
public RequestLine parseRequestLine(final CharArrayBuffer buffer,
final ParserCursor cursor) throws ParseException {
Args.notNull(buffer, "Char array buffer");
Args.notNull(cursor, "Parser cursor");
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
try {
skipWhitespace(buffer, cursor);
int i = cursor.getPos();
int blank = buffer.indexOf(' ', i, indexTo);
if (blank < 0) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
final String method = buffer.substringTrimmed(i, blank);
cursor.updatePos(blank);
skipWhitespace(buffer, cursor);
i = cursor.getPos();
blank = buffer.indexOf(' ', i, indexTo);
if (blank < 0) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
final String uri = buffer.substringTrimmed(i, blank);
cursor.updatePos(blank);
final ProtocolVersion ver = parseProtocolVersion(buffer, cursor);
skipWhitespace(buffer, cursor);
if (!cursor.atEnd()) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
return createRequestLine(method, uri, ver);
} catch (final IndexOutOfBoundsException e) {
throw new ParseException("Invalid request line: " +
buffer.substring(indexFrom, indexTo));
}
}