本文整理汇总了Java中org.apache.http.message.ParserCursor.getUpperBound方法的典型用法代码示例。如果您正苦于以下问题:Java ParserCursor.getUpperBound方法的具体用法?Java ParserCursor.getUpperBound怎么用?Java ParserCursor.getUpperBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.message.ParserCursor
的用法示例。
在下文中一共展示了ParserCursor.getUpperBound方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyContent
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
* Transfers content into the destination buffer until a whitespace character or any of
* the given delimiters is encountered.
*
* @param buf buffer with the sequence of chars to be parsed
* @param cursor defines the bounds and current position of the buffer
* @param delimiters set of delimiting characters. Can be <code>null</code> if the value
* is delimited by a whitespace only.
* @param dst destination buffer
*/
public void copyContent(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters,
final StringBuilder dst) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
for (int i = indexFrom; i < indexTo; i++) {
final char current = buf.charAt(i);
if ((delimiters != null && delimiters.get(current)) || isWhitespace(current)) {
break;
} else {
pos++;
dst.append(current);
}
}
cursor.updatePos(pos);
}
示例2: copyUnquotedContent
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
* Transfers content into the destination buffer until a whitespace character, a quote,
* or any of the given delimiters is encountered.
*
* @param buf buffer with the sequence of chars to be parsed
* @param cursor defines the bounds and current position of the buffer
* @param delimiters set of delimiting characters. Can be <code>null</code> if the value
* is delimited by a whitespace or a quote only.
* @param dst destination buffer
*/
public void copyUnquotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
final BitSet delimiters, final StringBuilder dst) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
for (int i = indexFrom; i < indexTo; i++) {
final char current = buf.charAt(i);
if ((delimiters != null && delimiters.get(current))
|| isWhitespace(current) || current == DQUOTE) {
break;
} else {
pos++;
dst.append(current);
}
}
cursor.updatePos(pos);
}
示例3: skipWhiteSpace
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
* Skips semantically insignificant whitespace characters and moves the cursor to the closest
* non-whitespace character.
*
* @param buf buffer with the sequence of chars to be parsed
* @param cursor defines the bounds and current position of the buffer
*/
public void skipWhiteSpace(final CharArrayBuffer buf, final ParserCursor cursor) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
for (int i = indexFrom; i < indexTo; i++) {
final char current = buf.charAt(i);
if (!isWhitespace(current)) {
break;
} else {
pos++;
}
}
cursor.updatePos(pos);
}
示例4: copyQuotedContent
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
/**
* Transfers content enclosed with quote marks into the destination buffer.
*
* @param buf buffer with the sequence of chars to be parsed
* @param cursor defines the bounds and current position of the buffer
* @param dst destination buffer
*/
public void copyQuotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
final StringBuilder dst) {
if (cursor.atEnd()) {
return;
}
int pos = cursor.getPos();
int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
char current = buf.charAt(pos);
if (current != DQUOTE) {
return;
}
pos++;
indexFrom++;
boolean escaped = false;
for (int i = indexFrom; i < indexTo; i++, pos++) {
current = buf.charAt(i);
if (escaped) {
if (current != DQUOTE && current != ESCAPE) {
dst.append(ESCAPE);
}
dst.append(current);
escaped = false;
} else {
if (current == DQUOTE) {
pos++;
break;
}
if (current == ESCAPE) {
escaped = true;
} else if (current != CR && current != LF) {
dst.append(current);
}
}
}
cursor.updatePos(pos);
}
示例5: copyUnquotedContent
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public void copyUnquotedContent(
final CharArrayBuffer buf,
final ParserCursor cursor,
final BitSet delimiters,
final StringBuilder dst) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
boolean escaped = false;
for (int i = indexFrom; i < indexTo; i++, pos++) {
final char current = buf.charAt(i);
if (escaped) {
dst.append(current);
escaped = false;
} else {
if ((delimiters != null && delimiters.get(current))
|| TokenParser.isWhitespace(current) || current == '\"') {
break;
} else if (current == '\\') {
escaped = true;
} else {
dst.append(current);
}
}
}
cursor.updatePos(pos);
}
示例6: parseProtocolVersion
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public ProtocolVersion parseProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) {
int index = cursor.getPos();
int bound = cursor.getUpperBound();
if (bound >= index + 4 && "ICY ".equals(buffer.substring(index, index + 4))) {
cursor.updatePos(index + 4);
return ICY_PROTOCOL;
}
return super.parseProtocolVersion(buffer, cursor);
}
示例7: hasProtocolVersion
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public boolean hasProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) {
int index = cursor.getPos();
int bound = cursor.getUpperBound();
if (bound >= index + 4 && "ICY ".equals(buffer.substring(index, index + 4))) {
return true;
}
return super.hasProtocolVersion(buffer, cursor);
}
示例8: skipDelims
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
private void skipDelims(final CharSequence buf, final ParserCursor cursor) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
for (int i = indexFrom; i < indexTo; i++) {
final char current = buf.charAt(i);
if (DELIMS.get(current)) {
pos++;
} else {
break;
}
}
cursor.updatePos(pos);
}
示例9: copyContent
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
private void copyContent(final CharSequence buf, final ParserCursor cursor, final StringBuilder dst) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
final int indexTo = cursor.getUpperBound();
for (int i = indexFrom; i < indexTo; i++) {
final char current = buf.charAt(i);
if (DELIMS.get(current)) {
break;
} else {
pos++;
dst.append(current);
}
}
cursor.updatePos(pos);
}
示例10: parseProtocolVersion
import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public ProtocolVersion parseProtocolVersion(CharArrayBuffer buffer, 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");
}
final int protolength = ICY_PROTOCOL_NAME.length();
int indexFrom = cursor.getPos();
int indexTo = cursor.getUpperBound();
skipWhitespace(buffer, cursor);
int i = cursor.getPos();
// long enough for "HTTP/1.1"?
if (i + protolength + 4 > indexTo) {
throw new ParseException("Not a valid protocol version: " + buffer.substring(indexFrom, indexTo));
}
// check the protocol name and slash
if (!buffer.substring(i, i + protolength).equals(ICY_PROTOCOL_NAME)) {
return super.parseProtocolVersion(buffer, cursor);
}
cursor.updatePos(i + protolength);
return createProtocolVersion(1, 0);
}