当前位置: 首页>>代码示例>>Java>>正文


Java ParserCursor.getPos方法代码示例

本文整理汇总了Java中org.apache.http.message.ParserCursor.getPos方法的典型用法代码示例。如果您正苦于以下问题:Java ParserCursor.getPos方法的具体用法?Java ParserCursor.getPos怎么用?Java ParserCursor.getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.message.ParserCursor的用法示例。


在下文中一共展示了ParserCursor.getPos方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:27,代码来源:TokenParser.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:28,代码来源:TokenParser.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:22,代码来源:TokenParser.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:45,代码来源:TokenParser.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:29,代码来源:DistinguishedNameParser.java

示例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);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:13,代码来源:HttpClientTools.java

示例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);
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:12,代码来源:HttpClientTools.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:LaxExpiresHandler.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:LaxExpiresHandler.java

示例10: hasProtocolVersion

import org.apache.http.message.ParserCursor; //导入方法依赖的package包/类
@Override
public boolean hasProtocolVersion(CharArrayBuffer buffer, ParserCursor cursor) {
	boolean superFound = super.hasProtocolVersion(buffer, cursor);
	if (superFound) {
		return true;
	}
	int index = cursor.getPos();

	final int protolength = ICY_PROTOCOL_NAME.length();

	if (buffer.length() < protolength)
		return false; // not long enough for "HTTP/1.1"

	if (index < 0) {
		// end of line, no tolerance for trailing whitespace
		// this works only for single-digit major and minor version
		index = buffer.length() - protolength;
	} else if (index == 0) {
		// beginning of line, tolerate leading whitespace
		while ((index < buffer.length()) && HTTP.isWhitespace(buffer.charAt(index))) {
			index++;
		}
	} // else within line, don't tolerate whitespace

	return index + protolength <= buffer.length()
			&& buffer.substring(index, index + protolength).equals(ICY_PROTOCOL_NAME);

}
 
开发者ID:andrewhanks,项目名称:MediaPlayerProxy,代码行数:29,代码来源:HttpUtils.java

示例11: 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);
}
 
开发者ID:andrewhanks,项目名称:MediaPlayerProxy,代码行数:34,代码来源:HttpUtils.java


注:本文中的org.apache.http.message.ParserCursor.getPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。