热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

okhttp3.internal.Util.delimiterOffset()方法的使用及代码示例

本文整理了Java中okhttp3.internal.Util.delimiterOffset()方法的一些代码示例,展示了Util.delimiterOf

本文整理了Java中okhttp3.internal.Util.delimiterOffset()方法的一些代码示例,展示了Util.delimiterOffset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.delimiterOffset()方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:delimiterOffset

Util.delimiterOffset介绍

[英]Returns the index of the first character in input that is delimiter. Returns limit if there is no such character.
[中]返回输入中作为分隔符的第一个字符的索引。如果没有这样的字符,则返回limit。

代码示例

代码示例来源:origin: square/okhttp

/**
* Returns the username, or an empty string if none is set.
*
*


*

*

*

*

*

*
URL{@code encodedUsername()}
{@code http://host/}{@code ""}
{@code http://username@host/}{@code "username"}
{@code http://username:password@host/}{@code "username"}
{@code http://a%20b:c%20d@host/}{@code "a%20b"}

*/
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

代码示例来源:origin: square/okhttp

/**
* Returns the entire path of this URL encoded for use in HTTP resource resolution. The returned
* path will start with {@code "/"}.
*
*


*

*

*

*

*
URL{@code encodedPath()}
{@code http://host/}{@code "/"}
{@code http://host/a/b/c}{@code "/a/b/c"}
{@code http://host/a/b%20c/d}{@code "/a/b%20c/d"}

*/
public String encodedPath() {
int pathStart = url.indexOf('/', scheme.length() + 3); // "://".length() == 3.
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
return url.substring(pathStart, pathEnd);
}

代码示例来源:origin: square/okhttp

private Builder addPathSegments(String pathSegments, boolean alreadyEncoded) {
int offset = 0;
do {
int segmentEnd = delimiterOffset(pathSegments, offset, pathSegments.length(), "/\\");
boolean addTrailingSlash = segmentEnd push(pathSegments, offset, segmentEnd, addTrailingSlash, alreadyEncoded);
offset = segmentEnd + 1;
} while (offset <= pathSegments.length());
return this;
}

代码示例来源:origin: square/okhttp

/**
* Returns a list of encoded path segments like {@code ["a", "b", "c"]} for the URL {@code
* http://host/a/b/c}. This list is never empty though it may contain a single empty string.
*
*


*

*

*

*

*
URL{@code encodedPathSegments()}
{@code http://host/}{@code [""]}
{@code http://host/a/b/c}{@code ["a", "b", "c"]}
{@code http://host/a/b%20c/d}{@code ["a", "b%20c", "d"]}

*/
public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: square/okhttp

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*
*


*

*

*

*

*

*

