本文整理了Java中okio.BufferedSource.indexOfElement()
方法的一些代码示例,展示了BufferedSource.indexOfElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedSource.indexOfElement()
方法的具体详情如下:
包路径:okio.BufferedSource
类名称:BufferedSource
方法名:indexOfElement
[英]Returns the index of the first byte in targetBytes in the buffer. This expands the buffer as necessary until a target byte is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested byte is found.
[中]返回缓冲区中targetBytes中第一个字节的索引。这会根据需要扩展缓冲区,直到找到目标字节。这会将无限数量的字节读入缓冲区。如果在找到请求的字节之前流已耗尽,则返回-1。
代码示例来源:origin: square/moshi
/** Returns an unquoted value as a string. */
private String nextUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
return i != -1 ? buffer.readUtf8(i) : buffer.readUtf8();
}
代码示例来源:origin: square/moshi
/**
* Advances the position until after the next newline character. If the line
* is terminated by "\r\n", the '\n' must be consumed as whitespace by the
* caller.
*/
private void skipToEndOfLine() throws IOException {
long index = source.indexOfElement(LINEFEED_OR_CARRIAGE_RETURN);
buffer.skip(index != -1 ? index + 1 : buffer.size());
}
代码示例来源:origin: square/moshi
private void skipUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
buffer.skip(i != -1L ? i : buffer.size());
}
代码示例来源:origin: apollographql/apollo-android
/** Returns an unquoted value as a string. */
private String nextUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
return i != -1 ? buffer.readUtf8(i) : buffer.readUtf8();
}
代码示例来源:origin: apollographql/apollo-android
/**
* Advances the position until after the next newline character. If the line
* is terminated by "\r\n", the '\n' must be consumed as whitespace by the
* caller.
*/
private void skipToEndOfLine() throws IOException {
long index = source.indexOfElement(LINEFEED_OR_CARRIAGE_RETURN);
buffer.skip(index != -1 ? index + 1 : buffer.size());
}
代码示例来源:origin: apollographql/apollo-android
private void skipUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
buffer.skip(i != -1L ? i : buffer.size());
}
代码示例来源:origin: square/moshi
private void skipQuotedValue(ByteString runTerminator) throws IOException {
while (true) {
long index = source.indexOfElement(runTerminator);
if (index == -1L) throw syntaxError("Unterminated string");
if (buffer.getByte(index) == '\\') {
buffer.skip(index + 1);
readEscapeCharacter();
} else {
buffer.skip(index + 1);
return;
}
}
}
代码示例来源:origin: square/moshi
StringBuilder builder = null;
while (true) {
long index = source.indexOfElement(runTerminator);
if (index == -1L) throw syntaxError("Unterminated string");
代码示例来源:origin: square/okio
@Test public void indexOfElementWithFromIndex() throws Exception {
sink.writeUtf8("aaa");
sink.emit();
assertEquals(0, source.indexOfElement(ByteString.encodeUtf8("a")));
assertEquals(0, source.indexOfElement(ByteString.encodeUtf8("a"), 0));
assertEquals(1, source.indexOfElement(ByteString.encodeUtf8("a"), 1));
assertEquals(2, source.indexOfElement(ByteString.encodeUtf8("a"), 2));
}
代码示例来源:origin: apollographql/apollo-android
private void skipQuotedValue(ByteString runTerminator) throws IOException {
while (true) {
long index = source.indexOfElement(runTerminator);
if (index == -1L) throw syntaxError("Unterminated string");
if (buffer.getByte(index) == '\\') {
buffer.skip(index + 1);
readEscapeCharacter();
} else {
buffer.skip(index + 1);
return;
}
}
}
代码示例来源:origin: square/okio
@Test public void indexOfElement() throws IOException {
sink.writeUtf8("a").writeUtf8(repeat('b', SEGMENT_SIZE)).writeUtf8("c");
sink.emit();
assertEquals(0, source.indexOfElement(ByteString.encodeUtf8("DEFGaHIJK")));
assertEquals(1, source.indexOfElement(ByteString.encodeUtf8("DEFGHIJKb")));
assertEquals(SEGMENT_SIZE + 1, source.indexOfElement(ByteString.encodeUtf8("cDEFGHIJK")));
assertEquals(1, source.indexOfElement(ByteString.encodeUtf8("DEFbGHIc")));
assertEquals(-1L, source.indexOfElement(ByteString.encodeUtf8("DEFGHIJK")));
assertEquals(-1L, source.indexOfElement(ByteString.encodeUtf8("")));
}
代码示例来源:origin: apollographql/apollo-android
StringBuilder builder = null;
while (true) {
long index = source.indexOfElement(runTerminator);
if (index == -1L) throw syntaxError("Unterminated string");
代码示例来源:origin: square/okio
@Test public void indexOfElementWithOffset() throws IOException {
sink.writeUtf8("a").writeUtf8(repeat('b', SEGMENT_SIZE)).writeUtf8("c");
sink.emit();
assertEquals(-1, source.indexOfElement(ByteString.encodeUtf8("DEFGaHIJK"), 1));
assertEquals(15, source.indexOfElement(ByteString.encodeUtf8("DEFGHIJKb"), 15));
}
代码示例来源:origin: square/okhttp
long lineEnd = source.indexOfElement(CRLF);
if (lineEnd == -1L) {
return false;
代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime
/**
* Advances the position until after the next newline character. If the line
* is terminated by "\r\n", the '\n' must be consumed as whitespace by the
* caller.
*/
private void skipToEndOfLine() throws IOException {
long index = source.indexOfElement(LINEFEED_OR_CARRIAGE_RETURN);
buffer.skip(index != -1 ? index + 1 : buffer.size());
}
代码示例来源:origin: com.squareup.moshi/moshi
/** Returns an unquoted value as a string. */
private String nextUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
return i != -1 ? buffer.readUtf8(i) : buffer.readUtf8();
}
代码示例来源:origin: com.squareup.moshi/moshi
/**
* Advances the position until after the next newline character. If the line
* is terminated by "\r\n", the '\n' must be consumed as whitespace by the
* caller.
*/
private void skipToEndOfLine() throws IOException {
long index = source.indexOfElement(LINEFEED_OR_CARRIAGE_RETURN);
buffer.skip(index != -1 ? index + 1 : buffer.size());
}
代码示例来源:origin: Tickaroo/tikxml
/** Returns an unquoted value as a string. */
private String nextUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
return i != -1 ? buffer.readUtf8(i) : buffer.readUtf8();
}
代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android
/** Returns an unquoted value as a string. */
private String nextUnquotedValue() throws IOException {
long i = source.indexOfElement(UNQUOTED_STRING_TERMINALS);
return i != -1 ? buffer.readUtf8(i) : buffer.readUtf8();
}
代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android
/**
* Advances the position until after the next newline character. If the line
* is terminated by "\r\n", the '\n' must be consumed as whitespace by the
* caller.
*/
private void skipToEndOfLine() throws IOException {
long index = source.indexOfElement(LINEFEED_OR_CARRIAGE_RETURN);
buffer.skip(index != -1 ? index + 1 : buffer.size());
}
内容来源于网络,如有侵权,请联系作者删除!