本文整理匯總了Java中org.apache.http.util.CharArrayBuffer.substring方法的典型用法代碼示例。如果您正苦於以下問題:Java CharArrayBuffer.substring方法的具體用法?Java CharArrayBuffer.substring怎麽用?Java CharArrayBuffer.substring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.util.CharArrayBuffer
的用法示例。
在下文中一共展示了CharArrayBuffer.substring方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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));
}
}
示例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 {
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));
}
}