*
URL{@code encodedQuery()}
{@code http://host/}null
{@code http://host/?}{@code ""}
{@code http://host/?a=apple&k=key+lime}{@code
* "a=apple&k=key+lime"}
{@code http://host/?a=apple&a=apricot}{@code "a=apple&a=apricot"}
{@code http://host/?a=apple&b}{@code "a=apple&b"}

*/
public @Nullable String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: square/okhttp

private void resolvePath(String input, int pos, int limit) {
// Read a delimiter.
if (pos == limit) {
// Empty path: keep the base path as-is.
return;
}
char c = input.charAt(pos);
if (c == '/' || c == '\\') {
// Absolute path: reset to the default "/".
encodedPathSegments.clear();
encodedPathSegments.add("");
pos++;
} else {
// Relative path: clear everything after the last '/'.
encodedPathSegments.set(encodedPathSegments.size() - 1, "");
}
// Read path segments.
for (int i = pos; i int pathSegmentDelimiterOffset = delimiterOffset(input, i, limit, "/\\");
boolean segmentHasTrailingSlash = pathSegmentDelimiterOffset push(input, i, pathSegmentDelimiterOffset, segmentHasTrailingSlash, true);
i = pathSegmentDelimiterOffset;
if (segmentHasTrailingSlash) i++;
}
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the entire path of this URL encoded for use in HTTP resource resolution. The returned
* path will start with {@code "/"}.
*
*


*

*

*

*

*
URL{@code encodedPath()}
{@code http://host/}{@code "/"}
{@code http://host/a/b/c}{@code "/a/b/c"}
{@code http://host/a/b%20c/d}{@code "/a/b%20c/d"}

*/
public String encodedPath() {
int pathStart = url.indexOf('/', scheme.length() + 3); // "://".length() == 3.
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
return url.substring(pathStart, pathEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the username, or an empty string if none is set.
*
*


*

*

*

*

*

*
URL{@code encodedUsername()}
{@code http://host/}{@code ""}
{@code http://username@host/}{@code "username"}
{@code http://username:password@host/}{@code "username"}
{@code http://a%20b:c%20d@host/}{@code "a%20b"}

*/
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

private Builder addPathSegments(String pathSegments, boolean alreadyEncoded) {
int offset = 0;
do {
int segmentEnd = delimiterOffset(pathSegments, offset, pathSegments.length(), "/\\");
boolean addTrailingSlash = segmentEnd push(pathSegments, offset, segmentEnd, addTrailingSlash, alreadyEncoded);
offset = segmentEnd + 1;
} while (offset <= pathSegments.length());
return this;
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*
*


*

*

*

*

*

*

*
URL{@code encodedQuery()}
{@code http://host/}null
{@code http://host/?}{@code ""}
{@code http://host/?a=apple&k=key+lime}{@code
* "a=apple&k=key+lime"}
{@code http://host/?a=apple&a=apricot}{@code "a=apple&a=apricot"}
{@code http://host/?a=apple&b}{@code "a=apple&b"}

*/
public @Nullable String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

/**
* Returns a list of encoded path segments like {@code ["a", "b", "c"]} for the URL {@code
* http://host/a/b/c}. This list is never empty though it may contain a single empty string.
*
*


*

*

*

*

*
URL{@code encodedPathSegments()}
{@code http://host/}{@code [""]}
{@code http://host/a/b/c}{@code ["a", "b", "c"]}
{@code http://host/a/b%20c/d}{@code ["a", "b%20c", "d"]}

*/
public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: square/okhttp

List result = new ArrayList<>();
for (int pos = 0, limit = header.length(), pairEnd; pos pairEnd = delimiterOffset(header, pos, limit, ";,");
int equalsSign = delimiterOffset(header, pos, pairEnd, '=');
String name = trimSubstring(header, pos, equalsSign);
if (name.startsWith("$")) continue;

代码示例来源:origin: com.squareup.okhttp3/okhttp

private void resolvePath(String input, int pos, int limit) {
// Read a delimiter.
if (pos == limit) {
// Empty path: keep the base path as-is.
return;
}
char c = input.charAt(pos);
if (c == '/' || c == '\\') {
// Absolute path: reset to the default "/".
encodedPathSegments.clear();
encodedPathSegments.add("");
pos++;
} else {
// Relative path: clear everything after the last '/'.
encodedPathSegments.set(encodedPathSegments.size() - 1, "");
}
// Read path segments.
for (int i = pos; i int pathSegmentDelimiterOffset = delimiterOffset(input, i, limit, "/\\");
boolean segmentHasTrailingSlash = pathSegmentDelimiterOffset push(input, i, pathSegmentDelimiterOffset, segmentHasTrailingSlash, true);
i = pathSegmentDelimiterOffset;
if (segmentHasTrailingSlash) i++;
}
}

代码示例来源:origin: square/okhttp

static @Nullable COOKIE parse(long currentTimeMillis, HttpUrl url, String setCOOKIE) {
int pos = 0;
int limit = setCOOKIE.length();
int COOKIEPairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int pairEqualsSign = delimiterOffset(setCOOKIE, pos, COOKIEPairEnd, '=');
if (pairEqualsSign == COOKIEPairEnd) return null;
int attributePairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int attributeEqualsSign = delimiterOffset(setCOOKIE, pos, attributePairEnd, '=');
String attributeName = trimSubstring(setCOOKIE, pos, attributeEqualsSign);
String attributeValue = attributeEqualsSign

代码示例来源:origin: square/okhttp

authority:
while (true) {
int compOnentDelimiterOffset= delimiterOffset(input, pos, limit, "@/\\?#");
int c = componentDelimiterOffset != limit
? input.charAt(componentDelimiterOffset)
int passwordColOnOffset= delimiterOffset(
input, pos, componentDelimiterOffset, ':');
String canOnicalUsername= canonicalize(input, pos, passwordColonOffset,
int pathDelimiterOffset = delimiterOffset(input, pos, limit, "?#");
resolvePath(input, pos, pathDelimiterOffset);
pos = pathDelimiterOffset;
int queryDelimiterOffset = delimiterOffset(input, pos, limit, '#');
this.encodedQueryNamesAndValues = queryStringToNamesAndValues(canonicalize(
input, pos + 1, queryDelimiterOffset, QUERY_ENCODE_SET, true, false, true, true, null));

代码示例来源:origin: com.squareup.okhttp3/okhttp

static @Nullable COOKIE parse(long currentTimeMillis, HttpUrl url, String setCOOKIE) {
int pos = 0;
int limit = setCOOKIE.length();
int COOKIEPairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int pairEqualsSign = delimiterOffset(setCOOKIE, pos, COOKIEPairEnd, '=');
if (pairEqualsSign == COOKIEPairEnd) return null;
int attributePairEnd = delimiterOffset(setCOOKIE, pos, limit, ';');
int attributeEqualsSign = delimiterOffset(setCOOKIE, pos, attributePairEnd, '=');
String attributeName = trimSubstring(setCOOKIE, pos, attributeEqualsSign);
String attributeValue = attributeEqualsSign

代码示例来源:origin: com.squareup.okhttp3/okhttp

authority:
while (true) {
int compOnentDelimiterOffset= delimiterOffset(input, pos, limit, "@/\\?#");
int c = componentDelimiterOffset != limit
? input.charAt(componentDelimiterOffset)
int passwordColOnOffset= delimiterOffset(
input, pos, componentDelimiterOffset, ':');
String canOnicalUsername= canonicalize(input, pos, passwordColonOffset,
int pathDelimiterOffset = delimiterOffset(input, pos, limit, "?#");
resolvePath(input, pos, pathDelimiterOffset);
pos = pathDelimiterOffset;
int queryDelimiterOffset = delimiterOffset(input, pos, limit, '#');
this.encodedQueryNamesAndValues = queryStringToNamesAndValues(canonicalize(
input, pos + 1, queryDelimiterOffset, QUERY_ENCODE_SET, true, false, true, true, null));

代码示例来源:origin: duzechao/OKHttpUtils

public List encodedPathSegments() {
int pathStart = url.indexOf('/', scheme.length() + 3);
int pathEnd = delimiterOffset(url, pathStart, url.length(), "?#");
List result = new ArrayList<>();
for (int i = pathStart; i i++; // Skip the '/'.
int segmentEnd = delimiterOffset(url, i, pathEnd, '/');
result.add(url.substring(i, segmentEnd));
i = segmentEnd;
}
return result;
}

代码示例来源:origin: duzechao/OKHttpUtils

/**
* Returns the query of this URL, encoded for use in HTTP resource resolution. The returned string
* may be null (for URLs with no query), empty (for URLs with an empty query) or non-empty (all
* other URLs).
*/
public String encodedQuery() {
if (queryNamesAndValues == null) return null; // No query.
int queryStart = url.indexOf('?') + 1;
int queryEnd = delimiterOffset(url, queryStart + 1, url.length(), '#');
return url.substring(queryStart, queryEnd);
}

代码示例来源:origin: duzechao/OKHttpUtils

/** Returns the username, or an empty string if none is set. */
public String encodedUsername() {
if (username.isEmpty()) return "";
int usernameStart = scheme.length() + 3; // "://".length() == 3.
int usernameEnd = delimiterOffset(url, usernameStart, url.length(), ":@");
return url.substring(usernameStart, usernameEnd);
}

推荐阅读
author-avatar
贰少爷闯天涯_964
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有